// NewUpdatePhaseInit creates a new update init phase executor
NewUpdatePhaseInit creates a new update init phase executor
// NewUpdatePhaseInit creates a new update init phase executor
func NewUpdatePhaseInit(
	p fsm.ExecutorParams,
	operator ops.Operator,
	apps app.Applications,
	backend, localBackend storage.Backend,
	packages pack.PackageService,
	users users.Identity,
	client *kubernetes.Clientset,
	logger log.FieldLogger,
) (*updatePhaseInit, error) {
	if p.Phase.Data == nil || p.Phase.Data.Package == nil {
		return nil, trace.BadParameter("no application package specified for phase %v", p.Phase)
	}
	if p.Phase.Data.InstalledPackage == nil {
		return nil, trace.BadParameter("no installed application package specified for phase %v", p.Phase)
	}
	if p.Phase.Data.Update == nil || len(p.Phase.Data.Update.Servers) == 0 {
		return nil, trace.BadParameter("no servers specified for phase %q", p.Phase.ID)
	}
	cluster, err := operator.GetLocalSite(context.TODO())
	if err != nil {
		return nil, trace.Wrap(err)
	}
	operation, err := operator.GetSiteOperation(fsm.OperationKey(p.Plan))
	if err != nil {
		return nil, trace.Wrap(err)
	}
	installOperation, err := ops.GetCompletedInstallOperation(cluster.Key(), operator)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	app, err := apps.GetApp(*p.Phase.Data.Package)
	if err != nil {
		return nil, trace.Wrap(err, "failed to query application")
	}
	installedApp, err := apps.GetApp(*p.Phase.Data.InstalledPackage)
	if err != nil {
		return nil, trace.Wrap(err, "failed to query installed application")
	}
	env, err := operator.GetClusterEnvironmentVariables(operation.ClusterKey())
	if err != nil {
		return nil, trace.Wrap(err)
	}
	clusterConfig, err := operator.GetClusterConfiguration(operation.ClusterKey())
	if err != nil {
		return nil, trace.Wrap(err)
	}
	configBytes, err := clusterconfig.Marshal(clusterConfig)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	existingDocker := checks.DockerConfigFromSchemaValue(installedApp.Manifest.SystemDocker())
	checks.OverrideDockerConfig(&existingDocker, installOperation.InstallExpand.Vars.System.Docker)
	return &updatePhaseInit{
		Backend:                    backend,
		LocalBackend:               localBackend,
		Operator:                   operator,
		Packages:                   packages,
		Users:                      users,
		Client:                     client,
		Cluster:                    *cluster,
		Operation:                  *operation,
		Servers:                    p.Phase.Data.Update.Servers,
		FieldLogger:                logger,
		updateManifest:             app.Manifest,
		installedApp:               *installedApp,
		existingDocker:             existingDocker,
		existingDNS:                p.Plan.DNSConfig,
		existingClusterConfigBytes: configBytes,
		existingClusterConfig:      clusterConfig,
		existingEnviron:            env.GetKeyValues(),
	}, nil
}
func NewUpdatePhaseInit ( p fsm . ExecutorParams , operator ops . Operator , apps app . Applications , backend , localBackend storage . Backend , packages pack . PackageService , users users . Identity , client * kubernetes . Clientset , logger log . FieldLogger , ) ( * updatePhaseInit , error ) { if p . Phase . Data == nil || p . Phase . Data . Package == nil { return nil , trace . BadParameter ( " " , p . Phase ) } if p . Phase . Data . InstalledPackage == nil { return nil , trace . BadParameter ( " " , p . Phase ) } if p . Phase . Data . Update == nil || len ( p . Phase . Data . Update . Servers ) == 0 { return nil , trace . BadParameter ( " " , p . Phase . ID ) } cluster , err := operator . GetLocalSite ( context . TODO ( ) ) if err != nil { return nil , trace . Wrap ( err ) } operation , err := operator . GetSiteOperation ( fsm . OperationKey ( p . Plan ) ) if err != nil { return nil , trace . Wrap ( err ) } installOperation , err := ops . GetCompletedInstallOperation ( cluster . Key ( ) , operator ) if err != nil { return nil , trace . Wrap ( err ) } app , err := apps . GetApp ( * p . Phase . Data . Package ) if err != nil { return nil , trace . Wrap ( err , " " ) } installedApp , err := apps . GetApp ( * p . Phase . Data . InstalledPackage ) if err != nil { return nil , trace . Wrap ( err , " " ) } env , err := operator . GetClusterEnvironmentVariables ( operation . ClusterKey ( ) ) if err != nil { return nil , trace . Wrap ( err ) } clusterConfig , err := operator . GetClusterConfiguration ( operation . ClusterKey ( ) ) if err != nil { return nil , trace . Wrap ( err ) } configBytes , err := clusterconfig . Marshal ( clusterConfig ) if err != nil { return nil , trace . Wrap ( err ) } existingDocker := checks . DockerConfigFromSchemaValue ( installedApp . Manifest . SystemDocker ( ) ) checks . OverrideDockerConfig ( & existingDocker , installOperation . InstallExpand . Vars . System . Docker ) return & updatePhaseInit { Backend : backend , LocalBackend : localBackend , Operator : operator , Packages : packages , Users : users , Client : client , Cluster : * cluster , Operation : * operation , Servers : p . Phase . Data . Update . Servers , FieldLogger : logger , updateManifest : app . Manifest , installedApp : * installedApp , existingDocker : existingDocker , existingDNS : p . Plan . DNSConfig , existingClusterConfigBytes : configBytes , existingClusterConfig : clusterConfig , existingEnviron : env . GetKeyValues ( ) , } , nil }
NewUpdatePhaseInit creates a new update init phase executor
NewUpdatePhaseInit creates a new update init phase executor