Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/openshift-install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func runRootCmd(cmd *cobra.Command, args []string) error {
level, err := logrus.ParseLevel(rootOpts.logLevel)
if err != nil {
return errors.Wrap(err, "invalid log-level")

}
logrus.SetLevel(level)
return nil
Expand Down
9 changes: 9 additions & 0 deletions cmd/openshift-install/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func newTargetsCmd() []*cobra.Command {
func runTargetCmd(targets ...asset.WritableAsset) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
assetStore := &asset.StoreImpl{}
err := assetStore.Load(rootOpts.dir)
if err != nil {
logrus.Errorf("Could not load assets from state file: %v", err)
}
for _, a := range targets {
err := assetStore.Fetch(a)
if err != nil {
Expand All @@ -91,6 +95,11 @@ func runTargetCmd(targets ...asset.WritableAsset) func(cmd *cobra.Command, args
return err
}
}
err = assetStore.Save(rootOpts.dir)
if err != nil {
errors.Wrapf(err, "failed to write to state file")
return err
}
return nil
}
}
8 changes: 4 additions & 4 deletions pkg/asset/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func (a *persistAsset) Generate(Parents) error {

type writablePersistAsset struct {
persistAsset
files []*File
FileList []*File
}

func (a *writablePersistAsset) Files() []*File {
return a.files
return a.FileList
}

func TestPersistToFile(t *testing.T) {
Expand Down Expand Up @@ -64,12 +64,12 @@ func TestPersistToFile(t *testing.T) {
defer os.RemoveAll(dir)

asset := &writablePersistAsset{
files: make([]*File, len(tc.filenames)),
FileList: make([]*File, len(tc.filenames)),
}
expectedFiles := map[string][]byte{}
for i, filename := range tc.filenames {
data := []byte(fmt.Sprintf("data%d", i))
asset.files[i] = &File{
asset.FileList[i] = &File{
Filename: filename,
Data: data,
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/asset/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
// Cluster uses the terraform executable to launch a cluster
// with the given terraform tfvar and generated templates.
type Cluster struct {
files []*asset.File
FileList []*asset.File
}

var _ asset.WritableAsset = (*Cluster)(nil)
Expand Down Expand Up @@ -67,7 +67,7 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {
return errors.Wrap(err, "failed to write terraform.tfvars file")
}

platform := terraformVariables.platform
platform := terraformVariables.Platform
if err := data.Unpack(tmpDir, platform); err != nil {
return err
}
Expand All @@ -78,7 +78,7 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {

defer func() {
if data, err2 := json.Marshal(metadata); err2 == nil {
c.files = append(c.files, &asset.File{
c.FileList = append(c.FileList, &asset.File{
Filename: MetadataFilename,
Data: data,
})
Expand All @@ -90,7 +90,7 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {
logrus.Error(err2)
}
}
// serialize metadata and stuff it into c.files
// serialize metadata and stuff it into c.FileList
}()

switch {
Expand Down Expand Up @@ -135,7 +135,7 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {

data, err2 := ioutil.ReadFile(stateFile)
if err2 == nil {
c.files = append(c.files, &asset.File{
c.FileList = append(c.FileList, &asset.File{
Filename: stateFileName,
Data: data,
})
Expand All @@ -151,7 +151,7 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) {
return err
}

// Files returns the files generated by the asset.
// Files returns the FileList generated by the asset.
func (c *Cluster) Files() []*asset.File {
return c.files
return c.FileList
}
12 changes: 6 additions & 6 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const (
// TerraformVariables depends on InstallConfig and
// Ignition to generate the terrafor.tfvars.
type TerraformVariables struct {
platform string
file *asset.File
Platform string
File *asset.File
}

var _ asset.WritableAsset = (*TerraformVariables)(nil)
Expand Down Expand Up @@ -46,7 +46,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
worker := &machine.Worker{}
parents.Get(installConfig, bootstrap, master, worker)

t.platform = installConfig.Config.Platform.Name()
t.Platform = installConfig.Config.Platform.Name()

bootstrapIgn := string(bootstrap.Files()[0].Data)

Expand All @@ -62,7 +62,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
if err != nil {
return errors.Wrap(err, "failed to get Tfvars")
}
t.file = &asset.File{
t.File = &asset.File{
Filename: tfvarsFilename,
Data: data,
}
Expand All @@ -72,8 +72,8 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {

// Files returns the files generated by the asset.
func (t *TerraformVariables) Files() []*asset.File {
if t.file != nil {
return []*asset.File{t.file}
if t.File != nil {
return []*asset.File{t.File}
}
return []*asset.File{}
}
56 changes: 28 additions & 28 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type bootstrapTemplateData struct {

// Bootstrap is an asset that generates the ignition config for bootstrap nodes.
type Bootstrap struct {
config *igntypes.Config
file *asset.File
Config *igntypes.Config
File *asset.File
}

var _ asset.WritableAsset = (*Bootstrap)(nil)
Expand Down Expand Up @@ -89,7 +89,7 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {
return errors.Wrap(err, "failed to get bootstrap templates")
}

a.config = &igntypes.Config{
a.Config = &igntypes.Config{
Ignition: igntypes.Ignition{
Version: igntypes.MaxVersion.String(),
},
Expand All @@ -100,23 +100,23 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {
a.addTectonicFiles(dependencies, templateData)
a.addTLSCertFiles(dependencies)

a.config.Systemd.Units = append(
a.config.Systemd.Units,
a.Config.Systemd.Units = append(
a.Config.Systemd.Units,
igntypes.Unit{Name: "bootkube.service", Contents: content.BootkubeSystemdContents},
igntypes.Unit{Name: "tectonic.service", Contents: content.TectonicSystemdContents, Enabled: util.BoolToPtr(true)},
igntypes.Unit{Name: "kubelet.service", Contents: applyTemplateData(content.KubeletSystemdTemplate, templateData), Enabled: util.BoolToPtr(true)},
)

a.config.Passwd.Users = append(
a.config.Passwd.Users,
a.Config.Passwd.Users = append(
a.Config.Passwd.Users,
igntypes.PasswdUser{Name: "core", SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{igntypes.SSHAuthorizedKey(installConfig.Config.Admin.SSHKey)}},
)

data, err := json.Marshal(a.config)
data, err := json.Marshal(a.Config)
if err != nil {
return errors.Wrap(err, "failed to Marshal Ignition config")
}
a.file = &asset.File{
a.File = &asset.File{
Filename: "bootstrap.ign",
Data: data,
}
Expand All @@ -131,8 +131,8 @@ func (a *Bootstrap) Name() string {

// Files returns the files generated by the asset.
func (a *Bootstrap) Files() []*asset.File {
if a.file != nil {
return []*asset.File{a.file}
if a.File != nil {
return []*asset.File{a.File}
}
return []*asset.File{}
}
Expand Down Expand Up @@ -174,13 +174,13 @@ func (a *Bootstrap) addBootstrapFiles(dependencies asset.Parents) {
kubeCoreOperator := &manifests.KubeCoreOperator{}
dependencies.Get(kubeletKubeconfig, kubeCoreOperator)

a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FileFromBytes("/etc/kubernetes/kubeconfig", 0600, kubeletKubeconfig.Files()[0].Data),
ignition.FileFromBytes("/var/lib/kubelet/kubeconfig", 0600, kubeletKubeconfig.Files()[0].Data),
)
a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, 0644, kubeCoreOperator)...,
)
}
Expand All @@ -190,16 +190,16 @@ func (a *Bootstrap) addBootkubeFiles(dependencies asset.Parents, templateData *b
manifests := &manifests.Manifests{}
dependencies.Get(adminKubeconfig, manifests)

a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FileFromString("/opt/tectonic/bootkube.sh", 0555, applyTemplateData(content.BootkubeShFileTemplate, templateData)),
)
a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, 0600, adminKubeconfig)...,
)
a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, 0644, manifests)...,
)
}
Expand All @@ -208,12 +208,12 @@ func (a *Bootstrap) addTectonicFiles(dependencies asset.Parents, templateData *b
tectonic := &manifests.Tectonic{}
dependencies.Get(tectonic)

a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FileFromString("/opt/tectonic/tectonic.sh", 0555, content.TectonicShFileContents),
)
a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FilesFromAsset(rootDir, 0644, tectonic)...,
)
}
Expand All @@ -236,13 +236,13 @@ func (a *Bootstrap) addTLSCertFiles(dependencies asset.Parents) {
&tls.ServiceAccountKeyPair{},
} {
dependencies.Get(asset)
a.config.Storage.Files = append(a.config.Storage.Files, ignition.FilesFromAsset(rootDir, 0600, asset)...)
a.Config.Storage.Files = append(a.Config.Storage.Files, ignition.FilesFromAsset(rootDir, 0600, asset)...)
}

etcdClientCertKey := &tls.EtcdClientCertKey{}
dependencies.Get(etcdClientCertKey)
a.config.Storage.Files = append(
a.config.Storage.Files,
a.Config.Storage.Files = append(
a.Config.Storage.Files,
ignition.FileFromBytes("/etc/ssl/etcd/ca.crt", 0600, etcdClientCertKey.Cert()),
)
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/asset/ignition/machine/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

// Master is an asset that generates the ignition config for master nodes.
type Master struct {
configs []*igntypes.Config
files []*asset.File
Configs []*igntypes.Config
FileList []*asset.File
}

var _ asset.WritableAsset = (*Master)(nil)
Expand All @@ -34,18 +34,18 @@ func (a *Master) Generate(dependencies asset.Parents) error {
rootCA := &tls.RootCA{}
dependencies.Get(installConfig, rootCA)

a.configs = make([]*igntypes.Config, installConfig.Config.MasterCount())
for i := range a.configs {
a.configs[i] = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "master", fmt.Sprintf("etcd_index=%d", i))
a.Configs = make([]*igntypes.Config, installConfig.Config.MasterCount())
for i := range a.Configs {
a.Configs[i] = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "master", fmt.Sprintf("etcd_index=%d", i))
}

a.files = make([]*asset.File, len(a.configs))
for i, c := range a.configs {
a.FileList = make([]*asset.File, len(a.Configs))
for i, c := range a.Configs {
data, err := json.Marshal(c)
if err != nil {
return errors.Wrap(err, "failed to marshal ignition config")
}
a.files[i] = &asset.File{
a.FileList[i] = &asset.File{
Filename: fmt.Sprintf("master-%d.ign", i),
Data: data,
}
Expand All @@ -61,5 +61,5 @@ func (a *Master) Name() string {

// Files returns the files generated by the asset.
func (a *Master) Files() []*asset.File {
return a.files
return a.FileList
}
14 changes: 7 additions & 7 deletions pkg/asset/ignition/machine/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

// Worker is an asset that generates the ignition config for worker nodes.
type Worker struct {
config *igntypes.Config
file *asset.File
Config *igntypes.Config
File *asset.File
}

var _ asset.WritableAsset = (*Worker)(nil)
Expand All @@ -33,13 +33,13 @@ func (a *Worker) Generate(dependencies asset.Parents) error {
rootCA := &tls.RootCA{}
dependencies.Get(installConfig, rootCA)

a.config = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "worker", "")
a.Config = pointerIgnitionConfig(installConfig.Config, rootCA.Cert(), "worker", "")

data, err := json.Marshal(a.config)
data, err := json.Marshal(a.Config)
if err != nil {
return errors.Wrap(err, "failed to get InstallConfig from parents")
}
a.file = &asset.File{
a.File = &asset.File{
Filename: "worker.ign",
Data: data,
}
Expand All @@ -54,8 +54,8 @@ func (a *Worker) Name() string {

// Files returns the files generated by the asset.
func (a *Worker) Files() []*asset.File {
if a.file != nil {
return []*asset.File{a.file}
if a.File != nil {
return []*asset.File{a.File}
}
return []*asset.File{}
}
4 changes: 2 additions & 2 deletions pkg/asset/installconfig/basedomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type baseDomain struct {
baseDomain string
BaseDomain string
}

var _ asset.Asset = (*baseDomain)(nil)
Expand All @@ -33,7 +33,7 @@ func (a *baseDomain) Generate(asset.Parents) error {
},
"OPENSHIFT_INSTALL_BASE_DOMAIN",
)
a.baseDomain = bd
a.BaseDomain = bd
return err
}

Expand Down
Loading