Skip to content

Commit

Permalink
Make configuration versions useful for workspaces
Browse files Browse the repository at this point in the history
This adds the current configuration version ID to the workspace model
and also includes the current VCS revision information on a given
configuration version. This makes the configuration version information
useful for workspaces that are VCS-backed.
  • Loading branch information
impl committed Apr 4, 2023
1 parent 8d8d36e commit 259bf34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
12 changes: 9 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 Down Expand Up @@ -94,8 +95,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
15 changes: 8 additions & 7 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ 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"`
Tags []*Tag `jsonapi:"relation,tags"`
}

// Hooks contains the custom hooks field.
Expand Down

0 comments on commit 259bf34

Please sign in to comment.