Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/azure/setup-helm-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrremann authored May 28, 2024
2 parents 3e3357b + ca493db commit 57dd501
Show file tree
Hide file tree
Showing 18 changed files with 495 additions and 540 deletions.
19 changes: 13 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/magiconair/properties v1.8.7
github.com/mitchellh/hashstructure v1.1.0
github.com/mitchellh/mapstructure v1.5.0
github.com/nais/liberator v0.0.0-20240426111230-5fb257b0706e
github.com/nais/liberator v0.0.0-20240528110305-6f0607c14332
github.com/novln/docker-parser v1.0.0
github.com/prometheus/client_golang v1.19.0
github.com/sirupsen/logrus v1.9.3
Expand All @@ -24,19 +24,19 @@ require (
golang.org/x/net v0.23.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0
google.golang.org/protobuf v1.34.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/controller-runtime v0.17.2
)

require (
github.com/GoogleCloudPlatform/gke-fqdnnetworkpolicies-golang v0.0.0-20230601172828-5dd0a14ed3f3
github.com/go-logr/logr v1.4.1
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.70.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
)

require (
Expand All @@ -48,18 +48,21 @@ require (
github.com/eapache/queue v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
Expand All @@ -68,10 +71,11 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.30.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -85,9 +89,11 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
Expand All @@ -102,6 +108,7 @@ require (
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/controller-tools v0.14.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
70 changes: 52 additions & 18 deletions go.sum

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions pkg/resourcecreator/google/sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ func GoogleSQLDatabase(objectMeta metav1.ObjectMeta, instanceName, dbName, proje
objectMeta.Name = dbName
util.SetAnnotation(&objectMeta, google.ProjectIdAnnotation, projectId)

// This is an annotation, but also a spec field.
// Which one has presedence? We set both to be certain.
var deletionPolicy string
if !cascadingDelete {
// Prevent out-of-band objects from being deleted when the Kubernetes resource is deleted.
util.SetAnnotation(&objectMeta, google.DeletionPolicyAnnotation, google.DeletionPolicyAbandon)
deletionPolicy = google_sql_crd.DeletionPolicyAbandon
} else {
deletionPolicy = google_sql_crd.DeletionPolicyDelete
}

return &google_sql_crd.SQLDatabase{
TypeMeta: metav1.TypeMeta{
Kind: "SqlDatabase",
Kind: "SQLDatabase",
APIVersion: "sql.cnrm.cloud.google.com/v1beta1",
},
ObjectMeta: objectMeta,
Spec: google_sql_crd.SQLDatabaseSpec{
InstanceRef: google_sql_crd.InstanceRef{Name: instanceName},
InstanceRef: google_sql_crd.InstanceRef{Name: instanceName},
ResourceID: dbName,
DeletionPolicy: deletionPolicy,
},
}
}
26 changes: 18 additions & 8 deletions pkg/resourcecreator/google/sql/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ import (

func TestGoogleSqlDatabase(t *testing.T) {
app := fixtures.MinimalApplication()
objectMeta := resource.CreateObjectMeta(app)
instanceName := "instance-0"
instance := nais.CloudSqlInstance{Name: instanceName, Type: "POSTGRES_11"}
database := nais.CloudSqlDatabase{Name: "db1"}
projectId := "projectid"
sqlDatabase := google_sql.GoogleSQLDatabase(objectMeta, instance.Name, database.Name, projectId, instance.CascadingDelete)
projectID := "projectid"
instance := nais.CloudSqlInstance{
Name: "instance-0",
Type: "POSTGRES_11",
}
database := nais.CloudSqlDatabase{
Name: "db1",
}
sqlDatabase := google_sql.GoogleSQLDatabase(
resource.CreateObjectMeta(app),
instance.Name,
database.Name,
projectID,
instance.CascadingDelete,
)

assert.Equal(t, database.Name, sqlDatabase.Name)
assert.Equal(t, database.Name, sqlDatabase.Name)
assert.Equal(t, instanceName, sqlDatabase.Spec.InstanceRef.Name)
assert.Equal(t, instance.Name, sqlDatabase.Spec.InstanceRef.Name)
assert.Equal(t, google.DeletionPolicyAbandon, sqlDatabase.ObjectMeta.Annotations[google.DeletionPolicyAnnotation])
assert.Equal(t, projectId, sqlDatabase.ObjectMeta.Annotations[google.ProjectIdAnnotation])
assert.Equal(t, projectID, sqlDatabase.ObjectMeta.Annotations[google.ProjectIdAnnotation])
}
Loading

0 comments on commit 57dd501

Please sign in to comment.