Remove PPC-specific codepaths (#1741)
This commit is contained in:
parent
e998c7554d
commit
2d93bb8693
4 changed files with 22 additions and 100 deletions
|
@ -67,9 +67,6 @@ func newStackCmd() *cobra.Command {
|
||||||
if isCloud {
|
if isCloud {
|
||||||
if cs, ok := s.(cloud.Stack); ok {
|
if cs, ok := s.(cloud.Stack); ok {
|
||||||
fmt.Printf(" Owner: %s\n", cs.OrgName())
|
fmt.Printf(" Owner: %s\n", cs.OrgName())
|
||||||
if !cs.RunLocally() {
|
|
||||||
fmt.Printf(" PPC: %s\n", cs.CloudName())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,6 @@ func newStackLsCmd() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
showPPCColumn, maxPPC := hasAnyPPCStacks(bs)
|
|
||||||
_, showURLColumn := b.(cloud.Backend)
|
_, showURLColumn := b.(cloud.Backend)
|
||||||
|
|
||||||
for _, stack := range bs {
|
for _, stack := range bs {
|
||||||
|
@ -115,10 +114,6 @@ func newStackLsCmd() *cobra.Command {
|
||||||
formatDirective := "%-" + strconv.Itoa(maxname) + "s %-24s %-18s"
|
formatDirective := "%-" + strconv.Itoa(maxname) + "s %-24s %-18s"
|
||||||
headers := []interface{}{"NAME", "LAST UPDATE", "RESOURCE COUNT"}
|
headers := []interface{}{"NAME", "LAST UPDATE", "RESOURCE COUNT"}
|
||||||
|
|
||||||
if showPPCColumn {
|
|
||||||
formatDirective += " %-" + strconv.Itoa(maxPPC) + "s"
|
|
||||||
headers = append(headers, "PPC")
|
|
||||||
}
|
|
||||||
if showURLColumn {
|
if showURLColumn {
|
||||||
formatDirective += " %s"
|
formatDirective += " %s"
|
||||||
headers = append(headers, "URL")
|
headers = append(headers, "URL")
|
||||||
|
@ -149,16 +144,6 @@ func newStackLsCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
values := []interface{}{name, lastUpdate, resourceCount}
|
values := []interface{}{name, lastUpdate, resourceCount}
|
||||||
if showPPCColumn {
|
|
||||||
// Print out the PPC name.
|
|
||||||
var cloudInfo string
|
|
||||||
if cs, ok := stack.(cloud.Stack); ok && !cs.RunLocally() {
|
|
||||||
cloudInfo = cs.CloudName()
|
|
||||||
} else {
|
|
||||||
cloudInfo = none
|
|
||||||
}
|
|
||||||
values = append(values, cloudInfo)
|
|
||||||
}
|
|
||||||
if showURLColumn {
|
if showURLColumn {
|
||||||
var url string
|
var url string
|
||||||
if cs, ok := stack.(cloud.Stack); ok {
|
if cs, ok := stack.(cloud.Stack); ok {
|
||||||
|
@ -183,17 +168,3 @@ func newStackLsCmd() *cobra.Command {
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasAnyPPCStacks(stacks []backend.Stack) (bool, int) {
|
|
||||||
res, maxLen := false, 0
|
|
||||||
for _, s := range stacks {
|
|
||||||
if cs, ok := s.(cloud.Stack); ok {
|
|
||||||
if !cs.RunLocally() {
|
|
||||||
res = true
|
|
||||||
maxLen = len(cs.CloudName())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, maxLen
|
|
||||||
}
|
|
||||||
|
|
|
@ -525,11 +525,7 @@ func (b *cloudBackend) CreateStack(ctx context.Context, stackRef backend.StackRe
|
||||||
}
|
}
|
||||||
|
|
||||||
stack := newStack(apistack, b)
|
stack := newStack(apistack, b)
|
||||||
fmt.Printf("Created stack '%s'", stack.Name())
|
fmt.Printf("Created stack '%s'.\n", stack.Name())
|
||||||
if !stack.RunLocally() {
|
|
||||||
fmt.Printf(" in PPC %s", stack.CloudName())
|
|
||||||
}
|
|
||||||
fmt.Println(".")
|
|
||||||
|
|
||||||
return stack, nil
|
return stack, nil
|
||||||
}
|
}
|
||||||
|
@ -716,10 +712,8 @@ func confirmBeforeUpdating(updateKind client.UpdateKind, stack backend.Stack,
|
||||||
|
|
||||||
choices := []string{string(yes), string(no)}
|
choices := []string{string(yes), string(no)}
|
||||||
|
|
||||||
// if this is a managed stack, then we can get the details for the operation, as we will
|
// For non-previews, we can also offer a detailed summary.
|
||||||
// have been able to collect the details while the preview ran. For ppc stacks, we don't
|
if !opts.SkipPreview {
|
||||||
// have that information since all the PPC does is forward stdout events to us.
|
|
||||||
if stack.(Stack).RunLocally() && !opts.SkipPreview {
|
|
||||||
choices = append(choices, string(details))
|
choices = append(choices, string(details))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,12 +760,6 @@ func (b *cloudBackend) PreviewThenPromptThenExecute(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !stack.(Stack).RunLocally() &&
|
|
||||||
(updateKind == client.UpdateKindDestroy || updateKind == client.UpdateKindRefresh) {
|
|
||||||
// The service does not support previews for PPC stacks, other than for updates. So skip the preview.
|
|
||||||
opts.SkipPreview = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preview the operation to the user and ask them if they want to proceed.
|
// Preview the operation to the user and ask them if they want to proceed.
|
||||||
changes, err := b.PreviewThenPrompt(ctx, updateKind, stack, pkg, root, m, opts, scopes)
|
changes, err := b.PreviewThenPrompt(ctx, updateKind, stack, pkg, root, m, opts, scopes)
|
||||||
if err != nil || updateKind == client.UpdateKindPreview {
|
if err != nil || updateKind == client.UpdateKindPreview {
|
||||||
|
@ -888,7 +876,7 @@ func (b *cloudBackend) updateStack(
|
||||||
var version int
|
var version int
|
||||||
var token string
|
var token string
|
||||||
var err error
|
var err error
|
||||||
if !stack.(Stack).RunLocally() || persist {
|
if persist {
|
||||||
update, version, token, err = b.createAndStartUpdate(ctx, action, stack.Name(), pkg, root, m, opts, dryRun)
|
update, version, token, err = b.createAndStartUpdate(ctx, action, stack.Name(), pkg, root, m, opts, dryRun)
|
||||||
|
|
||||||
// Print a URL at the end of the update pointing to the Pulumi Service.
|
// Print a URL at the end of the update pointing to the Pulumi Service.
|
||||||
|
@ -911,22 +899,9 @@ func (b *cloudBackend) updateStack(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are targeting a stack that uses local operations, run the appropriate engine action locally.
|
return b.runEngineAction(
|
||||||
if stack.(Stack).RunLocally() {
|
ctx, action, stack.Name(), pkg, root, opts, update, token, callerEventsOpt,
|
||||||
return b.runEngineAction(
|
dryRun, persist, scopes)
|
||||||
ctx, action, stack.Name(), pkg, root, opts, update, token, callerEventsOpt,
|
|
||||||
dryRun, persist, scopes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, wait for the update to complete while rendering its events to stdout/stderr.
|
|
||||||
status, err := b.waitForUpdate(ctx, actionLabel, update, opts.Display)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "waiting for %s", action)
|
|
||||||
} else if status != apitype.StatusSucceeded {
|
|
||||||
return nil, errors.Errorf("%s unsuccessful: status %v", action, status)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// uploadArchive archives the current Pulumi program and uploads it to a signed URL. "current"
|
// uploadArchive archives the current Pulumi program and uploads it to a signed URL. "current"
|
||||||
|
@ -1144,22 +1119,11 @@ func (b *cloudBackend) GetLogs(ctx context.Context, stackRef backend.StackRefere
|
||||||
return nil, errors.New("stack not found")
|
return nil, errors.New("stack not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're dealing with a stack that runs its operations locally, get the stack's target and fetch the logs
|
target, targetErr := b.getTarget(ctx, stackRef)
|
||||||
// directly
|
if targetErr != nil {
|
||||||
if stack.(Stack).RunLocally() {
|
return nil, targetErr
|
||||||
target, targetErr := b.getTarget(ctx, stackRef)
|
|
||||||
if targetErr != nil {
|
|
||||||
return nil, targetErr
|
|
||||||
}
|
|
||||||
return local.GetLogsForTarget(target, logQuery)
|
|
||||||
}
|
}
|
||||||
|
return local.GetLogsForTarget(target, logQuery)
|
||||||
// Otherwise, fetch the logs from the service.
|
|
||||||
stackID, err := b.getCloudStackIdentifier(stackRef)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return b.client.GetStackLogs(ctx, stackID, logQuery)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *cloudBackend) ExportDeployment(ctx context.Context,
|
func (b *cloudBackend) ExportDeployment(ctx context.Context,
|
||||||
|
|
|
@ -34,20 +34,17 @@ type Stack interface {
|
||||||
backend.Stack
|
backend.Stack
|
||||||
CloudURL() string // the URL to the cloud containing this stack.
|
CloudURL() string // the URL to the cloud containing this stack.
|
||||||
OrgName() string // the organization that owns this stack.
|
OrgName() string // the organization that owns this stack.
|
||||||
CloudName() string // the PPC in which this stack is running.
|
|
||||||
RunLocally() bool // true if previews/updates/destroys targeting this stack run locally.
|
|
||||||
ConsoleURL() (string, error) // the URL to view the stack's information on Pulumi.com
|
ConsoleURL() (string, error) // the URL to view the stack's information on Pulumi.com
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloudStack is a cloud stack descriptor.
|
// cloudStack is a cloud stack descriptor.
|
||||||
type cloudStack struct {
|
type cloudStack struct {
|
||||||
name backend.StackReference // the stack's name.
|
name backend.StackReference // the stack's name.
|
||||||
cloudURL string // the URL to the cloud containing this stack.
|
cloudURL string // the URL to the cloud containing this stack.
|
||||||
orgName string // the organization that owns this stack.
|
orgName string // the organization that owns this stack.
|
||||||
cloudName string // the PPC in which this stack is running.
|
config config.Map // the stack's config bag.
|
||||||
config config.Map // the stack's config bag.
|
snapshot **deploy.Snapshot // a snapshot representing the latest deployment state (allocated on first use)
|
||||||
snapshot **deploy.Snapshot // a snapshot representing the latest deployment state (allocated on first use)
|
b *cloudBackend // a pointer to the backend this stack belongs to.
|
||||||
b *cloudBackend // a pointer to the backend this stack belongs to.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type cloudBackendReference struct {
|
type cloudBackendReference struct {
|
||||||
|
@ -81,26 +78,19 @@ func newStack(apistack apitype.Stack, b *cloudBackend) Stack {
|
||||||
name: apistack.StackName,
|
name: apistack.StackName,
|
||||||
b: b,
|
b: b,
|
||||||
},
|
},
|
||||||
cloudURL: b.CloudURL(),
|
cloudURL: b.CloudURL(),
|
||||||
orgName: apistack.OrgName,
|
orgName: apistack.OrgName,
|
||||||
cloudName: apistack.CloudName,
|
config: nil, // TODO[pulumi/pulumi-service#249]: add the config variables.
|
||||||
config: nil, // TODO[pulumi/pulumi-service#249]: add the config variables.
|
snapshot: nil, // We explicitly allocate the snapshot on first use, since it is expensive to compute.
|
||||||
snapshot: nil, // We explicitly allocate the snapshot on first use, since it is expensive to compute.
|
b: b,
|
||||||
b: b,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// managedCloudName is the name used to refer to the cloud in the Pulumi Service that owns all of an organization's
|
|
||||||
// managed stacks. All engine operations for a managed stack--previews, updates, destroys, etc.--run locally.
|
|
||||||
const managedCloudName = "pulumi"
|
|
||||||
|
|
||||||
func (s *cloudStack) Name() backend.StackReference { return s.name }
|
func (s *cloudStack) Name() backend.StackReference { return s.name }
|
||||||
func (s *cloudStack) Config() config.Map { return s.config }
|
func (s *cloudStack) Config() config.Map { return s.config }
|
||||||
func (s *cloudStack) Backend() backend.Backend { return s.b }
|
func (s *cloudStack) Backend() backend.Backend { return s.b }
|
||||||
func (s *cloudStack) CloudURL() string { return s.cloudURL }
|
func (s *cloudStack) CloudURL() string { return s.cloudURL }
|
||||||
func (s *cloudStack) OrgName() string { return s.orgName }
|
func (s *cloudStack) OrgName() string { return s.orgName }
|
||||||
func (s *cloudStack) CloudName() string { return s.cloudName }
|
|
||||||
func (s *cloudStack) RunLocally() bool { return s.cloudName == managedCloudName }
|
|
||||||
|
|
||||||
func (s *cloudStack) Snapshot(ctx context.Context) (*deploy.Snapshot, error) {
|
func (s *cloudStack) Snapshot(ctx context.Context) (*deploy.Snapshot, error) {
|
||||||
if s.snapshot != nil {
|
if s.snapshot != nil {
|
||||||
|
|
Loading…
Reference in a new issue