command/push: read name from the config
This commit is contained in:
parent
9062bfda89
commit
5e27bfc040
|
@ -84,8 +84,19 @@ func (c *PushCommand) Run(args []string) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the configuration
|
||||||
|
config := ctx.Module().Config()
|
||||||
|
if config.Atlas == nil || config.Atlas.Name == "" {
|
||||||
|
c.Ui.Error(
|
||||||
|
"The name of this Terraform configuration in Atlas must be\n" +
|
||||||
|
"specified within your configuration or the command-line. To\n" +
|
||||||
|
"set it on the command-line, use the `-name` parameter.")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
name := config.Atlas.Name
|
||||||
|
|
||||||
// Get the variables we might already have
|
// Get the variables we might already have
|
||||||
vars, err := c.client.Get("")
|
vars, err := c.client.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf(
|
c.Ui.Error(fmt.Sprintf(
|
||||||
"Error looking up prior pushed configuration: %s", err))
|
"Error looking up prior pushed configuration: %s", err))
|
||||||
|
@ -127,6 +138,7 @@ func (c *PushCommand) Run(args []string) int {
|
||||||
|
|
||||||
// Upsert!
|
// Upsert!
|
||||||
opts := &pushUpsertOptions{
|
opts := &pushUpsertOptions{
|
||||||
|
Name: name,
|
||||||
Archive: archiveR,
|
Archive: archiveR,
|
||||||
Variables: ctx.Variables(),
|
Variables: ctx.Variables(),
|
||||||
}
|
}
|
||||||
|
@ -171,6 +183,7 @@ type pushClient interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type pushUpsertOptions struct {
|
type pushUpsertOptions struct {
|
||||||
|
Name string
|
||||||
Archive *archive.Archive
|
Archive *archive.Archive
|
||||||
Variables map[string]string
|
Variables map[string]string
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,10 @@ func TestPush_good(t *testing.T) {
|
||||||
if !reflect.DeepEqual(client.UpsertOptions.Variables, variables) {
|
if !reflect.DeepEqual(client.UpsertOptions.Variables, variables) {
|
||||||
t.Fatalf("bad: %#v", client.UpsertOptions)
|
t.Fatalf("bad: %#v", client.UpsertOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if client.UpsertOptions.Name != "foo" {
|
||||||
|
t.Fatalf("bad: %#v", client.UpsertOptions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPush_input(t *testing.T) {
|
func TestPush_input(t *testing.T) {
|
||||||
|
|
|
@ -2,3 +2,7 @@ variable "foo" {}
|
||||||
variable "bar" {}
|
variable "bar" {}
|
||||||
|
|
||||||
resource "test_instance" "foo" {}
|
resource "test_instance" "foo" {}
|
||||||
|
|
||||||
|
atlas {
|
||||||
|
name = "foo"
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
variable "foo" {}
|
variable "foo" {}
|
||||||
|
|
||||||
resource "test_instance" "foo" {}
|
resource "test_instance" "foo" {}
|
||||||
|
|
||||||
|
atlas {
|
||||||
|
name = "foo"
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
resource "aws_instance" "foo" {}
|
resource "aws_instance" "foo" {}
|
||||||
|
|
||||||
|
atlas {
|
||||||
|
name = "foo"
|
||||||
|
}
|
||||||
|
|
|
@ -376,6 +376,11 @@ func (c *Context) Validate() ([]string, []error) {
|
||||||
return walker.ValidationWarnings, rerrs.Errors
|
return walker.ValidationWarnings, rerrs.Errors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Module returns the module tree associated with this context.
|
||||||
|
func (c *Context) Module() *module.Tree {
|
||||||
|
return c.module
|
||||||
|
}
|
||||||
|
|
||||||
// Variables will return the mapping of variables that were defined
|
// Variables will return the mapping of variables that were defined
|
||||||
// for this Context. If Input was called, this mapping may be different
|
// for this Context. If Input was called, this mapping may be different
|
||||||
// than what was given.
|
// than what was given.
|
||||||
|
|
Loading…
Reference in New Issue