github.com/openshift/installer@v1.4.17/pkg/asset/releaseimage/pullspec.go (about) 1 package releaseimage 2 3 import ( 4 "context" 5 "os" 6 7 dockerref "github.com/containers/image/v5/docker/reference" 8 "github.com/pkg/errors" 9 "github.com/sirupsen/logrus" 10 11 "github.com/openshift/installer/pkg/asset" 12 ) 13 14 // Image asset generates the release-image pullspec for the cluster 15 type Image struct { 16 PullSpec string 17 Repository string 18 } 19 20 var _ asset.Asset = (*Image)(nil) 21 22 // Dependencies is the list of assets required to generate ReleaseImage. 23 func (a *Image) Dependencies() []asset.Asset { 24 return []asset.Asset{} 25 } 26 27 // Generate creates the asset using the dependencies. 28 func (a *Image) Generate(_ context.Context, dependencies asset.Parents) error { 29 var pullSpec string 30 if ri, ok := os.LookupEnv("OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE"); ok && ri != "" { 31 logrus.Warnf("Found override for release image (%s). Please be warned, this is not advised", ri) 32 pullSpec = ri 33 } else { 34 var err error 35 pullSpec, err = Default() 36 if err != nil { 37 return errors.Wrap(err, "failed to load default release image") 38 } 39 logrus.Debugf("Using internal constant for release image %s", pullSpec) 40 } 41 a.PullSpec = pullSpec 42 43 ref, err := dockerref.ParseNamed(pullSpec) 44 if err != nil { 45 return errors.Wrap(err, "failed to parse release-image pull spec") 46 } 47 a.Repository = ref.Name() 48 49 return nil 50 } 51 52 // Name is the human friendly name for the asset. 53 func (a *Image) Name() string { 54 return "Release Image Pull Spec" 55 }