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

Add reference for Configuration to kafka cluster #877

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions apis/kafka/v1beta1/reference.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package v1beta1

import (
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
"github.com/crossplane/crossplane-runtime/pkg/reference"
xpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
)

// Lovingly ripped off from config/common/ARNExtractor. Is there a better way?
func GetConfigurationRevision() reference.ExtractValueFn {
return func(mg xpresource.Managed) string {
paved, err := fieldpath.PaveObject(mg)
if err != nil {
// todo(hasan): should we log this error?
return ""
}
r, err := paved.GetString("status.atProvider.revision")
if err != nil {
// todo(hasan): should we log this error?
return ""
}
return r
}
}
30 changes: 22 additions & 8 deletions apis/kafka/v1beta1/zz_cluster_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 21 additions & 13 deletions apis/kafka/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions apis/kafka/v1beta1/zz_generated.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions config/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ func Configure(p *config.Provider) {
r.References["broker_node_group_info.security_groups"] = config.Reference{
Type: "github.com/upbound/provider-aws/apis/ec2/v1beta1.SecurityGroup",
}
r.References["configuration_info.arn"] = config.Reference{
Type: "Configuration",
Extractor: common.PathARNExtractor,
}
r.References["configuration_info.revision"] = config.Reference{
Type: "Configuration",
Extractor: "GetConfigurationRevision()",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Extractor: "GetConfigurationRevision()",
Extractor: `github.com/upbound/upjet/pkg/resource.ExtractParamPath("latest_revision",true)`,

We have a function for such situations, could you please try the configuration above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! I thought I remembered seeing something like that, and looked for it, but couldn't find it. This is much better.

}
r.UseAsync = true
})
}
27 changes: 26 additions & 1 deletion examples/kafka/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ spec:
- clientSubnetsRefs:
- name: subnet-az1
- name: subnet-az2
instanceType: kafka.m5.large
instanceType: kafka.t3.small
securityGroupsRefs:
- name: sg
storageInfo:
- ebsStorageInfo:
- volumeSize: 1000
clusterName: example
configurationInfo:
arnSelector:
matchLabels:
testing.upbound.io/example-name: example
revisionSelector:
matchLabels:
testing.upbound.io/example-name: example
encryptionInfo:
- encryptionAtRestKmsKeyArnSelector:
matchLabels:
Expand All @@ -42,6 +49,24 @@ spec:

---

apiVersion: kafka.aws.upbound.io/v1beta1
kind: Configuration
metadata:
labels:
testing.upbound.io/example-name: example
name: example
spec:
forProvider:
kafkaVersions:
- 2.6.0
name: example
region: us-west-1
serverProperties: |
auto.create.topics.enable = true
delete.topic.enable = true

---

apiVersion: iam.aws.upbound.io/v1beta1
kind: Role
metadata:
Expand Down
Loading
Loading