2018-03-21 19:43:21 +00:00
|
|
|
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
|
|
|
|
package local
|
|
|
|
|
|
|
|
import (
|
2018-02-28 18:02:02 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/apitype"
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/backend"
|
|
|
|
"github.com/pulumi/pulumi/pkg/engine"
|
|
|
|
"github.com/pulumi/pulumi/pkg/operations"
|
|
|
|
"github.com/pulumi/pulumi/pkg/resource/config"
|
|
|
|
"github.com/pulumi/pulumi/pkg/resource/deploy"
|
|
|
|
"github.com/pulumi/pulumi/pkg/tokens"
|
2018-02-14 21:56:16 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/workspace"
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Stack is a local stack. This simply adds some local-specific properties atop the standard backend stack interface.
|
|
|
|
type Stack interface {
|
|
|
|
backend.Stack
|
|
|
|
Path() string // a path to the stack's checkpoint file on disk.
|
|
|
|
}
|
|
|
|
|
|
|
|
// localStack is a local stack descriptor.
|
|
|
|
type localStack struct {
|
|
|
|
name tokens.QName // the stack's name.
|
|
|
|
path string // a path to the stack's checkpoint file on disk.
|
|
|
|
config config.Map // the stack's config bag.
|
|
|
|
snapshot *deploy.Snapshot // a snapshot representing the latest deployment state.
|
|
|
|
b *localBackend // a pointer to the backend this stack belongs to.
|
|
|
|
}
|
|
|
|
|
|
|
|
func newStack(name tokens.QName, path string, config config.Map,
|
|
|
|
snapshot *deploy.Snapshot, b *localBackend) Stack {
|
|
|
|
return &localStack{
|
|
|
|
name: name,
|
|
|
|
path: path,
|
|
|
|
config: config,
|
|
|
|
snapshot: snapshot,
|
|
|
|
b: b,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *localStack) Name() tokens.QName { return s.name }
|
|
|
|
func (s *localStack) Config() config.Map { return s.config }
|
|
|
|
func (s *localStack) Snapshot() *deploy.Snapshot { return s.snapshot }
|
|
|
|
func (s *localStack) Backend() backend.Backend { return s.b }
|
|
|
|
func (s *localStack) Path() string { return s.path }
|
|
|
|
|
|
|
|
func (s *localStack) Remove(force bool) (bool, error) {
|
|
|
|
return backend.RemoveStack(s, force)
|
|
|
|
}
|
|
|
|
|
2018-02-14 21:56:16 +00:00
|
|
|
func (s *localStack) Preview(proj *workspace.Project, root string,
|
2018-04-10 19:03:11 +00:00
|
|
|
opts engine.UpdateOptions, displayOpts backend.DisplayOptions) error {
|
|
|
|
return backend.PreviewStack(s, proj, root, opts, displayOpts)
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 21:56:16 +00:00
|
|
|
func (s *localStack) Update(proj *workspace.Project, root string,
|
2018-04-10 19:03:11 +00:00
|
|
|
m backend.UpdateMetadata, opts engine.UpdateOptions, displayOpts backend.DisplayOptions) error {
|
|
|
|
return backend.UpdateStack(s, proj, root, m, opts, displayOpts)
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 21:56:16 +00:00
|
|
|
func (s *localStack) Destroy(proj *workspace.Project, root string,
|
2018-04-10 19:03:11 +00:00
|
|
|
m backend.UpdateMetadata, opts engine.UpdateOptions, displayOpts backend.DisplayOptions) error {
|
|
|
|
return backend.DestroyStack(s, proj, root, m, opts, displayOpts)
|
Make some updates based on CR feedback
This change implements some feedback from @ellismg.
* Make backend.Stack an interface and let backends implement it,
enabling dynamic type testing/casting to access information
specific to that backend. For instance, the cloud.Stack conveys
the cloud URL, org name, and PPC name, for each stack.
* Similarly expose specialized backend.Backend interfaces,
local.Backend and cloud.Backend, to convey specific information.
* Redo a bunch of the commands in terms of these.
* Keeping with this theme, turn the CreateStack options into an
opaque interface{}, and let the specific backends expose their
own structures with their own settings (like PPC name in cloud).
* Show both the org and PPC names in the cloud column printed in
the stack ls command, in addition to the Pulumi Cloud URL.
Unrelated, but useful:
* Special case the 401 HTTP response and make a friendly error,
to tell the developer they must use `pulumi login`. This is
better than tossing raw "401: Unauthorized" errors in their face.
* Change the "Updating stack '..' in the Pulumi Cloud" message to
use the correct action verb ("Previewing", "Destroying", etc).
2017-12-03 15:51:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *localStack) GetLogs(query operations.LogQuery) ([]operations.LogEntry, error) {
|
|
|
|
return backend.GetStackLogs(s, query)
|
|
|
|
}
|
2018-01-05 20:46:13 +00:00
|
|
|
|
2018-03-03 20:12:54 +00:00
|
|
|
func (s *localStack) ExportDeployment() (*apitype.UntypedDeployment, error) {
|
2018-01-05 20:46:13 +00:00
|
|
|
return backend.ExportStackDeployment(s)
|
|
|
|
}
|
|
|
|
|
2018-03-03 20:12:54 +00:00
|
|
|
func (s *localStack) ImportDeployment(deployment *apitype.UntypedDeployment) error {
|
2018-01-05 20:46:13 +00:00
|
|
|
return backend.ImportStackDeployment(s, deployment)
|
|
|
|
}
|