Skip to content

Commit

Permalink
Merge pull request #26 from Scalr/feature/SCALRCORE-18253
Browse files Browse the repository at this point in the history
SCALRCORE-18253 Scalr provider for before/after hooks
  • Loading branch information
penja committed Jul 7, 2021
2 parents 63f7ac3 + c8ac98a commit 8510e41
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Workspace struct {
TerraformVersion string `jsonapi:"attr,terraform-version"`
VCSRepo *VCSRepo `jsonapi:"attr,vcs-repo"`
WorkingDirectory string `jsonapi:"attr,working-directory"`
Hooks *Hooks `jsonapi:"attr,hooks"`

// Relations
CurrentRun *Run `jsonapi:"relation,current-run"`
Expand All @@ -67,6 +68,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 @@ -145,6 +154,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 @@ -153,7 +166,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 @@ -172,6 +185,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 @@ -291,6 +312,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 8510e41

Please sign in to comment.