Skip to content

Commit

Permalink
Improve taskfile slightly (#1742)
Browse files Browse the repository at this point in the history
* Slight simplification of Taskfile

* Don't output RBAC for Crossplane

* Disambiguate variables

go-task doesn’t work properly with dynamic variables in
different directories, see: go-task/task#524

Co-authored-by: Bevan Arps <[email protected]>
  • Loading branch information
Porges and theunrepentantgeek authored Sep 20, 2021
1 parent 6808735 commit 7abfc0b
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,19 @@ tasks:
cmds:
- mkdir -p ./apis
- find ./apis -type f -name "zz_generated.*" -delete
- if [ -d "./config/crd/bases" ]; then find "./config/crd/bases" -type f -delete; fi
- cd apis && controller-gen object:headerFile=../../boilerplate.go.txt paths="./..." || true
- cd apis && controller-gen {{.CRD_OPTIONS}} rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=../config/crd/bases output:webhook:artifacts:config=../config/webhook output:rbac:artifacts:config=../config/rbac
- if [ -d "{{.OUTPUT}}/crd/bases" ]; then find "{{.OUTPUT}}/crd/bases" -type f -delete; fi
- cd apis && controller-gen {{.OBJECT_OPTIONS}} paths=./...
- cd apis && controller-gen {{.CRD_OPTIONS}} {{.WEBHOOK_OPTIONS}} {{.RBAC_OPTIONS}} paths=./...
vars:
CRD_OPTIONS: "crd:crdVersions=v1,allowDangerousTypes=true"
HEADER_FILE:
sh: 'realpath ../boilerplate.go.txt #controller:generate-crds'
OBJECT_OPTIONS: object:headerFile={{.HEADER_FILE}}

OUTPUT:
sh: 'realpath config #controller:generate-crds'
CRD_OPTIONS: crd:crdVersions=v1,allowDangerousTypes=true output:crd:artifacts:config={{.OUTPUT}}/crd/bases
WEBHOOK_OPTIONS: webhook output:webhook:artifacts:config={{.OUTPUT}}/webhook
RBAC_OPTIONS: rbac:roleName=manager-role output:rbac:artifacts:config={{.OUTPUT}}/rbac

controller:generate-genruntime-deepcopy:
desc: Run controller-gen to generate {{.CONTROLLER_APP}} CRD files.
Expand All @@ -278,8 +286,12 @@ tasks:
- "pkg/genruntime/**/*.go"
cmds:
- find ./pkg/genruntime -type f -name "zz_generated.*" -delete
- cd pkg/genruntime && controller-gen object:headerFile=../../../boilerplate.go.txt paths="./..." || true
- cd pkg/genruntime && controller-gen {{.OBJECT_OPTIONS}} paths=./...
- cd pkg/genruntime && gofmt -l -s -w . # We do this because controller-gen can generate these files in a way that isn't gofmt'ed which can break things down the line
vars:
HEADER_FILE:
sh: 'realpath ../boilerplate.go.txt #controller:generate-genruntime-deepcopy'
OBJECT_OPTIONS: object:headerFile={{.HEADER_FILE}}

controller:generate-kustomize:
desc: Run {{.GENERATOR_APP}} to generate the Kustomize file for registering CRDs.
Expand Down Expand Up @@ -359,11 +371,19 @@ tasks:
cmds:
- mkdir -p ./apis
- find ./apis -type f -name "zz_generated.*" -delete
- if [ -d "./config/crd/bases" ]; then find "./config/crd/bases" -type f -delete; fi
- cd apis && controller-gen object:headerFile=../../boilerplate.go.txt paths="./..." || true
- cd apis && controller-gen {{.CRD_OPTIONS}} rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=../config/crd/bases output:webhook:artifacts:config=../config/webhook
- if [ -d "{{.OUTPUT}}/crd/bases" ]; then find "{{.OUTPUT}}/crd/bases" -type f -delete; fi
- cd apis && controller-gen {{.OBJECT_OPTIONS}} paths=./...
- cd apis && controller-gen {{.CRD_OPTIONS}} {{.WEBHOOK_OPTIONS}} {{.RBAC_OPTIONS}} paths=./...
vars:
CRD_OPTIONS: "crd:crdVersions=v1,allowDangerousTypes=true"
HEADER_FILE:
sh: 'realpath ../boilerplate.go.txt #crossplane:generate-crds'
OBJECT_OPTIONS: object:headerFile={{.HEADER_FILE}}

OUTPUT:
sh: 'realpath config #crossplane:generate-crds'
CRD_OPTIONS: crd:crdVersions=v1,allowDangerousTypes=true output:crd:artifacts:config={{.OUTPUT}}/crd/bases
WEBHOOK_OPTIONS: webhook output:webhook:artifacts:config={{.OUTPUT}}/webhook
RBAC_OPTIONS: rbac:roleName=manager-role # output:rbac:artifacts:config={{.OUTPUT}}/rbac # not output currently?

crossplane:generate-types:
desc: Run {{.GENERATOR_APP}} to generate input files for controller-gen for {{.CROSSPLANE_APP}}.
Expand Down

0 comments on commit 7abfc0b

Please sign in to comment.