Skip to content

Commit

Permalink
remove patches for permissions (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedwigz authored Aug 17, 2022
1 parent c93b77a commit 20f6331
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOSTNAME=github.com
NAMESPACE=port-labs
NAME=port-labs
BINARY=terraform-provider-${NAME}
VERSION=0.1.0
VERSION=0.1.1
OS=$(shell go env GOOS)
ARCH=$(shell go env GOARCH)
OS_ARCH=${OS}_${ARCH}
Expand Down
21 changes: 1 addition & 20 deletions port/resource_port_blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package port

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -238,24 +237,10 @@ func blueprintResourceToBody(d *schema.ResourceData) (*cli.Blueprint, error) {
return b, nil
}

// patchBlueprintDeletePermission is a workaround for a bug where the creator of a blueprint does not have the permission to delete it.
func patchBlueprintDeletePermission(ctx context.Context, client *cli.PortClient, bpID string) error {
return client.CreatePermissions(ctx, client.ClientID, fmt.Sprintf("delete:blueprints:%s", bpID))
}

// patchBlueprintDeletePermission is a workaround for a bug where the creator of a blueprint does not have the permission to delete it.
func patchBlueprintUpdatePermission(ctx context.Context, client *cli.PortClient, bpID string) error {
return client.CreatePermissions(ctx, client.ClientID, fmt.Sprintf("update:blueprints:%s", bpID))
}

func deleteBlueprint(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics
c := m.(*cli.PortClient)
err := patchBlueprintDeletePermission(ctx, c, d.Id())
if err != nil {
return diag.FromErr(err)
}
err = c.DeleteBlueprint(ctx, d.Id())
err := c.DeleteBlueprint(ctx, d.Id())
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -300,10 +285,6 @@ func createBlueprint(ctx context.Context, d *schema.ResourceData, m interface{})
}
var bp *cli.Blueprint
if d.Id() != "" {
err = patchBlueprintUpdatePermission(ctx, c, d.Id())
if err != nil {
return diag.FromErr(err)
}
bp, err = c.UpdateBlueprint(ctx, b, d.Id())
} else {
bp, err = c.CreateBlueprint(ctx, b)
Expand Down

0 comments on commit 20f6331

Please sign in to comment.