Skip to content

Conversation

@andrewstillv15
Copy link
Contributor

@andrewstillv15 andrewstillv15 commented Dec 10, 2025

Resolves #14198

Problem

  • Adds support for owner relationships & component category predicates
  • owner relationships required the owner_relationship_management_rules FF on your account

Solution

Some test structures for manual testing:

func FilterTest(client *opslevel.Client) {
	createInput := opslevel.FilterCreateInput{
		Name: "opslevel-go test filter",
		Predicates: &[]opslevel.FilterPredicateInput{
			{
				Key:   "component_category",
				Type:  opslevel.PredicateTypeEnumDoesNotEqual,
				Value: opslevel.NewNullableFrom("default"),
			},
		},
	}

	result, err := client.CreateFilter(createInput)
	fmt.Println(result, err)

	updateInput := opslevel.FilterUpdateInput{
		Id: result.FilterId.Id,
		Predicates: &[]opslevel.FilterPredicateInput{
			{
				Key:   "component_category",
				Type:  opslevel.PredicateTypeEnumEquals,
				Value: opslevel.NewNullableFrom("infrastructure"),
			},
		},
	}

	result, err = client.UpdateFilter(updateInput)
	fmt.Println(result, err)
}

func ComponentTypeTest(client *opslevel.Client) {
	input := opslevel.ComponentTypeInput{
		OwnerRelationship: &opslevel.OwnerRelationshipInput{
			ManagementRules: &[]opslevel.ManagementRuleInput{
				{
					Operator:              opslevel.RelationshipDefinitionManagementRuleOperatorEquals,
					SourceProperty:        "tag_key_eq:owner",
					SourcePropertyBuiltin: true,
					TargetProperty:        "name",
					TargetPropertyBuiltin: true,
					TargetType:            opslevel.NewNullableFrom("team"),
				},
				{
					Operator:              opslevel.RelationshipDefinitionManagementRuleOperatorEquals,
					SourceProperty:        "tag_key_eq:owner",
					SourcePropertyBuiltin: true,
					TargetProperty:        "alias",
					TargetPropertyBuiltin: true,
					TargetType:            opslevel.NewNullableFrom("team"),
				},
			},
		},
	}
	result, err := client.UpdateComponentType("aws_cloudfront_distribution", input)

	fmt.Println(result, err)
}

Checklist

  • I have run this code, and it appears to resolve the stated issue.
  • This PR does not reduce total test coverage
  • This PR has no user interface changes or has already received approval from product management to change the interface.
  • Does this change require a Terraform schema change?
    • If so what is the ticket or PR #
  • Make a changie entry that explains the customer facing outcome of this change

@andrewstillv15 andrewstillv15 changed the title Andrew/14198/add support for owner relationships Add support for owner relationships & component category predicates Dec 11, 2025
Copy link
Contributor

@jasonopslevel jasonopslevel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@andrewstillv15 andrewstillv15 merged commit a640bef into main Dec 12, 2025
4 checks passed
@andrewstillv15 andrewstillv15 deleted the andrew/14198/add-support-for-owner-relationships branch December 12, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants