Skip to content

Commit

Permalink
Merge pull request DataWorkflowServices#19 from roehrich-hpe/release-…
Browse files Browse the repository at this point in the history
…v0.0.4

Release v0.0.4
  • Loading branch information
roehrich-hpe authored Mar 21, 2024
2 parents 96d2a0e + 422c1e3 commit 4af9238
Show file tree
Hide file tree
Showing 693 changed files with 54,475 additions and 27,836 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Docker build and push

on:
push:
branches:
- '*'
tags:
- 'v*'
on: [push]

env:
# TEST_TARGET: Name of the testing target in the Dockerfile
Expand All @@ -14,9 +9,6 @@ env:
# DO_TEST - true to build and run unit tests, false to skip the tests
DO_TEST: true

# DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push
DO_PUSH: true

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -98,3 +90,23 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}

create_release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Repair tag
run: git fetch -f origin ${{ github.ref }}:${{ github.ref }}
- name: Verify that the tag is annotated
run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi
- name: Release
uses: softprops/action-gh-release@v1
with:
#prerelease: true
generate_release_notes: true

28 changes: 0 additions & 28 deletions .github/workflows/verify_tag.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ bin
.vscode

.version
config/begin/*
cover.out

9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build the manager binary
FROM golang:1.19 as builder

ARG TARGETOS
ARG TARGETARCH

Expand All @@ -12,15 +13,15 @@ COPY vendor/ vendor/
COPY config/ config/

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

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# the GOARCH has 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 main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

FROM builder as testing
WORKDIR /workspace
Expand Down
69 changes: 41 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022-2023 Hewlett Packard Enterprise Development LP
# Copyright 2022-2024 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is licensed under the Apache License,
Expand Down Expand Up @@ -29,8 +29,10 @@
# cray.hpe.com/dws-bundle:$VERSION and cray.hpe.com/dws-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/dataworkflowservices/dws-test-driver

OVERLAY ?= top

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.0
ENVTEST_K8S_VERSION = 1.28.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -39,6 +41,12 @@ else
GOBIN=$(shell go env GOBIN)
endif

# $(CONTAINER_TOOL) defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
# tools. (i.e. podman)
CONTAINER_TOOL ?= docker

# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
Expand Down Expand Up @@ -72,7 +80,8 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
# $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
echo

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand All @@ -90,53 +99,53 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run cmd/main.go

.PHONY: container-unit-test
container-unit-test: VERSION ?= $(shell cat .version)
container-unit-test: .version ## Build docker image with the manager and execute unit tests.
docker build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing .
docker run --rm -t --name $@-dws-test-driver $(IMAGE_TAG_BASE)-$@:$(VERSION)
container-unit-test: .version ## Build $(CONTAINER_TOOL) image with the manager and execute unit tests.
$(CONTAINER_TOOL) build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing .
$(CONTAINER_TOOL) run --rm -t --name $@-dws-test-driver $(IMAGE_TAG_BASE)-$@:$(VERSION)

# If you wish built the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
# (i.e. $(CONTAINER_TOOL) build --platform linux/arm64 ). However, you must enable $(CONTAINER_TOOL) buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: VERSION ?= $(shell cat .version)
docker-build: test .version ## Build docker image with the manager.
docker build -t ${IMAGE_TAG_BASE}:${VERSION} .
docker-build: test .version ## Build $(CONTAINER_TOOL) image with the manager.
$(CONTAINER_TOOL) build -t ${IMAGE_TAG_BASE}:${VERSION} .

.PHONY: docker-push
docker-push: VERSION ?= $(shell cat .version)
docker-push: .version ## Push docker image with the manager.
docker push ${IMAGE_TAG_BASE}:${VERSION}
docker-push: .version ## Push $(CONTAINER_TOOL) image with the manager.
$(CONTAINER_TOOL) push ${IMAGE_TAG_BASE}:${VERSION}

.PHONY: kind-push
KIND_CLUSTER ?= "kind"
kind-push: VERSION ?= $(shell cat .version)
kind-push: .version ## Push docker image to kind
kind-push: .version ## Push $(CONTAINER_TOOL) image to kind
kind load docker-image --name $(KIND_CLUSTER) ${IMAGE_TAG_BASE}:${VERSION}

# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
# - able to use $(CONTAINER_TOOL) buildx . More info: https://docs.docker.com/build/buildx/
# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
# To properly provided solutions that supports more than one platform you should use this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: VERSION ?= $(shell cat .version)
docker-buildx: .version test ## Build and push docker image for the manager for cross-platform support
docker-buildx: .version test ## Build and push $(CONTAINER_TOOL) image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- docker buildx create --name project-v3-builder
docker buildx use project-v3-builder
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
- docker buildx rm project-v3-builder
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag ${IMAGE_TAG_BASE}:${VERSION} -f Dockerfile.cross
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

##@ Deployment
Expand All @@ -145,15 +154,18 @@ ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: edit-image
edit-image: VERSION ?= $(shell cat .version)
edit-image: .version
$(KUSTOMIZE_IMAGE_TAG) config/begin $(OVERLAY) $(IMAGE_TAG_BASE) $(VERSION)

.PHONY: deploy
deploy: VERSION ?= $(shell cat .version)
deploy: .version kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMAGE_TAG_BASE}:${VERSION}
$(KUSTOMIZE) build config/top | kubectl apply -f -
deploy: kustomize edit-image ## Deploy controller to the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/begin | kubectl apply -f -

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/top | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
$(KUSTOMIZE) build config/$(OVERLAY) | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

# Let .version be phony so that a git update to the workarea can be reflected
# in it each time it's needed.
Expand All @@ -178,18 +190,19 @@ clean-bin:
fi

## Tool Binaries
KUSTOMIZE_IMAGE_TAG ?= ./hack/make-kustomization.sh
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.7
CONTROLLER_TOOLS_VERSION ?= v0.12.0
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.13.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(LOCALBIN) ## Download kustomize locally if necessary.
if [[ ! -s $(LOCALBIN)/kustomize || $$($(LOCALBIN)/kustomize version | awk '{print $$1}' | awk -F/ '{print $$2}') != $(KUSTOMIZE_VERSION) ]]; then \
if [[ ! -s $(LOCALBIN)/kustomize || ! $$($(LOCALBIN)/kustomize version) =~ $(KUSTOMIZE_VERSION) ]]; then \
rm -f $(LOCALBIN)/kustomize && \
{ curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }; \
fi
Expand Down
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
domain: cray.hpe.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
projectName: dws-test-driver
repo: github.com/DataWorkflowServices/dws-test-driver
resources:
- controller: true
domain: cray.hpe.com
group: dws
domain: github.io
group: dataworkflowservices
kind: Workflow
version: v1alpha1
version: v1alpha2
version: "3"
6 changes: 3 additions & 3 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/DataWorkflowServices/dws-test-driver/controllers"
controllers "github.com/DataWorkflowServices/dws-test-driver/internal/controller"
//+kubebuilder:scaffold:imports
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down Expand Up @@ -72,8 +73,7 @@ func main() {
setupLog.Info("GOMAXPROCS", "value", runtime.GOMAXPROCS(0))
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "842e30f2.cray.hpe.com",
Expand Down
Loading

0 comments on commit 4af9238

Please sign in to comment.