Skip to content

Commit 259bf34

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 8d8d36e commit 259bf34

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
@@ -92,13 +92,14 @@ type Workspace struct {
9292
VarFiles []string `jsonapi:"attr,var-files"`
9393

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

104105
// Hooks contains the custom hooks field.

0 commit comments

Comments
 (0)