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

     1  package image
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"fmt"
     7  	"os"
     8  
     9  	"github.com/openshift/installer/pkg/asset"
    10  )
    11  
    12  const (
    13  	postDeploymentFilename = "post.sh"
    14  )
    15  
    16  // PostDeployment manages the post image-based installation steps.
    17  type PostDeployment struct {
    18  	File *asset.File
    19  }
    20  
    21  var (
    22  	_ asset.WritableAsset = (*PostDeployment)(nil)
    23  )
    24  
    25  // Name returns a human friendly name for the asset.
    26  func (pd *PostDeployment) Name() string {
    27  	return "Post Deployment Script"
    28  }
    29  
    30  // Dependencies returns all of the dependencies directly needed by the
    31  // asset.
    32  func (pd *PostDeployment) Dependencies() []asset.Asset {
    33  	return []asset.Asset{}
    34  }
    35  
    36  // Generate is not required for PostDeployment.
    37  func (pd *PostDeployment) Generate(_ context.Context, dependencies asset.Parents) error {
    38  	return nil
    39  }
    40  
    41  // Files returns the files generated by the asset.
    42  func (pd *PostDeployment) Files() []*asset.File {
    43  	if pd.File != nil {
    44  		return []*asset.File{pd.File}
    45  	}
    46  	return []*asset.File{}
    47  }
    48  
    49  // Load reads the asset file from disk.
    50  func (pd *PostDeployment) Load(f asset.FileFetcher) (found bool, err error) {
    51  	file, err := f.FetchByName(postDeploymentFilename)
    52  	if err != nil {
    53  		if errors.Is(err, os.ErrNotExist) {
    54  			return false, nil
    55  		}
    56  		return false, fmt.Errorf("failed to load the %s file: %w", postDeploymentFilename, err)
    57  	}
    58  
    59  	pd.File = file
    60  	return true, nil
    61  }