Skip to content

Commit

Permalink
refactor: don't use include and define
Browse files Browse the repository at this point in the history
  • Loading branch information
irizzant committed May 23, 2024
1 parent 6a255ac commit 441df43
Showing 1 changed file with 40 additions and 46 deletions.
86 changes: 40 additions & 46 deletions apis/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,11 @@ spec:
template: |
{{ $params := .observed.composite.resource.spec.parameters }}
{{- define "providerConfigRef" }}
providerConfigRef:
name: {{ .observed.composite.resource.spec.parameters.providerConfigName }}
{{- end }}
{{- define "networkId" }}
networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }}
{{- end }}
{{- define "region" }}
region: {{ .observed.composite.resource.spec.parameters.region }}
{{- end }}
{{- define "deletionPolicy" }}
deletionPolicy: {{ .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }}
{{- end }}
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("vpc") }}
spec:
Expand All @@ -50,25 +36,27 @@ spec:
enableDnsSupport: true
tags:
Name: {{ .observed.composite.resource.metadata.name }}
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: InternetGateway
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("igw") }}
spec:
forProvider:
vpcIdSelector:
matchControllerRef: true
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
{{ $region := $params.region }}
{{ $deletionPolicy := $params.deletionPolicy | default "Delete" }}
Expand Down Expand Up @@ -116,22 +104,23 @@ spec:
kind: RouteTable
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("rt") }}
spec:
forProvider:
vpcIdSelector:
matchControllerRef: true
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: Route
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("route") }}
spec:
Expand All @@ -141,15 +130,16 @@ spec:
matchControllerRef: true
routeTableIdSelector:
matchControllerRef: true
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: MainRouteTableAssociation
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("mrt") }}
spec:
Expand All @@ -158,9 +148,10 @@ spec:
matchControllerRef: true
vpcIdSelector:
matchControllerRef: true
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
{{- range $i, $subnet := $params.subnets }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
Expand Down Expand Up @@ -193,7 +184,7 @@ spec:
kind: SecurityGroup
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("sg") }}
spec:
Expand All @@ -202,15 +193,16 @@ spec:
name: platform-ref-aws-cluster
vpcIdSelector:
matchControllerRef: true
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroupRule
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("sgrp") }}
spec:
Expand All @@ -224,15 +216,16 @@ spec:
matchControllerRef: true
toPort: 5432
type: ingress
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: ec2.aws.upbound.io/v1beta1
kind: SecurityGroupRule
metadata:
labels:
{{- include "networkId" . | nindent 4 }}
networks.aws.platform.upbound.io/network-id: {{ $params.id }}
annotations:
{{ setResourceNameAnnotation ("sgrm") }}
spec:
Expand All @@ -246,9 +239,10 @@ spec:
matchControllerRef: true
toPort: 3306
type: ingress
{{- include "region" . | nindent 2 }}
{{- include "providerConfigRef" . }}
{{- include "deletionPolicy" . }}
region: {{ $params.region }}
providerConfigRef:
name: {{ $params.providerConfigName }}
deletionPolicy: {{ $params.deletionPolicy | default "Delete" }}
---
apiVersion: {{ .observed.composite.resource.apiVersion }}
kind: {{ .observed.composite.resource.kind }}
Expand Down

0 comments on commit 441df43

Please sign in to comment.