gitkube icon indicating copy to clipboard operation
gitkube copied to clipboard

Templating for git hooks

Open tirumaraiselvan opened this issue 6 years ago • 5 comments

Currently, pre-receive hook is fixed: https://github.com/hasura/gitkube/blob/master/build/gitkubed/pre_receive.sh

We want to make it scriptable to enable : https://github.com/hasura/gitkube/issues/20

Each hook probably needs variables from the remote like DEPLOYMENTS, REGISTRY_PREFIX. For pre-receive, we are currently doing a moustache render during startup.

For giving same variables to each hook, we need to run a moustache render on each hook and then place it in the correct directory.

tirumaraiselvan avatar Apr 04 '18 11:04 tirumaraiselvan

Would this also allow something like using a secret as a Docker build argument? For example, now I need to pass a Github token to a Dockerfile for fetching Github repos during the build. I can get the secret into Gitkubed's environment, but I see there is no way to pass a build argument currently.

jsierles avatar Apr 30 '18 06:04 jsierles

@jsierles Yep. You can then load the build argument from the kubernetes environment

kubectl get secrets my-secrets -o json | jq -r '.data."githubToken"' | base64 --decode

and then pass that as a build-arg to the docker build command.

@tirumaraiselvan Does that make sense?

coco98 avatar Apr 30 '18 11:04 coco98

Yeah sounds good. But this is still not done or on any WIP branch, correct? Is there an easy way to manually update the hook besides updating gitkube to support more docker build arguments and redeploying it?

jsierles avatar Apr 30 '18 11:04 jsierles

Yes, this issue is to make available arbitrary params to the build environment which can then be used in custom hooks. Custom hooks is in a WIP branch although I haven't gotten around to parameterization part yet. For now, the easiest way is to keep the token in the Dockerfile. The harder way is to fork from master and build your own version of Gitkube.

tirumaraiselvan avatar Apr 30 '18 11:04 tirumaraiselvan

@jsierles docker build args support is here https://github.com/hasura/gitkube/pull/64

tirumaraiselvan avatar May 16 '18 10:05 tirumaraiselvan