github.com/openshift/installer@v1.4.17/pkg/asset/agent/manifests/extramanifests.go (about)

     1  package manifests
     2  
     3  import (
     4  	"context"
     5  	"path/filepath"
     6  
     7  	"github.com/pkg/errors"
     8  
     9  	"github.com/openshift/installer/pkg/asset"
    10  )
    11  
    12  const (
    13  	openshiftManifestDir = "openshift"
    14  )
    15  
    16  // ExtraManifests manages the additional manifests for cluster customization
    17  type ExtraManifests struct {
    18  	FileList []*asset.File
    19  }
    20  
    21  var (
    22  	_ asset.WritableAsset = (*ExtraManifests)(nil)
    23  )
    24  
    25  // Name returns a human friendly name for the operator
    26  func (em *ExtraManifests) Name() string {
    27  	return "Extra Manifests"
    28  }
    29  
    30  // Dependencies returns all of the dependencies directly needed by the
    31  // Master asset
    32  func (em *ExtraManifests) Dependencies() []asset.Asset {
    33  	return []asset.Asset{}
    34  }
    35  
    36  // Generate is not required for ExtraManifests.
    37  func (em *ExtraManifests) Generate(_ context.Context, dependencies asset.Parents) error {
    38  	return nil
    39  }
    40  
    41  // Files returns the files generated by the asset.
    42  func (em *ExtraManifests) Files() []*asset.File {
    43  	return em.FileList
    44  }
    45  
    46  // Load reads the asset files from disk.
    47  func (em *ExtraManifests) Load(f asset.FileFetcher) (found bool, err error) {
    48  	yamlFileList, err := f.FetchByPattern(filepath.Join(openshiftManifestDir, "*.yaml"))
    49  	if err != nil {
    50  		return false, errors.Wrap(err, "failed to load *.yaml files")
    51  	}
    52  	ymlFileList, err := f.FetchByPattern(filepath.Join(openshiftManifestDir, "*.yml"))
    53  	if err != nil {
    54  		return false, errors.Wrap(err, "failed to load *.yml files")
    55  	}
    56  
    57  	em.FileList = append(em.FileList, yamlFileList...)
    58  	em.FileList = append(em.FileList, ymlFileList...)
    59  	asset.SortFiles(em.FileList)
    60  
    61  	return len(em.FileList) > 0, nil
    62  }
    63  
    64  // OpenshiftManifestDir returns the name of directory to add extra manifests.
    65  func OpenshiftManifestDir() string {
    66  	return openshiftManifestDir
    67  }