Skip to content

Commit

Permalink
Add providerConf ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Kidswiss committed Sep 30, 2024
1 parent eddffb1 commit 326678a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pkg/comp-functions/functions/common/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func createObjectBucket(ctx context.Context, comp common.InfoGetter, svc *runtim
ob := &appcatv1.XObjectBucket{
ObjectMeta: metav1.ObjectMeta{
Name: comp.GetName() + "-backup",
Labels: map[string]string{
runtime.ProviderConfigIgnoreLabel: "true",
},
},
Spec: appcatv1.XObjectBucketSpec{
Parameters: appcatv1.ObjectBucketParameters{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ func createObjectBucket(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime
xObjectBucket := &appcatv1.XObjectBucket{
ObjectMeta: metav1.ObjectMeta{
Name: comp.GetName(),
Labels: map[string]string{
runtime.ProviderConfigIgnoreLabel: "true",
},
},
Spec: appcatv1.XObjectBucketSpec{
Parameters: appcatv1.ObjectBucketParameters{
Expand Down
9 changes: 9 additions & 0 deletions pkg/comp-functions/functions/vshnpostgres/user_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func addUser(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime, username
Annotations: map[string]string{
"crossplane.io/external-name": username,
},
Labels: map[string]string{
runtime.ProviderConfigIgnoreLabel: "true",
},
},
Spec: pgv1alpha1.RoleSpec{
ForProvider: pgv1alpha1.RoleParameters{
Expand Down Expand Up @@ -209,6 +212,9 @@ func addDatabase(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime, name
Annotations: map[string]string{
"crossplane.io/external-name": name,
},
Labels: map[string]string{
runtime.ProviderConfigIgnoreLabel: "true",
},
},
Spec: pgv1alpha1.DatabaseSpec{
ForProvider: pgv1alpha1.DatabaseParameters{},
Expand Down Expand Up @@ -241,6 +247,9 @@ func addGrants(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRuntime, usernam
grant := &pgv1alpha1.Grant{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-%s-%s-grants", comp.GetName(), username, dbname),
Labels: map[string]string{
runtime.ProviderConfigIgnoreLabel: "true",
},
},
Spec: pgv1alpha1.GrantSpec{
ForProvider: pgv1alpha1.GrantParameters{
Expand Down
10 changes: 7 additions & 3 deletions pkg/comp-functions/runtime/function_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
ProtectsAnnotation = "appcat.vshn.io/protects"
EventForwardAnnotation = "appcat.vshn.io/forward-events-to"
providerConfigLabel = "appcat.vshn.io/provider-config"
providerConfigIgnoreLabel = "appcat.vshn.io/ignore-config"
ProviderConfigIgnoreLabel = "appcat.vshn.io/ignore-config"
)

// Step describes a single change within a service.
Expand Down Expand Up @@ -1271,7 +1271,7 @@ func (s *ServiceRuntime) setProviderConfigs() error {
configName := s.observedComposite.GetLabels()[providerConfigLabel]

for i := range s.desiredResources {
if _, exists := s.desiredResources[i].Resource.GetLabels()[providerConfigIgnoreLabel]; exists {
if _, exists := s.desiredResources[i].Resource.GetLabels()[ProviderConfigIgnoreLabel]; exists {
continue
}
// we set the providerConfig Ref
Expand All @@ -1280,7 +1280,11 @@ func (s *ServiceRuntime) setProviderConfigs() error {
return fmt.Errorf("cannot set providerConfig for %s: %w", s.desiredResources[i].Resource.GetName(), err)
}

//TODO: and also the provider-config label in case it's a nested composite
// We also propagate the label, so if the resource is a composite, then
// it will automagically also set the right providerConfigs.
labels := s.desiredResources[i].Resource.GetLabels()
labels[providerConfigLabel] = configName
s.desiredResources[i].Resource.SetLabels(labels)
}

return nil
Expand Down

0 comments on commit 326678a

Please sign in to comment.