Skip to content

Commit

Permalink
Return an error instead of a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
komalali committed Dec 18, 2023
1 parent d5778c7 commit a6135b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

### Bug Fixes

- Fix `Read` for TeamStackPermission so resources are not deleted from state on refresh. Note: TeamStackPermission resources created before v0.17.0 will maintain the existing behavior, but those (re)created with the new version will support `refresh`. [#205](https://github.com/pulumi/pulumi-pulumiservice/pull/205)
- Fix `Read` for TeamStackPermission so resources are not deleted from state on refresh. Note: TeamStackPermission resources created before v0.17.0 will now return an error if attempting a refresh, but those (re)created with the new version will support `refresh`. [#205](https://github.com/pulumi/pulumi-pulumiservice/pull/205)

1 change: 0 additions & 1 deletion provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (k *pulumiserviceProvider) Configure(_ context.Context, req *pulumirpc.Conf
},
&TeamStackPermissionResource{
client: client,
host: k.host,
},
&PulumiServiceTeamAccessTokenResource{
client: client,
Expand Down
13 changes: 3 additions & 10 deletions provider/pkg/provider/team_stack_perm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import (

"github.com/pulumi/pulumi-pulumiservice/provider/pkg/internal/pulumiapi"
"github.com/pulumi/pulumi-pulumiservice/provider/pkg/internal/serde"
"github.com/pulumi/pulumi/pkg/v3/resource/provider"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
)

type TeamStackPermissionResource struct {
client *pulumiapi.Client
host *provider.HostClient
}

type TeamStackPermissionInput struct {
Expand Down Expand Up @@ -59,15 +56,11 @@ func (tp *TeamStackPermissionResource) Read(req *pulumirpc.ReadRequest) (*pulumi
permId, err := splitTeamStackPermissionId(id)
if err != nil {
if strings.Contains(err.Error(), "expected 4 parts") {
// Keep existing behavior for stack permissions created before this change.
// Return an error if attempting to refresh stack permissions created before this change.
// We return a warning and an empty response, which will cause the resource to be deleted on refresh,
// forcing the user to recreate it with the updated version.
err = tp.host.Log(ctx, diag.Warning, resource.URN(req.Urn), fmt.Sprintf("TeamStackPermission resources created before v0.17.0 do not support refresh and will be deleted on refresh, maintaining existing behavior. "+
"Once recreated with >v0.17.0, refresh will be supported."))
if err != nil {
return nil, err
}
return &pulumirpc.ReadResponse{}, nil
return nil, fmt.Errorf("TeamStackPermission resources created before v0.17.0 do not support refresh. " +
"You will need to destroy and recreate this resource with >v0.17.0 to successfully refresh.")
}
return nil, err
}
Expand Down

0 comments on commit a6135b8

Please sign in to comment.