Skip to content

Commit

Permalink
Fix exclude username from zone request (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-shmilovich-sysdig authored Aug 9, 2023
1 parent dd7b79c commit 329f101
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
1 change: 0 additions & 1 deletion sysdig/internal/client/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ type PostureZoneRequest struct {
Description string `json:"description"`
PolicyIDs []string `json:"policyIds"`
Scopes []PostureZoneScope `json:"scopes"`
Username string `json:"username"`
}

type PostureZoneResponse struct {
Expand Down
21 changes: 3 additions & 18 deletions sysdig/resource_sysdig_secure_posture_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package sysdig

import (
"context"
"strconv"
"time"

v2 "github.com/draios/terraform-provider-sysdig/sysdig/internal/client/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"strconv"
"time"
)

func resourceSysdigSecurePostureZone() *schema.Resource {
Expand Down Expand Up @@ -105,16 +106,6 @@ func getPostureZoneClient(c SysdigClients) (v2.PostureZoneInterface, error) {
}

func resourceCreateOrUpdatePostureZone(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
commonClient, err := meta.(SysdigClients).commonClientV2()
if err != nil {
return diag.FromErr(err)
}

identityCtx, err := commonClient.GetIdentityContext(ctx)
if err != nil {
return diag.FromErr(err)
}

policiesData := d.Get(SchemaPolicyIDsKey).([]interface{})
policies := make([]string, len(policiesData))
for i, p := range policiesData {
Expand All @@ -134,18 +125,12 @@ func resourceCreateOrUpdatePostureZone(ctx context.Context, d *schema.ResourceDa
}
}

username := identityCtx.Username
if identityCtx.ServiceAccountID != 0 {
username = identityCtx.ServiceAccountName
}

req := &v2.PostureZoneRequest{
ID: d.Id(),
Name: d.Get(SchemaNameKey).(string),
Description: d.Get(SchemaDescriptionKey).(string),
PolicyIDs: policies,
Scopes: scopes,
Username: username,
}

zoneClient, err := getPostureZoneClient(meta.(SysdigClients))
Expand Down

0 comments on commit 329f101

Please sign in to comment.