github.com/openshift/installer@v1.4.17/pkg/asset/templates/content/bootkube/kube-cloud-config.go (about) 1 package bootkube 2 3 import ( 4 "context" 5 "os" 6 "path/filepath" 7 8 "github.com/openshift/installer/pkg/asset" 9 "github.com/openshift/installer/pkg/asset/templates/content" 10 ) 11 12 const ( 13 kubeCloudConfigFileName = "kube-cloud-config.yaml" 14 ) 15 16 var _ asset.WritableAsset = (*KubeCloudConfig)(nil) 17 18 // KubeCloudConfig is the constant to represent contents of kube_cloudconfig.yaml file 19 type KubeCloudConfig struct { 20 FileList []*asset.File 21 } 22 23 // Dependencies returns all of the dependencies directly needed by the asset 24 func (t *KubeCloudConfig) Dependencies() []asset.Asset { 25 return []asset.Asset{} 26 } 27 28 // Name returns the human-friendly name of the asset. 29 func (t *KubeCloudConfig) Name() string { 30 return "KubeCloudConfig" 31 } 32 33 // Generate generates the actual files by this asset 34 func (t *KubeCloudConfig) Generate(_ context.Context, parents asset.Parents) error { 35 fileName := kubeCloudConfigFileName 36 data, err := content.GetBootkubeTemplate(fileName) 37 if err != nil { 38 return err 39 } 40 t.FileList = []*asset.File{ 41 { 42 Filename: filepath.Join(content.TemplateDir, fileName), 43 Data: []byte(data), 44 }, 45 } 46 return nil 47 } 48 49 // Files returns the files generated by the asset. 50 func (t *KubeCloudConfig) Files() []*asset.File { 51 return t.FileList 52 } 53 54 // Load returns the asset from disk. 55 func (t *KubeCloudConfig) Load(f asset.FileFetcher) (bool, error) { 56 file, err := f.FetchByName(filepath.Join(content.TemplateDir, kubeCloudConfigFileName)) 57 if err != nil { 58 if os.IsNotExist(err) { 59 return false, nil 60 } 61 return false, err 62 } 63 t.FileList = []*asset.File{file} 64 return true, nil 65 }