Skip to content

Commit

Permalink
Adds Provisional configuration versions
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Aug 3, 2023
1 parent 39aff68 commit ca7d551
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions configuration_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ type ConfigurationVersion struct {
ErrorMessage string `jsonapi:"attr,error-message"`
Source ConfigurationSource `jsonapi:"attr,source"`
Speculative bool `jsonapi:"attr,speculative"`
Provisional bool `jsonapi:"attr,provisional"`
Status ConfigurationStatus `jsonapi:"attr,status"`
StatusTimestamps *CVStatusTimestamps `jsonapi:"attr,status-timestamps"`
UploadURL string `jsonapi:"attr,upload-url"`
Expand Down Expand Up @@ -154,6 +155,10 @@ type ConfigurationVersionCreateOptions struct {

// Optional: When true, this configuration version can only be used for planning.
Speculative *bool `jsonapi:"attr,speculative,omitempty"`

// Optional: When true, does not become the workspace's current configuration until
// a run referencing it is ultimately applied.
Provisional *bool `jsonapi:"attr,provisional,omitempty"`
}

// IngressAttributes include commit information associated with configuration versions sourced from VCS.
Expand Down
27 changes: 27 additions & 0 deletions configuration_version_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ func TestConfigurationVersionsCreate(t *testing.T) {
assert.Nil(t, cv)
assert.EqualError(t, err, ErrInvalidWorkspaceID.Error())
})

t.Run("provisional", func(t *testing.T) {
skipUnlessBeta(t)

cv, err := client.ConfigurationVersions.Create(ctx,
wTest.ID,
ConfigurationVersionCreateOptions{
Provisional: Bool(true),
},
)

require.NoError(t, err)
assert.True(t, cv.Provisional)

ws, err := client.Workspaces.ReadByID(ctx, wTest.ID)
require.NoError(t, err)

// Depends on "with valid options"
require.NotNil(t, ws.CurrentConfigurationVersion)

// Provisional configuration version is not the current one
assert.NotEqual(t, ws.CurrentConfigurationVersion.ID, cv.ID)
})
}

func TestConfigurationVersionsRead(t *testing.T) {
Expand Down Expand Up @@ -372,6 +395,8 @@ func TestConfigurationVersions_Unmarshal(t *testing.T) {
"finished-at": "2020-03-16T23:15:59+00:00",
"started-at": "2019-03-16T23:23:59+00:00",
},
"speculative": true,
"provisional": true,
},
},
}
Expand All @@ -396,4 +421,6 @@ func TestConfigurationVersions_Unmarshal(t *testing.T) {
assert.Equal(t, cv.Status, ConfigurationUploaded)
assert.Equal(t, cv.StatusTimestamps.FinishedAt, finishedParsedTime)
assert.Equal(t, cv.StatusTimestamps.StartedAt, startedParsedTime)
assert.Equal(t, cv.Provisional, true)
assert.Equal(t, cv.Speculative, true)
}

0 comments on commit ca7d551

Please sign in to comment.