From 88af186ccd28cfcddaff5111e753555ca52245a5 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Thu, 30 Jan 2025 07:50:57 -0600 Subject: [PATCH 1/2] Fixes needed for Terraform --- input.go | 18 +++++++++--------- tags.go | 13 ++++++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/input.go b/input.go index 5583ac49..83ff8297 100644 --- a/input.go +++ b/input.go @@ -1097,8 +1097,8 @@ type TagAssignInput struct { // TagCreateInput Specifies the input fields used to create a tag type TagCreateInput struct { - Alias *Nullable[string] `json:"alias,omitempty" yaml:"alias,omitempty" example:"example_value"` // The alias of the resource that this tag will be added to (Optional) - Id *Nullable[ID] `json:"id,omitempty" yaml:"id,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the resource that this tag will be added to (Optional) + Alias *string `json:"alias,omitempty" yaml:"alias,omitempty" example:"example_value"` // The alias of the resource that this tag will be added to (Optional) + Id *ID `json:"id,omitempty" yaml:"id,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the resource that this tag will be added to (Optional) Key string `json:"key" yaml:"key" example:"example_value"` // The tag's key (Required) Type *TaggableResource `json:"type,omitempty" yaml:"type,omitempty" example:"Domain"` // The type of resource `alias` refers to, if `alias` is provided (Optional) Value string `json:"value" yaml:"value" example:"example_value"` // The tag's value (Required) @@ -1124,9 +1124,9 @@ type TagRelationshipKeysAssignInput struct { // TagUpdateInput Specifies the input fields used to update a tag type TagUpdateInput struct { - Id ID `json:"id" yaml:"id" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the tag to be updated (Required) - Key *Nullable[string] `json:"key,omitempty" yaml:"key,omitempty" example:"example_value"` // The tag's key (Optional) - Value *Nullable[string] `json:"value,omitempty" yaml:"value,omitempty" example:"example_value"` // The tag's value (Optional) + Id ID `json:"id" yaml:"id" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the tag to be updated (Required) + Key *string `json:"key,omitempty" yaml:"key,omitempty" example:"example_value"` // The tag's key (Optional) + Value *string `json:"value,omitempty" yaml:"value,omitempty" example:"example_value"` // The tag's value (Optional) } // TeamCreateInput Specifies the input fields used to create a team @@ -1181,9 +1181,9 @@ type TeamPropertyDefinitionsAssignInput struct { // TeamUpdateInput Specifies the input fields used to update a team type TeamUpdateInput struct { - Alias *Nullable[string] `json:"alias,omitempty" yaml:"alias,omitempty" example:"example_value"` // The alias of the team to be updated (Optional) + Alias *string `json:"alias,omitempty" yaml:"alias,omitempty" example:"example_value"` // The alias of the team to be updated (Optional) Group *IdentifierInput `json:"group,omitempty" yaml:"group,omitempty"` // The group this team belongs to (Optional) - Id *Nullable[ID] `json:"id,omitempty" yaml:"id,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the team to be updated (Optional) + Id *ID `json:"id,omitempty" yaml:"id,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the team to be updated (Optional) ManagerEmail *Nullable[string] `json:"managerEmail,omitempty" yaml:"managerEmail,omitempty" example:"example_value"` // The email of the user who manages the team (Optional) Members *[]TeamMembershipUserInput `json:"members,omitempty" yaml:"members,omitempty" example:"[]"` // A set of emails that identify users in OpsLevel (Optional) Name *Nullable[string] `json:"name,omitempty" yaml:"name,omitempty" example:"example_value"` // The team's display name (Optional) @@ -1196,8 +1196,8 @@ type ToolCreateInput struct { Category ToolCategory `json:"category" yaml:"category" example:"admin"` // The category that the tool belongs to (Required) DisplayName string `json:"displayName" yaml:"displayName" example:"example_value"` // The display name of the tool (Required) Environment *Nullable[string] `json:"environment,omitempty" yaml:"environment,omitempty" example:"example_value"` // The environment that the tool belongs to (Optional) - ServiceAlias *Nullable[string] `json:"serviceAlias,omitempty" yaml:"serviceAlias,omitempty" example:"example_value"` // The alias of the service the tool will be assigned to (Optional) - ServiceId *Nullable[ID] `json:"serviceId,omitempty" yaml:"serviceId,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the service the tool will be assigned to (Optional) + ServiceAlias *string `json:"serviceAlias,omitempty" yaml:"serviceAlias,omitempty" example:"example_value"` // The alias of the service the tool will be assigned to (Optional) + ServiceId *ID `json:"serviceId,omitempty" yaml:"serviceId,omitempty" example:"Z2lkOi8vc2VydmljZS8xMjM0NTY3ODk"` // The id of the service the tool will be assigned to (Optional) Url string `json:"url" yaml:"url" example:"example_value"` // The URL of the tool (Required) } diff --git a/tags.go b/tags.go index 19f08ce3..a8258554 100644 --- a/tags.go +++ b/tags.go @@ -134,9 +134,9 @@ func (client *Client) CreateTags(identifier string, tags map[string]string) ([]T Value: value, } if IsID(identifier) { - input.Id = RefOf(ID(identifier)) + input.Id = NewID(identifier) } else { - input.Alias = RefOf(identifier) + input.Alias = &identifier } newTag, err := client.CreateTag(input) if err != nil { @@ -166,8 +166,10 @@ func (client *Client) UpdateTag(input TagUpdateInput) (*Tag, error) { var m struct { Payload TagUpdatePayload `graphql:"tagUpdate(input: $input)"` } - if err := ValidateTagKey(input.Key.Value); err != nil { - return nil, err + if input.Key != nil { + if err := ValidateTagKey(*input.Key); err != nil { + return nil, err + } } v := PayloadVariables{ "input": input, @@ -199,8 +201,9 @@ func (client *Client) ReconcileTags(resourceType TaggableResourceInterface, tags toCreate, toDelete := reconcileTags(tagConnection.Nodes, tagsDesired) for _, tag := range toCreate { taggableResourceType := resourceType.ResourceType() + taggableResourceID := resourceType.ResourceId() _, err := client.CreateTag(TagCreateInput{ - Id: RefOf(resourceType.ResourceId()), + Id: &taggableResourceID, Type: &taggableResourceType, Key: tag.Key, Value: tag.Value, From 3bce6a9276dd71ac8792f6f5d46fdac2e988cc44 Mon Sep 17 00:00:00 2001 From: Rocktavious Date: Thu, 30 Jan 2025 11:44:11 -0600 Subject: [PATCH 2/2] fix tests --- tags_test.go | 6 ++++-- team_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tags_test.go b/tags_test.go index f76db5d3..c3066bc9 100644 --- a/tags_test.go +++ b/tags_test.go @@ -187,11 +187,13 @@ func TestUpdateTag(t *testing.T) { ) client := BestTestClient(t, "tagUpdate", testRequest) + hello := "hello" + world := "world!" // Act result, err := client.UpdateTag(ol.TagUpdateInput{ Id: id1, - Key: ol.RefOf("hello"), - Value: ol.RefOf("world!"), + Key: &hello, + Value: &world, }) // Assert autopilot.Ok(t, err) diff --git a/team_test.go b/team_test.go index 949ec254..640f1be1 100644 --- a/team_test.go +++ b/team_test.go @@ -577,7 +577,7 @@ func TestUpdateTeam(t *testing.T) { // Arrange input := autopilot.Register[ol.TeamUpdateInput]("team_update_input", ol.TeamUpdateInput{ - Id: ol.RefOf(id1), + Id: &id1, Responsibilities: ol.RefOf("Foo & bar"), ParentTeam: ol.NewIdentifier("parent_team"), },