Skip to content

Commit

Permalink
fixing PostgreSQL creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz.widera@vshn.ch committed Sep 27, 2024
1 parent 0def60f commit 9de527a
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 967 deletions.
388 changes: 0 additions & 388 deletions 1

This file was deleted.

531 changes: 0 additions & 531 deletions log.log

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
sgv1beta1 "github.com/vshn/appcat/v4/apis/stackgres/v1beta1"
appcatv1 "github.com/vshn/appcat/v4/apis/v1"
vshnv1 "github.com/vshn/appcat/v4/apis/vshn/v1"
"gopkg.in/yaml.v2"

"github.com/vshn/appcat/v4/pkg/common/utils"
"github.com/vshn/appcat/v4/pkg/comp-functions/functions/common"
Expand Down Expand Up @@ -491,13 +490,6 @@ func createSgObjectStorage(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRunt
return fmt.Errorf("waiting for dependencies: %w", err)
}

all, _ := svc.GetAllObserved()
yaml, err := yaml.Marshal(all["pg-bucket"])
if err != nil {
return fmt.Errorf("cannot marshal all observed: %w", err)
}
fmt.Println(string(yaml))

sgObjectStorage := &sgv1beta1.SGObjectStorage{
ObjectMeta: metav1.ObjectMeta{
Name: "sgbackup-" + comp.GetName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ func TestPostgreSqlDeploy(t *testing.T) {
ctx := context.TODO()

assert.Nil(t, DeployPostgreSQL(ctx, &vshnv1.VSHNPostgreSQL{}, svc))
return
assert.Nil(t, addSchedules(ctx, &vshnv1.VSHNPostgreSQL{}, svc))
ns := &corev1.Namespace{}
assert.NoError(t, svc.GetDesiredKubeObject(ns, "namespace-conditions"))
assert.Equal(t, string("vshn"), ns.GetLabels()[utils.OrgLabelName])

roleBinding := &rbacv1.RoleBinding{}
assert.NoError(t, svc.GetDesiredKubeObject(roleBinding, "namespace-permissions"))

Expand Down
3 changes: 0 additions & 3 deletions pkg/comp-functions/runtime/function_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,6 @@ func (s *ServiceRuntime) WaitForDependenciesWithConnectionDetails(mainResource s
return false, nil
}

jsonized, _ := json.MarshalIndent(s.req.Observed.Resources, " ", " ")
fmt.Println("Checking connection details for object", "object", string(jsonized))

cd, err := s.GetObservedComposedResourceConnectionDetails(dep)
if err != nil {
return false, err
Expand Down
37 changes: 2 additions & 35 deletions test/functions/vshn-postgres/deploy/01_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ desired:
writeConnectionSecretToRef: {}
status:
instanceNamespace: vshn-postgresql-pgsql-gc9x4
"pg-bucket":
connectionDetails:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
"pg-bucket":
resource:
apiVersion: appcat.vshn.io/v1
kind: XObjectBucket
Expand Down Expand Up @@ -68,12 +61,6 @@ desired:
status: "True"
type: Ready
connectionDetails:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
lastPublishedTime: "2024-09-26T14:37:37Z"
input:
apiVersion: v1
Expand Down Expand Up @@ -170,21 +157,14 @@ observed:
#here
resources:
"pg-bucket":
connectionDetails:
connection_details:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
resource:
connectionDetails:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
apiVersion: appcat.vshn.io/v1
kind: XObjectBucket
metadata:
Expand All @@ -206,13 +186,6 @@ observed:
writeConnectionSecretToRef:
name: pgsql-gc9x4
namespace: vshn-postgresql-pgsql-gc9x4
connectionDetails:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
status:
conditions:
- lastTransitionTime: "2024-09-27T08:06:34Z"
Expand All @@ -224,12 +197,6 @@ observed:
status: "True"
type: Ready
connectionDetails:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
lastPublishedTime: "2024-09-26T14:37:37Z"

namespace-conditions:
Expand Down
134 changes: 134 additions & 0 deletions test/functions/vshn-postgres/deploy/02_with_pg_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,140 @@ observed:
status:
instanceNamespace: vshn-postgresql-pgsql-gc9x4
resources:
certificate:
resource:
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
annotations:
crossplane.io/composition-resource-name: certificate
crossplane.io/external-create-pending: "2024-09-26T14:37:32Z"
crossplane.io/external-create-succeeded: "2024-09-26T14:37:32Z"
crossplane.io/external-name: pgsql-gc9x4-certificate
creationTimestamp: "2024-09-26T14:37:32Z"
finalizers:
- finalizer.managedresource.crossplane.io
generateName: pgsql-gc9x4-
generation: 38
labels:
appcat.vshn.io/ownerapiversion: v1
appcat.vshn.io/ownergroup: vshn.appcat.vshn.io
appcat.vshn.io/ownerkind: XVSHNPostgreSQL
crossplane.io/claim-name: postgresql-widera-test3
crossplane.io/claim-namespace: widera-testing
crossplane.io/composite: pgsql-gc9x4
manager: crossplane-kubernetes-provider
operation: Update
subresource: status
time: "2024-09-26T14:37:34Z"
name: pgsql-gc9x4-certificate
ownerReferences:
- apiVersion: vshn.appcat.vshn.io/v1
blockOwnerDeletion: true
controller: true
kind: XVSHNPostgreSQL
name: pgsql-gc9x4
uid: 4d072f13-029d-4d9d-bc24-0e4f622a9d3a
resourceVersion: "531293"
uid: 1ffeef69-4add-4d17-98ae-5c210cdd0503
spec:
deletionPolicy: Delete
forProvider:
manifest:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
annotations:
appcat.vshn.io/forward-events-to: vshn.appcat.vshn.io/v1/VSHNPostgreSQL/widera-testing/postgresql-widera-test3
labels:
appcat.vshn.io/ownerapiversion: v1
appcat.vshn.io/ownergroup: vshn.appcat.vshn.io
appcat.vshn.io/ownerkind: XVSHNPostgreSQL
crossplane.io/composite: pgsql-gc9x4
name: pgsql-gc9x4
namespace: vshn-postgresql-pgsql-gc9x4
spec:
dnsNames:
- pgsql-gc9x4.vshn-postgresql-pgsql-gc9x4.svc.cluster.local
- pgsql-gc9x4.vshn-postgresql-pgsql-gc9x4.svc
duration: 87600h0m0s
issuerRef:
group: cert-manager.io
kind: Issuer
name: pgsql-gc9x4
privateKey:
algorithm: RSA
encoding: PKCS1
size: 4096
renewBefore: 2400h0m0s
secretName: tls-certificate
subject:
organizations:
- vshn-appcat
usages:
- server auth
- client auth
status: {}
managementPolicies:
- '*'
providerConfigRef:
name: kubernetes
readiness:
policy: SuccessfulCreate
watch: false
status:
conditions:
- lastTransitionTime: "2024-09-26T14:37:33Z"
reason: Available
status: "True"
type: Ready
- lastTransitionTime: "2024-09-26T14:37:32Z"
reason: ReconcileSuccess
status: "True"
type: Synced

"pg-bucket":
connection_details:
AWS_ACCESS_KEY_ID: whatever
AWS_REGION: whatever
AWS_SECRET_ACCESS_KEY: whatever
BUCKET_NAME: whatever
ENDPOINT: whatever
ENDPOINT_URL: whatever
resource:
apiVersion: appcat.vshn.io/v1
kind: XObjectBucket
metadata:
name: pgsql-gc9x4
labels:
appuio.io/organization: vshn
crossplane.io/claim-name: pgsql
crossplane.io/claim-namespace: unit-test
crossplane.io/composite: pgsql-gc9x4
spec:
parameters:
bucketName: pgsql-gc9x4
providerRef:
name: s3
region: ch-gva-2
security:
deletionProtection: false
allowAllNamespaces: false
writeConnectionSecretToRef:
name: pgsql-gc9x4
namespace: vshn-postgresql-pgsql-gc9x4
status:
conditions:
- lastTransitionTime: "2024-09-27T08:06:34Z"
reason: ReconcileSuccess
status: "True"
type: Synced
- lastTransitionTime: "2024-09-26T14:37:37Z"
reason: Available
status: "True"
type: Ready
connectionDetails:
lastPublishedTime: "2024-09-26T14:37:37Z"
namespace-conditions:
resource:
apiVersion: kubernetes.crossplane.io/v1alpha2
Expand Down
Loading

0 comments on commit 9de527a

Please sign in to comment.