Skip to content

Commit

Permalink
Merge pull request #130 from vshn/add/resource-names
Browse files Browse the repository at this point in the history
Make composition function compatible
  • Loading branch information
Kidswiss authored Mar 31, 2023
2 parents 3f6b8d9 + e867be3 commit f45b453
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
19 changes: 19 additions & 0 deletions component/vshn_postgres.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ local namespace = comp.KubeObject('v1', 'Namespace') +
};

local namespaceObserve = {
name: 'ns-observer',
base: namespace {
spec+: {
managementPolicy: 'Observe',
Expand All @@ -110,6 +111,7 @@ local namespaceObserve = {
};

local namespaceConditions = {
name: 'namespace-conditions',
base: namespace,
patches: [
comp.ToCompositeFieldPath('status.conditions', 'status.namespaceConditions'),
Expand All @@ -121,6 +123,7 @@ local namespaceConditions = {
};

local localca = {
name: 'local-ca',
base: comp.KubeObject('cert-manager.io/v1', 'Issuer') +
{
spec+: {
Expand Down Expand Up @@ -148,6 +151,7 @@ local localca = {
};

local certificate = {
name: 'certificate',
base: comp.KubeObject('cert-manager.io/v1', 'Certificate') +
{
spec+: {
Expand Down Expand Up @@ -199,6 +203,7 @@ local certificate = {
};

local sgInstanceProfile = {
name: 'profile',
base: comp.KubeObject('stackgres.io/v1', 'SGInstanceProfile') +
{
spec+: {
Expand Down Expand Up @@ -281,6 +286,7 @@ local sgInstanceProfile = {
};

local sgPostgresConfig = {
name: 'pg-conf',
base: comp.KubeObject('stackgres.io/v1', 'SGPostgresConfig') +
{
spec+: {
Expand All @@ -307,6 +313,7 @@ local sgPostgresConfig = {
};

local sgCluster = {
name: 'cluster',
base: comp.KubeObject('stackgres.io/v1', 'SGCluster') +
{
spec+: {
Expand Down Expand Up @@ -385,6 +392,7 @@ local sgCluster = {
};

local secret = {
name: 'connection',
base: comp.KubeObject('v1', 'Secret') +
{
spec+: {
Expand Down Expand Up @@ -468,6 +476,7 @@ local secret = {
};

local xobjectBucket = {
name: 'pg-bucket',
base: {
apiVersion: 'appcat.vshn.io/v1',
kind: 'XObjectBucket',
Expand All @@ -494,6 +503,7 @@ local xobjectBucket = {
};

local sgObjectStorage = {
name: 'sg-backup',
base: comp.KubeObject('stackgres.io/v1beta1', 'SGObjectStorage') +
{
spec+: {
Expand Down Expand Up @@ -542,6 +552,7 @@ local sgObjectStorage = {
};

local networkPolicy = {
name: 'network-policy',
base: comp.KubeObject('networking.k8s.io/v1', 'NetworkPolicy') +
{
spec+: {
Expand Down Expand Up @@ -582,6 +593,7 @@ local networkPolicy = {
};

local copyJob = {
name: 'copy-job',
base: comp.KubeObject('batch/v1', 'Job') + {
spec+: {
forProvider+: {
Expand Down Expand Up @@ -635,6 +647,7 @@ local copyJob = {
};

local clusterRestoreConfig = {
name: 'cluster-restore',
base+: {
spec+: {
references+: [
Expand All @@ -656,6 +669,7 @@ local clusterRestoreConfig = {
};

local maintenanceServiceAccount = {
name: 'maintenance-serviceaccount',
base: comp.KubeObject('v1', 'ServiceAccount') + {
spec+: {
forProvider+: {
Expand All @@ -670,6 +684,7 @@ local maintenanceServiceAccount = {
};

local maintenanceRole = {
name: 'maintenance-role',
base: comp.KubeObject('rbac.authorization.k8s.io/v1', 'Role') + {
spec+: {
forProvider+: {
Expand All @@ -695,6 +710,7 @@ local maintenanceRole = {
};

local maintenanceRoleBinding = {
name: 'maintenance-rolebinding',
base: comp.KubeObject('rbac.authorization.k8s.io/v1', 'RoleBinding') + {
spec+: {
forProvider+: {
Expand Down Expand Up @@ -812,6 +828,7 @@ local convertToCron() = [
];

local maintenanceJob = {
name: 'maintenancejob',
base: comp.KubeObject('batch/v1', 'CronJob') + {
spec+: {
forProvider+: {
Expand Down Expand Up @@ -859,6 +876,7 @@ local maintenanceJob = {
};

local prometheusRule = {
name: 'prometheusrule',
base: comp.KubeObject('monitoring.coreos.com/v1', 'PrometheusRule') + {
spec+: {
forProvider+: {
Expand Down Expand Up @@ -948,6 +966,7 @@ local prometheusRule = {
};

local podMonitor = {
name: 'podmonitor',
base: comp.KubeObject('monitoring.coreos.com/v1', 'PodMonitor') + {
spec+: {
forProvider+: {
Expand Down
1 change: 1 addition & 0 deletions lib/appcat-compositions.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ local kubeObject(apiVersion, kind) = {
};

local namespacePermissions(namespacePrefix) = {
name: 'namespace-permissions',
base: {
apiVersion: 'kubernetes.crossplane.io/v1alpha1',
kind: 'Object',
Expand Down
18 changes: 18 additions & 0 deletions tests/golden/vshn/appcat/appcat/21_composition_vshn_postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
managementPolicy: Observe
providerConfigRef:
name: kubernetes
name: ns-observer
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -70,6 +71,7 @@ spec:
name: ''
providerConfigRef:
name: kubernetes
name: namespace-conditions
patches:
- fromFieldPath: status.conditions
toFieldPath: status.namespaceConditions
Expand Down Expand Up @@ -111,6 +113,7 @@ spec:
name: organization
providerConfigRef:
name: kubernetes
name: namespace-permissions
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -148,6 +151,7 @@ spec:
crlDistributionPoints: []
providerConfigRef:
name: kubernetes
name: local-ca
patches:
- fromFieldPath: status.conditions
toFieldPath: status.localCAConditions
Expand Down Expand Up @@ -206,6 +210,7 @@ spec:
- client auth
providerConfigRef:
name: kubernetes
name: certificate
patches:
- fromFieldPath: status.conditions
toFieldPath: status.certificateConditions
Expand Down Expand Up @@ -285,6 +290,7 @@ spec:
memory: null
providerConfigRef:
name: kubernetes
name: profile
patches:
- fromFieldPath: status.conditions
toFieldPath: status.profileConditions
Expand Down Expand Up @@ -355,6 +361,7 @@ spec:
postgresql.conf: {}
providerConfigRef:
name: kubernetes
name: pg-conf
patches:
- fromFieldPath: status.conditions
toFieldPath: status.pgconfigConditions
Expand Down Expand Up @@ -421,6 +428,7 @@ spec:
sgInstanceProfile: ''
providerConfigRef:
name: kubernetes
name: cluster
patches:
- fromFieldPath: status.conditions
toFieldPath: status.pgclusterConditions
Expand Down Expand Up @@ -572,6 +580,7 @@ spec:
- fromConnectionSecretKey: POSTGRESQL_PASSWORD
name: POSTGRESQL_PASSWORD
type: FromConnectionSecretKey
name: connection
patches:
- fromFieldPath: status.conditions
toFieldPath: status.secretConditions
Expand Down Expand Up @@ -671,6 +680,7 @@ spec:
writeConnectionSecretToRef:
name: ''
namespace: ''
name: pg-bucket
patches:
- fromFieldPath: status.conditions
toFieldPath: status.objectBackupConfigConditions
Expand Down Expand Up @@ -726,6 +736,7 @@ spec:
type: s3Compatible
providerConfigRef:
name: kubernetes
name: sg-backup
patches:
- fromFieldPath: status.conditions
toFieldPath: status.objectBucketConditions
Expand Down Expand Up @@ -792,6 +803,7 @@ spec:
name: maintenanceserviceaccount
providerConfigRef:
name: kubernetes
name: maintenance-serviceaccount
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -833,6 +845,7 @@ spec:
- create
providerConfigRef:
name: kubernetes
name: maintenance-role
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -869,6 +882,7 @@ spec:
name: maintenanceserviceaccount
providerConfigRef:
name: kubernetes
name: maintenance-rolebinding
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -940,6 +954,7 @@ spec:
successfulJobsHistoryLimit: 0
providerConfigRef:
name: kubernetes
name: maintenancejob
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -1047,6 +1062,7 @@ spec:
app: StackGresCluster
providerConfigRef:
name: kubernetes
name: podmonitor
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -1171,6 +1187,7 @@ spec:
severity: critical
providerConfigRef:
name: kubernetes
name: prometheusrule
patches:
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: metadata.name
Expand Down Expand Up @@ -1209,6 +1226,7 @@ spec:
- Ingress
providerConfigRef:
name: kubernetes
name: network-policy
patches:
- fromFieldPath: status.conditions
toFieldPath: status.networkPolicyConditions
Expand Down
Loading

0 comments on commit f45b453

Please sign in to comment.