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

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