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

feat: add governance_subscription_resource [GOV-630] #2072

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roope-kar
Copy link
Member

@roope-kar roope-kar commented Feb 26, 2025

for managing governance subscriptions, marked as beta as the API and resource are prone to change.

About this change—what it does

Resolves: #xxxxx.

Why this way

@roope-kar roope-kar requested a review from byashimov February 26, 2025 18:38
func resourceGovernanceSubscriptionCreate(ctx context.Context, d *schema.ResourceData, client avngen.Client) error {
var req governance.OrganizationGovernanceSubscriptionCreateIn

req.SubscriptionName = d.Get("subscription_name").(string)
Copy link
Member Author

@roope-kar roope-kar Feb 27, 2025

Choose a reason for hiding this comment

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

The reason why I did not use the preferred schemautil.ResourceDataGet and schemautil.ResourceDataSet was because:

  1. in the tf schema, the subscription_data is a list and acorn API wants single object.
  2. There we also some optional fields that needed to be excluded if not defined.
  3. schemautil.RenameAlias (project_name -> project) seemed to not reach inside subscription_data, only top level.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey. It is better to stick to the schema. I would flatten subscription_data field. Is there any reason why it is turned into a property?

Copy link
Member Author

@roope-kar roope-kar Mar 4, 2025

Choose a reason for hiding this comment

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

Agreed, I wanted to keep it 1:1 with the schema as well thus I did not flatten it. The subscription_data is a property in Acorn API because the relevant fields could be different for other subscription_type (we don't know yet).

Though one option could be to make the resource based on subscription_type. In this case, aiven_governance_kafka_subscription. While it would not be 1:1 with API schema, it would provide more flat structure and perhaps reduce congitive complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding the API schema, I think there is room for improvement and we'll probably try to simplify it with some abstraction but I'm hoping the Beta mark will give us room for future improvements.

Copy link
Contributor

@byashimov byashimov left a comment

Choose a reason for hiding this comment

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

Please update the go mod files if you use a custom client branch.

Optional: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 256),
Description: userconfig.Desc("The IP address from which a principal is allowed or denied access to the resource. Use `*` for all hosts").ForceNew().MaxLen(256).Build(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: there is IsCIDR validator organization_vpc.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey, I did not use this for now, since I realized it needs to support csv of ips (which matches the kafka-native-acl schema)

func resourceGovernanceSubscriptionCreate(ctx context.Context, d *schema.ResourceData, client avngen.Client) error {
var req governance.OrganizationGovernanceSubscriptionCreateIn

req.SubscriptionName = d.Get("subscription_name").(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey. It is better to stick to the schema. I would flatten subscription_data field. Is there any reason why it is turned into a property?

@roope-kar roope-kar force-pushed the rkar-add-governance-subscription-resource branch 4 times, most recently from 531e329 to 9889554 Compare March 5, 2025 07:59
@roope-kar roope-kar requested a review from byashimov March 5, 2025 08:03
for managing governance subscriptions, beta as prone to change.
@roope-kar roope-kar force-pushed the rkar-add-governance-subscription-resource branch from 9889554 to 2e1af34 Compare March 6, 2025 07:48
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