github.com/openshift/installer@v1.4.17/pkg/asset/templates/content/bootkube/pull.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  	openshiftConfigSecretPullSecretFileName = "openshift-config-secret-pull-secret.yaml.template"
    14  )
    15  
    16  var _ asset.WritableAsset = (*OpenshiftConfigSecretPullSecret)(nil)
    17  
    18  // OpenshiftConfigSecretPullSecret is the constant to represent contents of openshift-config-secret-pull-secret.yaml.template file.
    19  type OpenshiftConfigSecretPullSecret struct {
    20  	FileList []*asset.File
    21  }
    22  
    23  // Dependencies returns all of the dependencies directly needed by the asset
    24  func (t *OpenshiftConfigSecretPullSecret) Dependencies() []asset.Asset {
    25  	return []asset.Asset{}
    26  }
    27  
    28  // Name returns the human-friendly name of the asset.
    29  func (t *OpenshiftConfigSecretPullSecret) Name() string {
    30  	return "OpenshiftConfigSecretPullSecret"
    31  }
    32  
    33  // Generate generates the actual files by this asset
    34  func (t *OpenshiftConfigSecretPullSecret) Generate(_ context.Context, parents asset.Parents) error {
    35  	fileName := openshiftConfigSecretPullSecretFileName
    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 *OpenshiftConfigSecretPullSecret) Files() []*asset.File {
    51  	return t.FileList
    52  }
    53  
    54  // Load returns the asset from disk.
    55  func (t *OpenshiftConfigSecretPullSecret) Load(f asset.FileFetcher) (bool, error) {
    56  	file, err := f.FetchByName(filepath.Join(content.TemplateDir, openshiftConfigSecretPullSecretFileName))
    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  }