Skip to content

Commit 8d75c58

Browse files
committed
Make configuration versions useful for workspaces
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.
1 parent 6aa9155 commit 8d75c58

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

configuration_version.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type configurationVersions struct {
2929
// ConfigurationStatus represents a configuration version status.
3030
type ConfigurationStatus string
3131

32-
//List all available configuration version statuses.
32+
// List all available configuration version statuses.
3333
const (
3434
ConfigurationErrored ConfigurationStatus = "errored"
3535
ConfigurationPending ConfigurationStatus = "pending"
@@ -43,7 +43,8 @@ type ConfigurationVersion struct {
4343
ID string `jsonapi:"primary,configuration-versions"`
4444
Status ConfigurationStatus `jsonapi:"attr,status"`
4545
// Relations
46-
Workspace *Workspace `jsonapi:"relation,workspace"`
46+
Workspace *Workspace `jsonapi:"relation,workspace"`
47+
VcsRevision *VcsRevision `jsonapi:"relation,vcs-revision,omitempty"`
4748
}
4849

4950
// ConfigurationVersionCreateOptions represents the options for creating a
@@ -94,8 +95,13 @@ func (s *configurationVersions) Read(ctx context.Context, cvID string) (*Configu
9495
return nil, errors.New("invalid value for configuration version ID")
9596
}
9697

98+
options := struct {
99+
Include string `url:"include"`
100+
}{
101+
Include: "vcs-revision",
102+
}
97103
u := fmt.Sprintf("configuration-versions/%s", url.QueryEscape(cvID))
98-
req, err := s.client.newRequest("GET", u, nil)
104+
req, err := s.client.newRequest("GET", u, options)
99105
if err != nil {
100106
return nil, err
101107
}

workspace.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ type Workspace struct {
9393
VarFiles []string `jsonapi:"attr,var-files"`
9494

9595
// Relations
96-
CurrentRun *Run `jsonapi:"relation,current-run"`
97-
Environment *Environment `jsonapi:"relation,environment"`
98-
CreatedBy *User `jsonapi:"relation,created-by"`
99-
VcsProvider *VcsProvider `jsonapi:"relation,vcs-provider"`
100-
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
101-
ModuleVersion *ModuleVersion `jsonapi:"relation,module-version,omitempty"`
102-
Tags []*Tag `jsonapi:"relation,tags"`
96+
CurrentRun *Run `jsonapi:"relation,current-run"`
97+
Environment *Environment `jsonapi:"relation,environment"`
98+
CreatedBy *User `jsonapi:"relation,created-by"`
99+
VcsProvider *VcsProvider `jsonapi:"relation,vcs-provider"`
100+
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
101+
ModuleVersion *ModuleVersion `jsonapi:"relation,module-version,omitempty"`
102+
ConfigurationVersion *ConfigurationVersion `jsonapi:"relation,configuration-version,omitempty"`
103+
Tags []*Tag `jsonapi:"relation,tags"`
103104
}
104105

105106
// Hooks contains the custom hooks field.

0 commit comments

Comments
 (0)