diff --git a/apis/postgresql/v1alpha1/provider_types.go b/apis/postgresql/v1alpha1/provider_types.go index 1a0b3eba..2936b72b 100644 --- a/apis/postgresql/v1alpha1/provider_types.go +++ b/apis/postgresql/v1alpha1/provider_types.go @@ -19,6 +19,8 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/crossplane-contrib/provider-sql/pkg/clients" + "github.com/crossplane-contrib/provider-sql/pkg/clients/postgresql" xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) @@ -36,6 +38,24 @@ type ProviderConfigSpec struct { // +kubebuilder:default=verify-full // +kubebuilder:validation:Optional SSLMode *string `json:"sslMode,omitempty"` + // Path to the certificate used for client authentication + // +kubebuilder:validation:Optional + SSLCert *string `json:"sslCert,omitempty"` + // Path to the key used for client authentication + // +kubebuilder:validation:Optional + SSLKey *string `json:"sslKey,omitempty"` + // Path to the CA certificate(s) used for verifying the server certificate + // +kubebuilder:validation:Optional + SSLRootCert *string `json:"sslRootCert,omitempty"` +} + +func (s ProviderConfigSpec) Options() postgresql.Options { + return postgresql.Options{ + SSLMode: clients.ToString(s.SSLMode), + SSLCert: clients.ToString(s.SSLCert), + SSLKey: clients.ToString(s.SSLKey), + SSLRootCert: clients.ToString(s.SSLRootCert), + } } const ( diff --git a/apis/postgresql/v1alpha1/zz_generated.deepcopy.go b/apis/postgresql/v1alpha1/zz_generated.deepcopy.go index 70d15187..bc2fcbaf 100644 --- a/apis/postgresql/v1alpha1/zz_generated.deepcopy.go +++ b/apis/postgresql/v1alpha1/zz_generated.deepcopy.go @@ -563,6 +563,21 @@ func (in *ProviderConfigSpec) DeepCopyInto(out *ProviderConfigSpec) { *out = new(string) **out = **in } + if in.SSLCert != nil { + in, out := &in.SSLCert, &out.SSLCert + *out = new(string) + **out = **in + } + if in.SSLKey != nil { + in, out := &in.SSLKey, &out.SSLKey + *out = new(string) + **out = **in + } + if in.SSLRootCert != nil { + in, out := &in.SSLRootCert, &out.SSLRootCert + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProviderConfigSpec. diff --git a/cluster/local/integration_tests.sh b/cluster/local/integration_tests.sh index e8669b78..3c6a62d0 100755 --- a/cluster/local/integration_tests.sh +++ b/cluster/local/integration_tests.sh @@ -96,6 +96,15 @@ nodes: extraMounts: - hostPath: "${cache_path}/" containerPath: /cache + extraPortMappings: + - containerPort: 5432 + hostPort: 5432 + kubeadmConfigPatches: + - | + kind: ClusterConfiguration + apiServer: + extraArgs: + "service-node-port-range": "1-65535" EOF )" echo "${config}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --wait=5m --image="${node_image}" --config=- diff --git a/cluster/local/postgresdb_functions.sh b/cluster/local/postgresdb_functions.sh index 4a64c7e2..e027dd86 100644 --- a/cluster/local/postgresdb_functions.sh +++ b/cluster/local/postgresdb_functions.sh @@ -21,6 +21,54 @@ setup_postgresdb_no_tls() { PORT_FORWARD_PID=$! } +setup_postgresdb_tls() { + echo_step "Installing PostgresDB Helm chart into default namespace" + postgres_root_pw=$(LC_ALL=C tr -cd "A-Za-z0-9"