Skip to content

Commit

Permalink
Merge pull request #1922 from crossplane-contrib/backport-1921-to-rel…
Browse files Browse the repository at this point in the history
…ease-0.44
  • Loading branch information
MisterMX committed Oct 19, 2023
2 parents ab10001 + 157e33e commit 4cb93f7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions apis/kafka/generator-config.yaml
Expand Up @@ -18,3 +18,9 @@ resources:
errors:
404:
code: NotFoundException
fields:
ClusterPolicyVersion:
is_read_only: true
from:
operation: GetClusterPolicy
path: CurrentVersion
2 changes: 2 additions & 0 deletions apis/kafka/v1alpha1/zz_cluster.go

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

5 changes: 5 additions & 0 deletions apis/kafka/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions package/crds/kafka.aws.crossplane.io_clusters.yaml
Expand Up @@ -1295,6 +1295,9 @@ spec:
clusterARN:
description: The Amazon Resource Name (ARN) of the cluster.
type: string
clusterPolicyVersion:
description: Cluster policy version.
type: string
state:
description: The state of the cluster. The possible states are
ACTIVE, CREATING, DELETING, FAILED, HEALING, MAINTENANCE, REBOOTING_BROKER,
Expand Down
16 changes: 11 additions & 5 deletions pkg/controller/kafka/cluster/setup.go
Expand Up @@ -375,19 +375,24 @@ func (u *hooks) getClusterPolicyState(ctx context.Context, wanted *svcapitypes.C
})
if IsNotFound(err) {
if wanted.Spec.ForProvider.ClusterPolicy == nil {
return subResourceOK, "spec.forProvider.clusterPolicy", nil
return subResourceOK, "", nil
}
return subResourceNeedsUpdate, "spec.forProvider.clusterPolicy", nil
}
if err != nil {
return subResourceOK, "", errors.Wrap(err, errGetClusterPolicy)
}

// write clusterPolicy currentVersion into status to be used in potential update and to be visible for user
wanted.Status.AtProvider.ClusterPolicyVersion = res.CurrentVersion

if res.Policy == nil {
if wanted.Spec.ForProvider.ClusterPolicy == nil {
return subResourceNeedsDeletion, "spec.forProvider.clusterPolicy", nil
return subResourceOK, "", nil
}
return subResourceOK, "spec.forProvider.clusterPolicy", nil
return subResourceNeedsUpdate, "spec.forProvider.clusterPolicy", nil
} else if wanted.Spec.ForProvider.ClusterPolicy == nil {
return subResourceNeedsDeletion, "spec.forProvider.clusterPolicy", nil
}

currentPolicy, err := policy.ParsePolicyString(*res.Policy)
Expand Down Expand Up @@ -990,8 +995,9 @@ func (u *hooks) update(ctx context.Context, mg resource.Managed) (managed.Extern
return managed.ExternalUpdate{}, errors.Wrap(err, errMarshalClusterPolicy)
}
_, err = u.client.PutClusterPolicyWithContext(ctx, &svcsdk.PutClusterPolicyInput{
ClusterArn: &currentARN,
Policy: policyRaw,
ClusterArn: &currentARN,
CurrentVersion: cr.Status.AtProvider.ClusterPolicyVersion,
Policy: policyRaw,
})
if err != nil {
return managed.ExternalUpdate{}, errors.Wrap(err, errPutClusterPolicy)
Expand Down

0 comments on commit 4cb93f7

Please sign in to comment.