Skip to content

Commit

Permalink
chore: updates CRDs, and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtcoder17 committed Nov 29, 2024
1 parent f379b52 commit cc8dca1
Show file tree
Hide file tree
Showing 16 changed files with 997 additions and 1,540 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
**
!bin/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ go.work

bin
.direnv
.secrets
go.work
go.work.*
33 changes: 3 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
# Build the manager binary
FROM golang:1.22 AS builder
ARG TARGETOS
ARG TARGETARCH

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
ARG BINARY TARGETARCH
COPY $BINARY-$TARGETARCH /plugin-helm-controller
USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/plugin-helm-controller"]
20 changes: 20 additions & 0 deletions Runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,23 @@ tasks:
HELM_JOB_IMAGE: "ghcr.io/kloudlite/kloudlite/operator/workers/helm-job-runner:v1.1.4"
cmd:
- make run

go:build:
env:
CGO_ENABLED: 0
GOARCH:
required: true
cmd:
- go build -ldflags='-s -w' -o ./bin/plugin-helm-controller-$GOARCH ./cmd

build:
env:
HELM_JOB_IMAGE: "ghcr.io/kloudlite/kloudlite/operator/workers/helm-job-runner:v1.1.4"
image:
required: true
cmd:
- GOARCH=amd64 run2 go:build || echo "hi"
- GOARCH=arm64 run2 go:build || echo "hello"
- docker buildx build -t "$image" --output=type=image,compression=zstd,force-compression=true,compression-level=12,push=true --platform linux/amd64,linux/arm64 --build-arg BINARY=./bin/plugin-helm-controller .


19 changes: 13 additions & 6 deletions api/v1/helmchart_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,25 @@ type ChartInfo struct {
Name string `json:"name"`
}

// HelmChartSpec defines the desired state of HelmChart.
type HelmChartSpec struct {
type HelmJobVars struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`

Resources ct.Resources `json:"resources"`
}

// HelmChartSpec defines the desired state of HelmChart.
type HelmChartSpec struct {
Chart ChartInfo `json:"chart"`

HelmValues map[string]apiextensionsv1.JSON `json:"helmValues"`

HelmJobVars *HelmJobVars `json:"jobVars,omitempty"`

PreInstall string `json:"preInstall,omitempty"`
PostInstall string `json:"postInstall,omitempty"`

HelmValues map[string]apiextensionsv1.JSON `json:"helmValues"`

PreUninstall string `json:"preUninstall,omitempty"`
PostUninstall string `json:"postUninstall,omitempty"`
}
Expand All @@ -59,14 +63,17 @@ type HelmChartStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:JSONPath=".status.lastReconcileTime",name=Seen,type=date
// +kubebuilder:printcolumn:JSONPath=".metadata.annotations.kloudlite\\.io\\/operator\\.checks",name=Checks,type=string
// +kubebuilder:printcolumn:JSONPath=".metadata.annotations.kloudlite\\.io\\/operator\\.resource\\.ready",name=Ready,type=string
// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date

// HelmChart is the Schema for the helmcharts API.
type HelmChart struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec HelmChartSpec `json:"spec,omitempty"`
Output LocalSecretReference `json:"output"`
Spec HelmChartSpec `json:"spec,omitempty"`

Export plugin.Export `json:"export,omitempty"`
Status HelmChartStatus `json:"status,omitempty"`
Expand Down
63 changes: 41 additions & 22 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cc8dca1

Please sign in to comment.