Skip to content

Commit

Permalink
Add config block to bundle steps (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisghill authored Oct 31, 2024
1 parent c832621 commit 78f3b18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions pkg/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const (
)

type Step struct {
Path string `json:"path" yaml:"path"`
Provisioner string `json:"provisioner" yaml:"provisioner"`
SkipOnDelete bool `json:"skip_on_delete,omitempty" yaml:"skip_on_delete,omitempty"`
Path string `json:"path" yaml:"path"`
Provisioner string `json:"provisioner" yaml:"provisioner"`
SkipOnDelete bool `json:"skip_on_delete,omitempty" yaml:"skip_on_delete,omitempty"`
Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"`
}

type Bundle struct {
Expand All @@ -39,13 +40,11 @@ type Bundle struct {
Steps []Step `json:"steps" yaml:"steps"`
Artifacts map[string]interface{} `json:"artifacts" yaml:"artifacts"`
Params map[string]interface{} `json:"params" yaml:"params"`
Connections Connections `json:"connections" yaml:"connections"`
Connections map[string]interface{} `json:"connections" yaml:"connections"`
UI map[string]interface{} `json:"ui" yaml:"ui"`
AppSpec *AppSpec `json:"app,omitempty" yaml:"app,omitempty"`
}

type Connections = map[string]any

type AppSpec struct {
Envs map[string]string `json:"envs" yaml:"envs"`
Policies []string `json:"policies" yaml:"policies"`
Expand Down
10 changes: 7 additions & 3 deletions pkg/commands/publish/publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ func TestPublish(t *testing.T) {
Access: "public",
Steps: []bundle.Step{
{
Path: "deploy",
Provisioner: "opentofu",
Path: "deploy",
Provisioner: "opentofu",
SkipOnDelete: true,
Config: map[string]interface{}{
"foo": "bar",
},
},
},
Artifacts: map[string]interface{}{
Expand Down Expand Up @@ -197,7 +201,7 @@ func TestPublish(t *testing.T) {
},
},
},
wantBody: `{"name":"the-bundle","description":"something","type":"bundle","source_url":"github.com/some-repo","access":"public","artifacts_schema":{"artifacts":"foo"},"connections_schema":{"connections":"bar"},"params_schema":{"params":{"hello":"world"}},"ui_schema":{"ui":"baz"},"operator_guide":"IyBTb21lIE1hcmtkb3duIQo=","app":{"envs":{"LOG_LEVEL":"warn"},"policies":[".connections.vpc.data.infrastructure.arn"],"secrets":{"STRIPE_KEY":{"description":"Access key for live stripe accounts","json":false,"required":true,"title":"A secret"}}},"spec":{"access":"public","app":{"envs":{"LOG_LEVEL":"warn"},"policies":[".connections.vpc.data.infrastructure.arn"],"secrets":{"STRIPE_KEY":{"description":"Access key for live stripe accounts","json":false,"required":true,"title":"A secret"}}},"artifacts":{"artifacts":"foo"},"connections":{"connections":"bar"},"description":"something","name":"the-bundle","params":{"params":{"hello":"world"}},"schema":"","source_url":"github.com/some-repo","steps":[{"path":"deploy","provisioner":"opentofu"}],"type":"bundle","ui":{"ui":"baz"}}}`,
wantBody: `{"name":"the-bundle","description":"something","type":"bundle","source_url":"github.com/some-repo","access":"public","artifacts_schema":{"artifacts":"foo"},"connections_schema":{"connections":"bar"},"params_schema":{"params":{"hello":"world"}},"ui_schema":{"ui":"baz"},"operator_guide":"IyBTb21lIE1hcmtkb3duIQo=","app":{"envs":{"LOG_LEVEL":"warn"},"policies":[".connections.vpc.data.infrastructure.arn"],"secrets":{"STRIPE_KEY":{"description":"Access key for live stripe accounts","json":false,"required":true,"title":"A secret"}}},"spec":{"access":"public","app":{"envs":{"LOG_LEVEL":"warn"},"policies":[".connections.vpc.data.infrastructure.arn"],"secrets":{"STRIPE_KEY":{"description":"Access key for live stripe accounts","json":false,"required":true,"title":"A secret"}}},"artifacts":{"artifacts":"foo"},"connections":{"connections":"bar"},"description":"something","name":"the-bundle","params":{"params":{"hello":"world"}},"schema":"","source_url":"github.com/some-repo","steps":[{"config":{"foo":"bar"},"path":"deploy","provisioner":"opentofu","skip_on_delete":true}],"type":"bundle","ui":{"ui":"baz"}}}`,
},
}

Expand Down

0 comments on commit 78f3b18

Please sign in to comment.