Skip to content

Commit

Permalink
feat(bump): add accessentry and bump deps (#78)
Browse files Browse the repository at this point in the history
* feat(bump): add accessentry and bump deps

Signed-off-by: Christopher Haar <christopher.haar@upbound.io>

* style(lint): fix lint issues

Signed-off-by: Christopher Haar <christopher.haar@upbound.io>

---------

Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
  • Loading branch information
haarchri authored Aug 13, 2024
1 parent 930aa68 commit 801fe5c
Show file tree
Hide file tree
Showing 16 changed files with 558 additions and 699 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/_output
/results
/.idea
/.kclvm

*.xpkg
kubeconfig

# generated by kcl
apis/composition-kcl-generated.yaml
apis/kcl/composition.yaml
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CROSSPLANE_CLI_VERSION=v1.16.0
# ====================================================================================
# Setup XPKG
XPKG_DIR = $(shell pwd)
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml,apis/composition-kcl.yaml
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml
XPKG_REG_ORGS ?= xpkg.upbound.io/upbound
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
Expand Down Expand Up @@ -57,7 +57,7 @@ submodules: ## Update the submodules, such as the common build scripts.

# We must ensure up is installed in tool cache prior to build as including the k8s_tools machinery prior to the xpkg
# machinery sets UP to point to tool cache.
build.init: $(UP) kcl-generate
build.init: $(UP) kcl

# ====================================================================================
# End to End Testing
Expand All @@ -70,29 +70,53 @@ build.init: $(UP) kcl-generate
SKIP_DELETE ?=
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e examples/network-xr.yaml,examples/network-xr-kcl.yaml,examples/eks-xr.yaml,examples/eks-xr-kcl.yaml --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 $(SKIP_DELETE) || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) CROSSPLANE_CLI=$(CROSSPLANE_CLI) $(UPTEST) e2e "${UPTEST_EXAMPLE_LIST}" --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=test/setup.sh --default-timeout=2400 $(SKIP_DELETE) || $(FAIL)
@$(OK) running automated tests

# This target requires the following environment variables to be set:
# - UPTEST_CLOUD_CREDENTIALS, cloud credentials for the provider being tested, e.g. export UPTEST_CLOUD_CREDENTIALS=$(cat ~/.aws/credentials)
# Use `make e2e SKIP_DELETE=--skip-delete` to skip deletion of resources created during the test.
e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest ## Run uptest together with all dependencies. Use `make e2e SKIP_DELETE=--skip-delete` to skip deletion of resources.

kcl-generate: $(KCL) ## Generate KCL-based Composition
$(KCL) generate-composition.k

render-kcl: kcl-generate $(CROSSPLANE_CLI) ## Crossplane render kcl generated composition
$(CROSSPLANE_CLI) beta render examples/eks-xr.yaml apis/composition-kcl-generated.yaml examples/functions.yaml -r

render: $(CROSSPLANE_CLI) ## Crossplane render
$(CROSSPLANE_CLI) beta render examples/eks-xr.yaml apis/composition.yaml examples/functions.yaml -r
kcl: $(KCL) ## Generate KCL-based Composition
$(KCL) apis/kcl/generate.k

render: kcl $(CROSSPLANE_CLI) ${YQ}
@indir="./examples"; \
for file in $$(find $$indir -type f -name '*.yaml' ); do \
doc_count=$$(grep -c '^---' "$$file"); \
if [[ $$doc_count -gt 0 ]]; then \
continue; \
fi; \
COMPOSITION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/composition-path"' $$file); \
FUNCTION=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/function-path"' $$file); \
ENVIRONMENT=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/environment-path"' $$file); \
OBSERVE=$$(${YQ} eval '.metadata.annotations."render.crossplane.io/observe-path"' $$file); \
if [[ "$$ENVIRONMENT" == "null" ]]; then \
ENVIRONMENT=""; \
fi; \
if [[ "$$OBSERVE" == "null" ]]; then \
OBSERVE=""; \
fi; \
if [[ "$$COMPOSITION" == "null" || "$$FUNCTION" == "null" ]]; then \
continue; \
fi; \
ENVIRONMENT=$${ENVIRONMENT=="null" ? "" : $$ENVIRONMENT}; \
OBSERVE=$${OBSERVE=="null" ? "" : $$OBSERVE}; \
$(CROSSPLANE_CLI) beta render $$file $$COMPOSITION $$FUNCTION $${ENVIRONMENT:+-e $$ENVIRONMENT} $${OBSERVE:+-o $$OBSERVE} -x; \
done

