Skip to content

Commit

Permalink
SCALRCORE-18479 > Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Vang committed Jul 16, 2021
2 parents 8fa8493 + 8510e41 commit f54c3b4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
1 change: 1 addition & 0 deletions variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type CategoryType string
const (
CategoryEnv CategoryType = "env"
CategoryTerraform CategoryType = "terraform"
CategoryShell CategoryType = "shell"
)

// VariableList represents a list of variables.
Expand Down
16 changes: 8 additions & 8 deletions variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Value: String(""),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Workspace: wsTest,
}

Expand All @@ -37,7 +37,7 @@ func TestVariablesCreate(t *testing.T) {
t.Run("when options is missing value", func(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Workspace: wsTest,
}

Expand All @@ -53,7 +53,7 @@ func TestVariablesCreate(t *testing.T) {
t.Run("when options is missing key", func(t *testing.T) {
options := VariableCreateOptions{
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Workspace: wsTest,
}

Expand All @@ -65,7 +65,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(""),
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Workspace: wsTest,
}

Expand All @@ -88,7 +88,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Environment: wsTest.Environment,
Workspace: wsTest,
}
Expand All @@ -101,7 +101,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Account: account,
Workspace: wsTest,
}
Expand All @@ -114,7 +114,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Account: account,
Environment: wsTest.Environment,
}
Expand All @@ -127,7 +127,7 @@ func TestVariablesCreate(t *testing.T) {
options := VariableCreateOptions{
Key: String(randomVariableKey(t)),
Value: String(randomString(t)),
Category: Category(CategoryEnv),
Category: Category(CategoryShell),
Workspace: wsTest,
}

Expand Down
27 changes: 26 additions & 1 deletion workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Workspace struct {
VCSRepo *VCSRepo `jsonapi:"attr,vcs-repo"`
WorkingDirectory string `jsonapi:"attr,working-directory"`
HasActiveState bool `jsonapi:"attr,has-active-state"`
Hooks *Hooks `jsonapi:"attr,hooks"`

// Relations
CurrentRun *Run `jsonapi:"relation,current-run"`
Expand All @@ -68,6 +69,14 @@ type Workspace struct {
VcsProvider *VcsProviderOptions `jsonapi:"relation,vcs-provider"`
}

// Hooks contains the custom hooks field.
type Hooks struct {
PrePlan string `json:"pre-plan"`
PostPlan string `json:"post-plan"`
PreApply string `json:"pre-apply"`
PostApply string `json:"post-apply"`
}

// VCSRepo contains the configuration of a VCS integration.
type VCSRepo struct {
Branch string `json:"branch"`
Expand Down Expand Up @@ -146,6 +155,10 @@ type WorkspaceCreateOptions struct {
// oauth-token-id and identifier keys below.
VCSRepo *VCSRepoOptions `jsonapi:"attr,vcs-repo,omitempty"`

// Contains configuration for custom hooks,
// which can be triggered before or after plan or apply phases
Hooks *HooksOptions `jsonapi:"attr,hooks,omitempty"`

// A relative path that Terraform will execute within. This defaults to the
// root of your repository and is typically set to a subdirectory matching the
// environment when multiple environments exist within the same repository.
Expand All @@ -154,7 +167,7 @@ type WorkspaceCreateOptions struct {
// Specifies the VcsProvider for workspace vcs-repo. Required if vcs-repo attr passed
VcsProvider *VcsProviderOptions `jsonapi:"relation,vcs-provider,omitempty"`

// Specifies the Environmen for workpace.
// Specifies the Environment for workspace.
Environment *Environment `jsonapi:"relation,environment"`
}

Expand All @@ -173,6 +186,14 @@ type VcsProviderOptions struct {
Url string `jsonapi:"attr,url"`
}

// HooksOptions represents the WorkspaceHooks configuration.
type HooksOptions struct {
PrePlan *string `json:"pre-plan,omitempty"`
PostPlan *string `json:"post-plan,omitempty"`
PreApply *string `json:"pre-apply,omitempty"`
PostApply *string `json:"post-apply,omitempty"`
}

func (o WorkspaceCreateOptions) valid() error {
if !validString(o.Name) {
return errors.New("name is required")
Expand Down Expand Up @@ -292,6 +313,10 @@ type WorkspaceUpdateOptions struct {
// identifier keys.
VCSRepo *VCSRepoOptions `jsonapi:"attr,vcs-repo,omitempty"`

// Contains configuration for custom hooks,
// which can be triggered before or after plan or apply phases
Hooks *HooksOptions `jsonapi:"attr,hooks,omitempty"`

// A relative path that Terraform will execute within. This defaults to the
// root of your repository and is typically set to a subdirectory matching
// the environment when multiple environments exist within the same
Expand Down

0 comments on commit f54c3b4

Please sign in to comment.