Skip to content

Commit

Permalink
Merge branch 'vsukhin/fix/wrong-workflow-name' into sandbox/twrc
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>

# Conflicts:
#	cmd/tcl/testworkflow-toolkit/commands/execute.go
#	go.mod
#	go.sum
#	pkg/triggers/service.go
  • Loading branch information
vsukhin committed Oct 28, 2024
2 parents 993a133 + 221edaf commit 6b766f6
Show file tree
Hide file tree
Showing 56 changed files with 1,885 additions and 715 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.git
.gitignore
.github
LICENSE
README.md
Makefile
build
docs
assets
config
choco
test
test
skaffold.yaml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ movie.mp4
/dist
.vscode


build/_local/values.dev.yaml
46 changes: 46 additions & 0 deletions build/_local/agent-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
###################################
## Build
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

RUN apk --no-cache --update add ca-certificates && (rm -rf /var/cache/apk/* || 0)

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/agent-server cmd/api-server/main.go

###################################
## Debug
###################################
FROM golang:1.23-alpine AS debug

ENV GOTRACEBACK=all
RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/build/_local/agent-server /testkube/

ENTRYPOINT ["/go/bin/dlv", "exec", "--headless", "--continue", "--accept-multiclient", "--listen=:56268", "--api-version=2", "/testkube/agent-server"]

###################################
## Distribution
###################################
FROM scratch AS dist

COPY LICENSE /testkube/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /app/build/_local/agent-server /testkube/

EXPOSE 8080
ENTRYPOINT ["/testkube/agent-server"]
63 changes: 63 additions & 0 deletions build/_local/testworkflow-init.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
ARG BUSYBOX_IMAGE="busybox:1.36.1-musl"

###################################
## Build testworkflow init
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/workflow-init cmd/testworkflow-init/main.go

###################################
## Build testworkflow toolkit
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/workflow-init cmd/testworkflow-init/main.go

###################################
## Debug
###################################
FROM golang:1.23-alpine AS debug

ENV GOTRACEBACK=all
RUN go install github.com/go-delve/delve/cmd/[email protected]

COPY --from=builder /app/build/_local/workflow-init /testkube/

ENTRYPOINT ["/go/bin/dlv", "exec", "--headless", "--continue", "--accept-multiclient", "--listen=:56268", "--api-version=2", "/testkube/workflow-init"]

###################################
## Distribution
###################################
FROM ${BUSYBOX_IMAGE} AS dist
RUN cp -rf /bin /.tktw-bin
COPY --from=builder /app/build/_local/workflow-init /testkube/init
USER 1001
ENTRYPOINT ["/init"]

71 changes: 71 additions & 0 deletions build/_local/testworkflow-toolkit.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
ARG BUSYBOX_IMAGE="busybox:1.36.1-musl"
ARG ALPINE_IMAGE="alpine:3.20.0"
FROM ${BUSYBOX_IMAGE} AS busybox

###################################
## Build testworkflow-init
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder-init

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/workflow-init cmd/testworkflow-init/main.go

###################################
## Build testworkflow-toolkit
###################################
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS builder-toolkit

ARG TARGETOS
ARG TARGETARCH
ARG GOMODCACHE="/root/.cache/go-build"
ARG GOCACHE="/go/pkg"
ARG SKAFFOLD_GO_GCFLAGS

RUN go install github.com/go-delve/delve/cmd/[email protected]

WORKDIR /app
COPY . .
RUN --mount=type=cache,target="$GOMODCACHE" \
--mount=type=cache,target="$GOCACHE" \
GOOS=$TARGETOS \
GOARCH=$TARGETARCH \
CGO_ENABLED=0 \
go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o build/_local/workflow-toolkit cmd/testworkflow-toolkit/main.go

###################################
## Debug
###################################
FROM ${ALPINE_IMAGE} AS debug
RUN apk --no-cache add ca-certificates libssl3 git openssh-client
ENV GOTRACEBACK=all
COPY --from=builder-toolkit /go/bin/dlv /
COPY --from=busybox /bin /.tktw-bin
COPY --from=builder-toolkit /app/build/_local/workflow-toolkit /toolkit
COPY --from=builder-init /app/build/_local/workflow-init /init
RUN adduser --disabled-password --home / --no-create-home --uid 1001 default
USER 1001
ENTRYPOINT ["/dlv", "exec", "--headless", "--accept-multiclient", "--listen=:56300", "--api-version=2", "/toolkit"]

###################################
## Distribution
###################################
FROM ${ALPINE_IMAGE} AS dist
RUN apk --no-cache add ca-certificates libssl3 git openssh-client
COPY --from=busybox /bin /.tktw-bin
COPY --from=builder-toolkit /app/build/_local/workflow-toolkit /toolkit
COPY --from=builder-init /app/build/_local/workflow-init /init
RUN adduser --disabled-password --home / --no-create-home --uid 1001 default
USER 1001
ENTRYPOINT ["/toolkit"]
12 changes: 12 additions & 0 deletions build/_local/values.dev.tpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testkube-dashboard:
enabled: false
mongodb:
enabled: false
testkube-api:
cloud:
url: testkube-enterprise-api:8089
tls:
enabled: false
existingSecret:
name: testkube-default-agent-token
key: agent-token
2 changes: 1 addition & 1 deletion cmd/api-server/commons/commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func ReadProContext(ctx context.Context, cfg *config.Config, grpcClient cloud.Te
DashboardURI: cfg.TestkubeDashboardURI,
}

if grpcClient == nil {
if cfg.TestkubeProAPIKey == "" || grpcClient == nil {
return proContext
}

Expand Down
1 change: 1 addition & 0 deletions cmd/api-server/commons/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (d *deprecatedClients) Templates() templatesclientv1.Interface {
return d.templates
}

// TODO: Move Templates() out of Deprecation, as it's used by Webhook Payload (?)
func CreateDeprecatedClients(kubeClient client.Client, namespace string) DeprecatedClients {
return &deprecatedClients{
executors: executorsclientv1.NewClient(kubeClient, namespace),
Expand Down
Loading

0 comments on commit 6b766f6

Please sign in to comment.