From c6c42c4d0860b6d508912ccac1ca0ddd3a78a9cc Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 31 Oct 2022 22:35:36 +0100 Subject: [PATCH] with default --- pkg/cli/templatecmd/init.go | 8 ++++ pkg/cli/templatecmd/ls.go | 2 +- .../templatecmd/templates/default/.drone.yml | 4 ++ templates/bust_default_template.yaml | 40 +++++++++++++++++++ templates/bust_docker_template.yaml | 2 +- templates/uploadtemplate.sh | 5 +-- 6 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 pkg/cli/templatecmd/templates/default/.drone.yml create mode 100644 templates/bust_default_template.yaml diff --git a/pkg/cli/templatecmd/init.go b/pkg/cli/templatecmd/init.go index 0f1923b..f3e01d2 100644 --- a/pkg/cli/templatecmd/init.go +++ b/pkg/cli/templatecmd/init.go @@ -16,6 +16,9 @@ var gobinDefault embed.FS //go:embed templates/docker/* var docker embed.FS +//go:embed templates/default/* +var defaultFs embed.FS + func NewInitCmd() *cobra.Command { var ( template string @@ -40,6 +43,11 @@ func NewInitCmd() *cobra.Command { return err } break + case "default": + if err := initializeTemplate(&defaultFs, "default", name); err != nil { + return err + } + break default: return errors.New("could not find matching templates, please run [bust template ls] instead") } diff --git a/pkg/cli/templatecmd/ls.go b/pkg/cli/templatecmd/ls.go index 616649d..cf0b6c1 100644 --- a/pkg/cli/templatecmd/ls.go +++ b/pkg/cli/templatecmd/ls.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -var templates = []string{"docker", "gobin_default"} +var templates = []string{"docker", "gobin_default", "default"} func NewLsCmd() *cobra.Command { return &cobra.Command{ diff --git a/pkg/cli/templatecmd/templates/default/.drone.yml b/pkg/cli/templatecmd/templates/default/.drone.yml new file mode 100644 index 0000000..0ce3ee3 --- /dev/null +++ b/pkg/cli/templatecmd/templates/default/.drone.yml @@ -0,0 +1,4 @@ +kind: template +load: bust_default_template.yaml +name: [[.Name]] +data: {} diff --git a/templates/bust_default_template.yaml b/templates/bust_default_template.yaml new file mode 100644 index 0000000..3aa7b7c --- /dev/null +++ b/templates/bust_default_template.yaml @@ -0,0 +1,40 @@ +type: docker +kind: pipeline +name: "drone-dagger-test" + +steps: + - name: "build" + image: harbor.server.kjuulh.io/kjuulh/bust:1667250488156 + volumes: + - name: dockersock + path: /var/run + environment: + DOCKER_BUILDKIT: 1 + HARBOR_DOCKER_HOST: "harbor.server.kjuulh.io" + HARBOR_DOCKER_USERNAME: + from_secret: "harbor_docker_username" + HARBOR_DOCKER_PASSWORD: + from_secret: "harbor_docker_password" + commands: + - sleep 5 + - > + echo "$${HARBOR_DOCKER_PASSWORD}" | docker login + --password-stdin + --username="$${HARBOR_DOCKER_USERNAME}" + "$${HARBOR_DOCKER_HOST}" + - bust build default + +services: + - name: docker + image: docker:dind + privileged: true + volumes: + - name: dockersock + path: /var/run + +volumes: + - name: dockersock + temp: {} + +image_pull_secrets: + - dockerconfig diff --git a/templates/bust_docker_template.yaml b/templates/bust_docker_template.yaml index ca26732..72d757d 100644 --- a/templates/bust_docker_template.yaml +++ b/templates/bust_docker_template.yaml @@ -4,7 +4,7 @@ name: "drone-dagger-test" steps: - name: "build" - image: harbor.server.kjuulh.io/kjuulh/bust:1667244085545 + image: harbor.server.kjuulh.io/kjuulh/bust:1667250488156 volumes: - name: dockersock path: /var/run diff --git a/templates/uploadtemplate.sh b/templates/uploadtemplate.sh index a6f971c..9ec833e 100755 --- a/templates/uploadtemplate.sh +++ b/templates/uploadtemplate.sh @@ -7,8 +7,7 @@ function add_template() { drone template update --namespace "${namespace}" --name "${name}" --data "@${name}" } +add_template kjuulh bust_default_template.yaml +add_template kjuulh bust_docker_template.yaml add_template kjuulh bust_gobin_template.yaml add_template kjuulh bust_gobin_default_template.yaml -add_template kjuulh bust_docker_template.yaml - -