new helm
This commit is contained in:
103
.drone.yml
103
.drone.yml
@@ -1,35 +1,84 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: kubernetes
|
||||||
name: default
|
name: build
|
||||||
|
|
||||||
platform:
|
trigger:
|
||||||
os: linux
|
branch:
|
||||||
arch: amd64
|
- main
|
||||||
|
|
||||||
|
clone:
|
||||||
|
# disable: true
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
image_pull_secrets:
|
||||||
|
- dockerconfig
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
host:
|
||||||
|
path: /mnt/kub.drone
|
||||||
|
- name: gocache
|
||||||
|
host:
|
||||||
|
path: /mnt/kub.drone/${DRONE_REPO}/gocache
|
||||||
|
- name: golangcilintcache
|
||||||
|
host:
|
||||||
|
path: /mnt/kub.drone/${DRONE_REPO}/golangcilintcache
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
|
- name: prepare cache
|
||||||
|
image: harbor.1sept.ru/docker/library/busybox
|
||||||
|
commands:
|
||||||
|
- mkdir -p /cache/${DRONE_REPO}/gocache
|
||||||
|
- mkdir -p /cache/${DRONE_REPO}/golangcilintcache
|
||||||
|
volumes:
|
||||||
|
- name: cache
|
||||||
|
path: /cache
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: golang:1.13
|
image: golangci/golangci-lint:v1.48.0
|
||||||
|
environment:
|
||||||
|
GOCACHE: /drone/src/gocache
|
||||||
|
GOLANGCI_LINT_CACHE: /drone/src/golangcilintcache
|
||||||
commands:
|
commands:
|
||||||
- go test ./cmd/... ./internal/...
|
- go mod download
|
||||||
- go vet ./cmd/... ./internal/...
|
- make test
|
||||||
- name: lint
|
volumes:
|
||||||
image: cytopia/golint
|
- name: gocache
|
||||||
commands:
|
path: /drone/src/gocache
|
||||||
- golint -set_exit_status ./cmd/... ./internal/...
|
- name: golangcilintcache
|
||||||
- name: build
|
path: /drone/src/golangcilintcache
|
||||||
image: golang:1.13
|
resources:
|
||||||
commands:
|
limits:
|
||||||
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/drone-helm cmd/drone-helm/main.go
|
memory: 3GiB
|
||||||
|
|
||||||
|
# - name: build
|
||||||
|
# image: golang:1.19
|
||||||
|
# environment:
|
||||||
|
# GOCACHE: /drone/src/gocache
|
||||||
|
# GOLANGCI_LINT_CACHE: /drone/src/golangcilintcache
|
||||||
|
# commands:
|
||||||
|
# - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/drone-helm cmd/drone-helm/main.go
|
||||||
|
# volumes:
|
||||||
|
# - name: gocache
|
||||||
|
# path: /drone/src/gocache
|
||||||
|
# - name: golangcilintcache
|
||||||
|
# path: /drone/src/golangcilintcache
|
||||||
|
|
||||||
- name: publish_linux_amd64
|
- name: publish_linux_amd64
|
||||||
image: plugins/docker
|
image: harbor.1sept.ru/drone/drone-kaniko
|
||||||
settings:
|
settings:
|
||||||
auto_tag: true
|
registry: harbor.1sept.ru
|
||||||
username:
|
repo: harbor.1sept.ru/drone/drone-helm3
|
||||||
from_secret: docker_username
|
cache: true
|
||||||
password:
|
tags:
|
||||||
from_secret: docker_password
|
- git-${DRONE_COMMIT_SHA:0:7}
|
||||||
repo:
|
- latest
|
||||||
from_secret: plugin_repo
|
username:
|
||||||
dockerfile: Dockerfile
|
from_secret: harbor-username
|
||||||
when:
|
password:
|
||||||
event: [ tag, push ]
|
from_secret: harbor-password
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: signature
|
||||||
|
hmac: 94caa65765078801fd56960cdccacf3a1017ebfb41484099f3e3237ee9f868ef
|
||||||
23
Dockerfile
23
Dockerfile
@@ -1,10 +1,19 @@
|
|||||||
FROM alpine/helm:3.8.1
|
FROM golang:1.22-alpine3.19 as builder
|
||||||
MAINTAINER Joachim Hill-Grannec <joachim@pelo.tech>
|
|
||||||
|
|
||||||
COPY build/drone-helm /bin/drone-helm
|
ENV GO111MODULE=on
|
||||||
COPY assets/kubeconfig.tpl /root/.kube/config.tpl
|
WORKDIR /app
|
||||||
|
|
||||||
LABEL description="Helm 3 plugin for Drone 3"
|
COPY --link go.mod .
|
||||||
LABEL base="alpine/helm"
|
COPY --link go.sum .
|
||||||
|
RUN go mod download
|
||||||
|
COPY --link . .
|
||||||
|
|
||||||
ENTRYPOINT [ "/bin/drone-helm" ]
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /go/bin/drone-helm ./cmd/drone-helm
|
||||||
|
|
||||||
|
# --- Copy the cli to an image with helm already installed ---
|
||||||
|
FROM alpine/helm:3.14.0
|
||||||
|
|
||||||
|
COPY --link --from=builder /go/bin/drone-helm /bin/drone-helm
|
||||||
|
COPY --link ./assets/kubeconfig.tpl /root/.kube/config.tpl
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/bin/drone-helm" ]
|
||||||
@@ -3,10 +3,11 @@ package run
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pelotech/drone-helm3/internal/env"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/pelotech/drone-helm3/internal/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitKube is a step in a helm Plan that initializes the kubernetes config file.
|
// InitKube is a step in a helm Plan that initializes the kubernetes config file.
|
||||||
@@ -87,7 +88,7 @@ func (i *InitKube) Prepare() error {
|
|||||||
fmt.Fprintf(i.stderr, "kubeconfig file at %s\n", i.configFilename)
|
fmt.Fprintf(i.stderr, "kubeconfig file at %s\n", i.configFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
i.configFile, err = os.Create(i.configFilename)
|
i.configFile, err = os.OpenFile(i.configFilename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not open kubeconfig file for writing: %w", err)
|
return fmt.Errorf("could not open kubeconfig file for writing: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user