Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make configuration versions useful for workspaces #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions configuration_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type configurationVersions struct {
// ConfigurationStatus represents a configuration version status.
type ConfigurationStatus string

//List all available configuration version statuses.
// List all available configuration version statuses.
const (
ConfigurationErrored ConfigurationStatus = "errored"
ConfigurationPending ConfigurationStatus = "pending"
Expand All @@ -43,7 +43,8 @@ type ConfigurationVersion struct {
ID string `jsonapi:"primary,configuration-versions"`
Status ConfigurationStatus `jsonapi:"attr,status"`
// Relations
Workspace *Workspace `jsonapi:"relation,workspace"`
Workspace *Workspace `jsonapi:"relation,workspace"`
VcsRevision *VcsRevision `jsonapi:"relation,vcs-revision,omitempty"`
}

// ConfigurationVersionCreateOptions represents the options for creating a
Expand All @@ -52,6 +53,10 @@ type ConfigurationVersionCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,configuration-versions"`

// Indicates if a run should automatically be queued when the configuration
// has been uploaded.
AutoQueueRuns *bool `jsonapi:"attr,auto-queue-runs,omitempty"`

Workspace *Workspace `jsonapi:"relation,workspace"`
}

Expand Down Expand Up @@ -94,8 +99,13 @@ func (s *configurationVersions) Read(ctx context.Context, cvID string) (*Configu
return nil, errors.New("invalid value for configuration version ID")
}

options := struct {
Include string `url:"include"`
}{
Include: "vcs-revision",
}
u := fmt.Sprintf("configuration-versions/%s", url.QueryEscape(cvID))
req, err := s.client.newRequest("GET", u, nil)
req, err := s.client.newRequest("GET", u, options)
if err != nil {
return nil, err
}
Expand Down
16 changes: 9 additions & 7 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ type Workspace struct {
VarFiles []string `jsonapi:"attr,var-files"`

// Relations
CurrentRun *Run `jsonapi:"relation,current-run"`
Environment *Environment `jsonapi:"relation,environment"`
CreatedBy *User `jsonapi:"relation,created-by"`
VcsProvider *VcsProvider `jsonapi:"relation,vcs-provider"`
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
ModuleVersion *ModuleVersion `jsonapi:"relation,module-version,omitempty"`
Tags []*Tag `jsonapi:"relation,tags"`
CurrentRun *Run `jsonapi:"relation,current-run"`
Environment *Environment `jsonapi:"relation,environment"`
CreatedBy *User `jsonapi:"relation,created-by"`
VcsProvider *VcsProvider `jsonapi:"relation,vcs-provider"`
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
ModuleVersion *ModuleVersion `jsonapi:"relation,module-version,omitempty"`
ConfigurationVersion *ConfigurationVersion `jsonapi:"relation,configuration-version,omitempty"`
LatestConfigurationVersion *ConfigurationVersion `jsonapi:"relation,latest-configuration-version,omitempty"`
Tags []*Tag `jsonapi:"relation,tags"`
}

// Hooks contains the custom hooks field.
Expand Down