Skip to content

Commit

Permalink
Merge pull request #954 from hashicorp/no-code-workspace-output
Browse files Browse the repository at this point in the history
Fix returned workspace for created & upgraded no-code workspaces
  • Loading branch information
brandonc authored Aug 7, 2024
2 parents 08c99d6 + 2b5ca89 commit ffbcfd3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# UNRELEASED
* Adds `AllowMemberTokenManagement` permission to `Team` by @juliannatetreault [#922](https://github.com/hashicorp/go-tfe/pull/922)

## Bug Fixes
* Fix returned workspace for no-code workspace creation & upgrade by @paladin-devops [#954](https://github.com/hashicorp/go-tfe/pull/954)

# v1.61.0

## Enhancements
Expand Down
8 changes: 4 additions & 4 deletions mocks/registry_no_code_module_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions registry_no_code_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ type RegistryNoCodeModules interface {
Delete(ctx context.Context, ID string) error

// CreateWorkspace creates a workspace using a no-code module.
CreateWorkspace(ctx context.Context, noCodeModuleID string, options *RegistryNoCodeModuleCreateWorkspaceOptions) (*RegistryNoCodeModuleWorkspace, error)
CreateWorkspace(ctx context.Context, noCodeModuleID string, options *RegistryNoCodeModuleCreateWorkspaceOptions) (*Workspace, error)

// UpgradeWorkspace initiates an upgrade of an existing no-code module workspace.
UpgradeWorkspace(ctx context.Context, noCodeModuleID string, workspaceID string, options *RegistryNoCodeModuleUpgradeWorkspaceOptions) (*RegistryNoCodeModuleWorkspace, error)
UpgradeWorkspace(ctx context.Context, noCodeModuleID string, workspaceID string, options *RegistryNoCodeModuleUpgradeWorkspaceOptions) (*Workspace, error)
}

type RegistryNoCodeModuleCreateWorkspaceOptions struct {
Expand Down Expand Up @@ -85,10 +85,6 @@ type RegistryNoCodeModuleUpgradeWorkspaceOptions struct {
Variables []*Variable `jsonapi:"relation,vars,omitempty"`
}

type RegistryNoCodeModuleWorkspace struct {
Workspace
}

// registryNoCodeModules implements RegistryNoCodeModules.
type registryNoCodeModules struct {
client *Client
Expand Down Expand Up @@ -282,7 +278,7 @@ func (r *registryNoCodeModules) CreateWorkspace(
ctx context.Context,
noCodeModuleID string,
options *RegistryNoCodeModuleCreateWorkspaceOptions,
) (*RegistryNoCodeModuleWorkspace, error) {
) (*Workspace, error) {
if err := options.valid(); err != nil {
return nil, err
}
Expand All @@ -293,7 +289,7 @@ func (r *registryNoCodeModules) CreateWorkspace(
return nil, err
}

w := &RegistryNoCodeModuleWorkspace{}
w := &Workspace{}
err = req.Do(ctx, w)
if err != nil {
return nil, err
Expand All @@ -308,7 +304,7 @@ func (r *registryNoCodeModules) UpgradeWorkspace(
noCodeModuleID string,
workspaceID string,
options *RegistryNoCodeModuleUpgradeWorkspaceOptions,
) (*RegistryNoCodeModuleWorkspace, error) {
) (*Workspace, error) {
if err := options.valid(); err != nil {
return nil, err
}
Expand All @@ -322,7 +318,7 @@ func (r *registryNoCodeModules) UpgradeWorkspace(
return nil, err
}

w := &RegistryNoCodeModuleWorkspace{}
w := &Workspace{}
err = req.Do(ctx, w)
if err != nil {
return nil, err
Expand Down
9 changes: 4 additions & 5 deletions registry_no_code_module_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func TestRegistryNoCodeModulesCreateWorkspace(t *testing.T) {
wn := fmt.Sprintf("foo-%s", randomString(t))
sn := "my-app"
su := "http://my-app.com"
_, err = client.RegistryNoCodeModules.CreateWorkspace(
w, err := client.RegistryNoCodeModules.CreateWorkspace(
ctx,
ncm.ID,
&RegistryNoCodeModuleCreateWorkspaceOptions{
Expand All @@ -366,9 +366,6 @@ func TestRegistryNoCodeModulesCreateWorkspace(t *testing.T) {
},
)
r.NoError(err)

w, err := client.Workspaces.Read(ctx, org.Name, wn)
r.NoError(err)
r.Equal(wn, w.Name)
r.Equal(sn, w.SourceName)
r.Equal(su, w.SourceURL)
Expand Down Expand Up @@ -473,13 +470,15 @@ func TestRegistryNoCodeModuleWorkspaceUpgrade(t *testing.T) {
r.NotNil(uncm)

t.Run("test upgrading a workspace via a no-code module", func(t *testing.T) {
_, err = client.RegistryNoCodeModules.UpgradeWorkspace(
ws, err := client.RegistryNoCodeModules.UpgradeWorkspace(
ctx,
ncm.ID,
w.ID,
&RegistryNoCodeModuleUpgradeWorkspaceOptions{},
)
r.NoError(err)
r.NotNil(ws)
r.Equal(w.ID, ws.ID)
})

t.Run("fail to upgrade workspace with invalid no-code module", func(t *testing.T) {
Expand Down

0 comments on commit ffbcfd3

Please sign in to comment.