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 ibm_event_streams_schema_global_rule #5621

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kccox
Copy link
Contributor

@kccox kccox commented Sep 5, 2024

What has been done?

Add a data source and resource for the IBM Event Streams schema-registry global compatibility rule.

  • This is a configuration property of the schema registry, so always exists.
  • The terraform create operation is the same as an update; the delete operation resets the rule to the default value.

The data model used by both data source and resource is:

  • resource_instance_id: The CRN of the Event Streams service instance. (Our existing models for topics and schemas also use this to identify the service instance.) Required in data source and resource.
  • config: The value of the rule. Computed in data source, required in resource.

The implementations use the Event Streams SDK client for our schema-registry API.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes internal Event Streams feature request from BNPP.

Output from acceptance testing:

$ make testacc TEST=./ibm/service/eventstreams TESTARGS='-run=TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleDataSource\|TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleResource'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./ibm/service/eventstreams -v -run=TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleDataSource\|TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleResource -timeout 700m
  (skipping many warnings to set environment variables not used by this test)
=== RUN   TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleDataSource
--- PASS: TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleDataSource (30.54s)
=== RUN   TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleResource
--- PASS: TestAccIBMEventStreamsSchemaGlobalCompatibilityRuleResource (39.46s)
PASS
ok  	github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/eventstreams

ibm/provider/provider.go Outdated Show resolved Hide resolved
@kccox kccox changed the title feat: add ibm_event_streams_schema_global_compatibility_rule feat: add ibm_event_streams_schema_global_rule Oct 14, 2024
func getSchemaGlobalCompatibilityRuleID(instanceCRN string) string {
crnSegments := strings.Split(instanceCRN, ":")
crnSegments[8] = schemaGlobalCompatibilityRuleResourceType
crnSegments[9] = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why we are appending empty string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our convention in Event Streams is that the first 8 fields of the CRN identify the service-instance, and the last two identify the resource on the instance. crnSegment[8] is the type of the resource, and crnSegment[9] is the identifier for the resource.

The type for the global rule is schema-global-compatibility-rule. Since the global compatibility rule is global, there is only one instance, so it does not have a unique identifier field. So we set segment 9 to "".

Example:

  • input instanceCRN is crn:v1:staging:public:messagehub-vnext-integration:eu-gb:a/6db1b0d0b5c54ee5c201552547febcd8:4088c6f5-6a6b-49e8-a31d-712f09f23058::
  • global rule CRN will be crn:v1:staging:public:messagehub-vnext-integration:eu-gb:a/6db1b0d0b5c54ee5c201552547febcd8:4088c6f5-6a6b-49e8-a31d-712f09f23058:schema-global-compatibility-rule:

In practice, the split segment 9 should already be "" since it should be coming from a service-instance CRN, in which the last two fields are not set. Setting it to "" is a precaution in case some other value was provided.

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