Skip to content

Commit

Permalink
Merge pull request #233 from vshn/fix/bucket_protection
Browse files Browse the repository at this point in the history
Fix ObjectBucket deletion protection
  • Loading branch information
Kidswiss authored Sep 19, 2024
2 parents c0bfba5 + b52d136 commit 01fa5b4
Show file tree
Hide file tree
Showing 26 changed files with 244 additions and 188 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ get-crds:
./hack/get_crds.sh https://github.com/crossplane-contrib/provider-helm provider-helm apis/release apis/helm
./hack/get_crds.sh https://github.com/crossplane-contrib/provider-kubernetes provider-kubernetes apis/object/v1alpha2 apis/kubernetes
# There is currently a bug with the serialization if `inline` and `omitempty` are set: https://github.com/crossplane/function-sdk-go/issues/161
sed -i 's/inline,omitempty/inline/g' apis/helm/release/v1beta1/types.go
$(sed) -i 's/inline,omitempty/inline/g' apis/helm/release/v1beta1/types.go
# provider-sql needs manual fixes... Running this every time would break them.
# The crossplane code generator only works if the code is valid, but the code is not valid until the code generator has run...
#./hack/get_crds.sh https://github.com/crossplane-contrib/provider-sql provider-sql apis/ apis/sql
Expand Down
6 changes: 3 additions & 3 deletions apis/exoscale/v1/dbaas_exoscale_kafka.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
"github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ type ExoscaleKafkaSpec struct {
Parameters ExoscaleKafkaParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

type ExoscaleKafkaParameters struct {
Expand Down Expand Up @@ -75,7 +75,7 @@ type ExoscaleKafkaServiceSpec struct {

type ExoscaleKafkaStatus struct {
// KafkaConditions contains the status conditions of the backing object.
KafkaConditions []v1.Condition `json:"kafkaConditions,omitempty"`
KafkaConditions []vshnv1.Condition `json:"kafkaConditions,omitempty"`

// The actual observed Kafka version.
Version string `json:"version,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions apis/exoscale/v1/dbaas_exoscale_mysql.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
"github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ type ExoscaleMySQLSpec struct {
Parameters ExoscaleMySQLParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

type ExoscaleMySQLParameters struct {
Expand Down Expand Up @@ -71,5 +71,5 @@ type ExoscaleMySQLServiceSpec struct {

type ExoscaleMySQLStatus struct {
// MySQLConditions contains the status conditions of the backing object.
MySQLConditions []v1.Condition `json:"mysqlConditions,omitempty"`
MySQLConditions []vshnv1.Condition `json:"mysqlConditions,omitempty"`
}
6 changes: 3 additions & 3 deletions apis/exoscale/v1/dbaas_exoscale_opensearch.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
v1 "github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -65,9 +65,9 @@ type ExoscaleOpenSearchSpec struct {
Parameters ExoscaleOpenSearchParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}
type ExoscaleOpenSearchStatus struct {
// OpenSearchConditions contains the status conditions of the backing object.
OpenSearchConditions []v1.Condition `json:"opensearchConditions,omitempty"`
OpenSearchConditions []vshnv1.Condition `json:"opensearchConditions,omitempty"`
}
6 changes: 3 additions & 3 deletions apis/exoscale/v1/dbaas_exoscale_postgresql.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
v1 "github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -35,7 +35,7 @@ type ExoscalePostgreSQLSpec struct {
Parameters ExoscalePostgreSQLParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

type ExoscalePostgreSQLParameters struct {
Expand Down Expand Up @@ -71,5 +71,5 @@ type ExoscalePostgreSQLServiceSpec struct {

type ExoscalePostgreSQLStatus struct {
// PostgreSQLConditions contains the status conditions of the backing object.
PostgreSQLConditions []v1.Condition `json:"postgresqlConditions,omitempty"`
PostgreSQLConditions []vshnv1.Condition `json:"postgresqlConditions,omitempty"`
}
6 changes: 3 additions & 3 deletions apis/exoscale/v1/dbaas_exoscale_redis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
v1 "github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -34,7 +34,7 @@ type ExoscaleRedisSpec struct {
Parameters ExoscaleRedisParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

type ExoscaleRedisParameters struct {
Expand All @@ -59,5 +59,5 @@ type ExoscaleRedisServiceSpec struct {

type ExoscaleRedisStatus struct {
// RedisConditions contains the status conditions of the backing object.
RedisConditions []v1.Condition `json:"redisConditions,omitempty"`
RedisConditions []vshnv1.Condition `json:"redisConditions,omitempty"`
}
12 changes: 6 additions & 6 deletions apis/exoscale/v1/zz_generated.deepcopy.go

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

18 changes: 6 additions & 12 deletions apis/v1/objectstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v1
import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
crossplane "github.com/crossplane/crossplane/apis/apiextensions/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -36,7 +37,7 @@ type ObjectBucketSpec struct {
Parameters ObjectBucketParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef vshnv1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
CompositionReference crossplane.CompositionReference `json:"compositionRef,omitempty"`
}

Expand Down Expand Up @@ -64,15 +65,15 @@ type ObjectBucketParameters struct {
BucketDeletionPolicy BucketDeletionPolicy `json:"bucketDeletionPolicy,omitempty"`

// Security defines the security of a service
Security Security `json:"security,omitempty"`
Security vshnv1.Security `json:"security,omitempty"`
}

// ObjectBucketStatus reflects the observed state of a ObjectBucket.
type ObjectBucketStatus struct {
// AccessUserConditions contains a copy of the claim's underlying user account conditions.
AccessUserConditions []Condition `json:"accessUserConditions,omitempty"`
AccessUserConditions []vshnv1.Condition `json:"accessUserConditions,omitempty"`
// BucketConditions contains a copy of the claim's underlying bucket conditions.
BucketConditions []Condition `json:"bucketConditions,omitempty"`
BucketConditions []vshnv1.Condition `json:"bucketConditions,omitempty"`

xpv1.ResourceStatus `json:",inline"`
}
Expand Down Expand Up @@ -102,13 +103,6 @@ type NamespacedName struct {
Name string `json:"name,omitempty"`
}

// Security defines the security of a service
type Security struct {
// DeletionProtection blocks the deletion of the instance if it is enabled (enabled by default)
// +kubebuilder:default=true
DeletionProtection bool `json:"deletionProtection,omitempty"`
}

func (v *ObjectBucket) GetSecurity() *Security {
func (v *ObjectBucket) GetSecurity() *vshnv1.Security {
return &v.Spec.Parameters.Security
}
59 changes: 7 additions & 52 deletions apis/v1/zz_generated.deepcopy.go

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

5 changes: 3 additions & 2 deletions apis/vshn/v1/common_types_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package v1

import (
"github.com/stretchr/testify/assert"
"k8s.io/utils/ptr"
"testing"
"time"

"github.com/stretchr/testify/assert"
"k8s.io/utils/ptr"
)

func Test_GetTime(t *testing.T) {
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions apis/vshn/v1/dbaas_vshn_keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
v1 "github.com/vshn/appcat/v4/apis/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -48,7 +47,7 @@ type VSHNKeycloakSpec struct {
Parameters VSHNKeycloakParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
WriteConnectionSecretToRef LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

// VSHNKeycloakParameters are the configurable fields of a VSHNKeycloak.
Expand Down
Loading

0 comments on commit 01fa5b4

Please sign in to comment.