Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes needed for Terraform #513

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
13 changes: 8 additions & 5 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
Expand Down
Loading