Skip to content

Commit

Permalink
support runID on entities (#13)
Browse files Browse the repository at this point in the history
* support runID on entities

* bump

* bump

* oops

* oops
  • Loading branch information
hedwigz authored Sep 18, 2022
1 parent 2178d76 commit 8e769ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 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.4.3
VERSION=0.4.6
OS=$(shell go env GOOS)
ARCH=$(shell go env GOARCH)
OS_ARCH=${OS}_${ARCH}
Expand Down
1 change: 1 addition & 0 deletions docs/resources/entity.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Port entity

- `identifier` (String) The identifier of the entity
- `relations` (Block Set) The other entities that are connected (see [below for nested schema](#nestedblock--relations))
- `run_id` (String) The runID of the action run that created the entity
- `team` (String) The team related to the entity

### Read-Only
Expand Down
3 changes: 2 additions & 1 deletion port/cli/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ func (c *PortClient) ReadEntity(ctx context.Context, id string, blueprint string
return &pb.Entity, nil
}

func (c *PortClient) CreateEntity(ctx context.Context, e *Entity) (*Entity, error) {
func (c *PortClient) CreateEntity(ctx context.Context, e *Entity, runID string) (*Entity, error) {
url := "v1/blueprints/{blueprint}/entities"
pb := &PortBody{}
resp, err := c.Client.R().
SetBody(e).
SetPathParam(("blueprint"), e.Blueprint).
SetQueryParam("upsert", "true").
SetQueryParam("run_id", runID).
SetResult(&pb).
Post(url)
if err != nil {
Expand Down
11 changes: 10 additions & 1 deletion port/resource_port_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func newEntityResource() *schema.Resource {
Description: "The display name of the entity",
Required: true,
},
"run_id": {
Type: schema.TypeString,
Description: "The runID of the action run that created the entity",
Optional: true,
},
"team": {
Type: schema.TypeString,
Description: "The team related to the entity",
Expand Down Expand Up @@ -243,7 +248,11 @@ func createEntity(ctx context.Context, d *schema.ResourceData, m interface{}) di
if err != nil {
return diag.FromErr(err)
}
en, err := c.CreateEntity(ctx, e)
runID := ""
if rid, ok := d.GetOk("run_id"); ok {
runID = rid.(string)
}
en, err := c.CreateEntity(ctx, e, runID)
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit 8e769ea

Please sign in to comment.