github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/pullsecret.go (about)

     1  package installconfig
     2  
     3  import (
     4  	"context"
     5  
     6  	survey "github.com/AlecAivazis/survey/v2"
     7  	"github.com/pkg/errors"
     8  
     9  	"github.com/openshift/installer/pkg/asset"
    10  	"github.com/openshift/installer/pkg/validate"
    11  )
    12  
    13  type pullSecret struct {
    14  	PullSecret string
    15  }
    16  
    17  var _ asset.Asset = (*pullSecret)(nil)
    18  
    19  // Dependencies returns no dependencies.
    20  func (a *pullSecret) Dependencies() []asset.Asset {
    21  	return []asset.Asset{}
    22  }
    23  
    24  // Generate queries for the pull secret from the user.
    25  func (a *pullSecret) Generate(context.Context, asset.Parents) error {
    26  	if err := survey.Ask([]*survey.Question{
    27  		{
    28  			Prompt: &survey.Password{
    29  				Message: "Pull Secret",
    30  				Help:    "The container registry pull secret for this cluster, as a single line of JSON (e.g. {\"auths\": {...}}).\n\nYou can get this secret from https://console.redhat.com/openshift/install/pull-secret",
    31  			},
    32  			Validate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {
    33  				return validate.ImagePullSecret(ans.(string))
    34  			}),
    35  		},
    36  	}, &a.PullSecret); err != nil {
    37  		return errors.Wrap(err, "failed UserInput")
    38  	}
    39  	return nil
    40  }
    41  
    42  // Name returns the human-friendly name of the asset.
    43  func (a *pullSecret) Name() string {
    44  	return "Pull Secret"
    45  }