diff --git a/cmd/stack.go b/cmd/stack.go index e10b9ce24..907c2ca8d 100644 --- a/cmd/stack.go +++ b/cmd/stack.go @@ -67,9 +67,6 @@ func newStackCmd() *cobra.Command { if isCloud { if cs, ok := s.(cloud.Stack); ok { fmt.Printf(" Owner: %s\n", cs.OrgName()) - if !cs.RunLocally() { - fmt.Printf(" PPC: %s\n", cs.CloudName()) - } } } diff --git a/cmd/stack_ls.go b/cmd/stack_ls.go index 20be9b7d8..1cbec2ba7 100644 --- a/cmd/stack_ls.go +++ b/cmd/stack_ls.go @@ -82,7 +82,6 @@ func newStackLsCmd() *cobra.Command { if err != nil { return err } - showPPCColumn, maxPPC := hasAnyPPCStacks(bs) _, showURLColumn := b.(cloud.Backend) for _, stack := range bs { @@ -115,10 +114,6 @@ func newStackLsCmd() *cobra.Command { formatDirective := "%-" + strconv.Itoa(maxname) + "s %-24s %-18s" headers := []interface{}{"NAME", "LAST UPDATE", "RESOURCE COUNT"} - if showPPCColumn { - formatDirective += " %-" + strconv.Itoa(maxPPC) + "s" - headers = append(headers, "PPC") - } if showURLColumn { formatDirective += " %s" headers = append(headers, "URL") @@ -149,16 +144,6 @@ func newStackLsCmd() *cobra.Command { } 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 { var url string if cs, ok := stack.(cloud.Stack); ok { @@ -183,17 +168,3 @@ func newStackLsCmd() *cobra.Command { 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 -} diff --git a/pkg/backend/cloud/backend.go b/pkg/backend/cloud/backend.go index e1f7743ad..59c84d6af 100644 --- a/pkg/backend/cloud/backend.go +++ b/pkg/backend/cloud/backend.go @@ -525,11 +525,7 @@ func (b *cloudBackend) CreateStack(ctx context.Context, stackRef backend.StackRe } stack := newStack(apistack, b) - fmt.Printf("Created stack '%s'", stack.Name()) - if !stack.RunLocally() { - fmt.Printf(" in PPC %s", stack.CloudName()) - } - fmt.Println(".") + fmt.Printf("Created stack '%s'.\n", stack.Name()) return stack, nil } @@ -716,10 +712,8 @@ func confirmBeforeUpdating(updateKind client.UpdateKind, stack backend.Stack, choices := []string{string(yes), string(no)} - // if this is a managed stack, then we can get the details for the operation, as we will - // have been able to collect the details while the preview ran. For ppc stacks, we don't - // have that information since all the PPC does is forward stdout events to us. - if stack.(Stack).RunLocally() && !opts.SkipPreview { + // For non-previews, we can also offer a detailed summary. + if !opts.SkipPreview { choices = append(choices, string(details)) } @@ -766,12 +760,6 @@ func (b *cloudBackend) PreviewThenPromptThenExecute( 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. changes, err := b.PreviewThenPrompt(ctx, updateKind, stack, pkg, root, m, opts, scopes) if err != nil || updateKind == client.UpdateKindPreview { @@ -888,7 +876,7 @@ func (b *cloudBackend) updateStack( var version int var token string 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) // 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 } - // If we are targeting a stack that uses local operations, run the appropriate engine action locally. - if stack.(Stack).RunLocally() { - return b.runEngineAction( - 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 + return b.runEngineAction( + ctx, action, stack.Name(), pkg, root, opts, update, token, callerEventsOpt, + dryRun, persist, scopes) } // 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") } - // If we're dealing with a stack that runs its operations locally, get the stack's target and fetch the logs - // directly - if stack.(Stack).RunLocally() { - target, targetErr := b.getTarget(ctx, stackRef) - if targetErr != nil { - return nil, targetErr - } - return local.GetLogsForTarget(target, logQuery) + target, targetErr := b.getTarget(ctx, stackRef) + if targetErr != nil { + return nil, targetErr } - - // 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) + return local.GetLogsForTarget(target, logQuery) } func (b *cloudBackend) ExportDeployment(ctx context.Context, diff --git a/pkg/backend/cloud/stack.go b/pkg/backend/cloud/stack.go index 2aeb2b3cc..dbbb10262 100644 --- a/pkg/backend/cloud/stack.go +++ b/pkg/backend/cloud/stack.go @@ -34,20 +34,17 @@ type Stack interface { backend.Stack CloudURL() string // the URL to the cloud containing 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 } // cloudStack is a cloud stack descriptor. type cloudStack struct { - name backend.StackReference // the stack's name. - cloudURL string // the URL to the cloud containing 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. - 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. + name backend.StackReference // the stack's name. + cloudURL string // the URL to the cloud containing this stack. + orgName string // the organization that owns this stack. + config config.Map // the stack's config bag. + 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. } type cloudBackendReference struct { @@ -81,26 +78,19 @@ func newStack(apistack apitype.Stack, b *cloudBackend) Stack { name: apistack.StackName, b: b, }, - cloudURL: b.CloudURL(), - orgName: apistack.OrgName, - cloudName: apistack.CloudName, - 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. - b: b, + cloudURL: b.CloudURL(), + orgName: apistack.OrgName, + 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. + 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) Config() config.Map { return s.config } func (s *cloudStack) Backend() backend.Backend { return s.b } func (s *cloudStack) CloudURL() string { return s.cloudURL } 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) { if s.snapshot != nil {