yamllint: ## Static yamllint check
@$(INFO) running yamllint
@yamllint ./apis || $(FAIL)
@$(OK) running yamllint

kcllint: ## Static kcllint check
@$(INFO) running kcllint
@$(KCL) lint ./apis/kcl/ || $(FAIL)
@$(OK) running kcllint

help.local:
@grep -E '^[a-zA-Z_-]+.*:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: uptest e2e render yamllint help.local
.PHONY: uptest e2e render yamllint kcllint help.local
39 changes: 0 additions & 39 deletions apis/composition-kcl.yaml

This file was deleted.

15 changes: 3 additions & 12 deletions apis/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: xeks.aws.platform.upbound.io
spec:
defaultCompositionRef:
name: xeks.aws.platform.upbound.io
name: pat.xeks.aws.platform.upbound.io
connectionSecretKeys:
- kubeconfig
group: aws.platform.upbound.io
Expand Down Expand Up @@ -36,18 +36,9 @@ spec:
type: object
description: IAM configuration to connect as ClusterAdmin.
properties:
roleArn:
description: The IAM Role ARN to connect as ClusterAdmin.
principalArn:
description: The principal ARN to connect as ClusterAdmin.
type: string
default: roleArn
userArn:
description: The IAM User ARN to connect as ClusterAdmin.
type: string
default: userArn
autoscalerArn:
description: The AutoScaler Role ARN to connect as ClusterAdmin.
type: string
default: autoscalerArn
deletionPolicy:
description: Delete the external resources when the Claim/XR is deleted. Defaults to Delete
enum:
Expand Down
77 changes: 77 additions & 0 deletions apis/kcl/generate.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import file
import yaml

_composition = {
apiVersion: "apiextensions.crossplane.io/v1",
kind: "Composition",
metadata: {
name: "kcl.xeks.aws.platform.upbound.io",
labels: {
provider: "aws",
function: "kcl",
},
},
spec: {
writeConnectionSecretsToNamespace: "upbound-system",
compositeTypeRef: {
apiVersion: "aws.platform.upbound.io/v1alpha1"
kind: "XEKS"
},
mode: "Pipeline",
pipeline: [
{
step: "kcl"
functionRef: {
name: "crossplane-contrib-function-kcl"
}
input: {
apiVersion: "krm.kcl.dev/v1alpha1"
kind: "KCLRun"
spec: {
source = (file.read("apis/kcl/main.k"))
}
}
},
{
step: "automatically-detect-ready-composed-resources"
functionRef: {
name: "crossplane-contrib-function-auto-ready"
},
},
{
step: "sequence-creation"
functionRef: {
name: "crossplane-contrib-function-sequencer"
}
input: {
apiVersion: "sequencer.fn.crossplane.io/v1beta1"
kind: "Input"
rules: [
{
sequence: [
"kubernetesCluster"
"kubernetesClusterAuth"
"vpc-cni-addon"
"nodeGroupPublic"
]
},
{
sequence: [
"nodeGroupPublic"
"aws-ebs-csi-driver-addon"
]
},
{
sequence: [
"nodeGroupPublic"
"eks-pod-identity-agent-addon"
]
}
]
}
}
]
}
}

file.write("apis/kcl/composition.yaml", yaml.encode(_composition))
Loading

0 comments on commit 801fe5c

Please sign in to comment.