Skip to content

Commit

Permalink
Merge pull request #221 from DataWorkflowServices/release-v0.1.5
Browse files Browse the repository at this point in the history
Release v0.1.5
  • Loading branch information
ajfloeder authored Aug 22, 2024
2 parents 1da2dbf + 88027ef commit 0d2c6ad
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 124 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: "Verify auto-generated files"
run: |
make manifests generate generate-go-conversions
if [[ $(git status -s | wc -l) -gt 0 ]]; then \
git status; exit 1; \
fi
- name: "Verify CRD conversions"
run: make verify
run: make verify-conversions

- name: "Lowercase repository name for docker build"
id: lowercase-repository-name
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.21 as builder
FROM golang:1.21 AS builder

ARG TARGETARCH
ARG TARGETOS
Expand All @@ -42,7 +42,7 @@ COPY github/cluster-api/util/conversion/ github/cluster-api/util/conversion/
# 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

FROM builder as testing
FROM builder AS testing
WORKDIR /workspace

COPY hack/ hack/
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ IMAGE_TAG_BASE ?= ghcr.io/dataworkflowservices/dws
OVERLAY ?= kind

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

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -261,15 +261,16 @@ $(CONVERSION_GEN): $(LOCALBIN) # Build conversion-gen from tools folder.
GOBIN=$(LOCALBIN) $(GO_INSTALL) $(CONVERSION_GEN_PKG) $(CONVERSION_GEN_BIN) $(CONVERSION_GEN_VER)

.PHONY: generate-go-conversions
# The SRC_DIRS value is a comma-separated list of paths to old versions.
# The SRC_DIRS value is a space-separated list of paths to old versions.
# The --input-dirs value is a single path item; specify multiple --input-dirs
# parameters if you have multiple old versions.
SRC_DIRS=./api/v1alpha1
generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1"
$(MAKE) clean-generated-conversions SRC_DIRS="$(SRC_DIRS)"
$(CONVERSION_GEN) \
--output-file=zz_generated.conversion.go \
--go-header-file=./hack/boilerplate.go.txt \
./api/v1alpha1
$(SRC_DIRS)

.PHONY: clean-generated-conversions
clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/clientmount_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var clientmountlog = logf.Log.WithName("clientmount-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *ClientMount) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/computes_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var computeslog = logf.Log.WithName("computes-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *Computes) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/directivebreakdown_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var directivebreakdownlog = logf.Log.WithName("directivebreakdown-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *DirectiveBreakdown) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/dwdirectiverule_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var dwdirectiverulelog = logf.Log.WithName("dwdirectiverule-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *DWDirectiveRule) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/persistentstorageinstance_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var persistentstorageinstancelog = logf.Log.WithName("persistentstorageinstance-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *PersistentStorageInstance) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
7 changes: 5 additions & 2 deletions api/v1alpha2/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
)

// ResourceStatus is the enumeration of the status of a DWS resource
// +kubebuilder:validation:Enum:=Starting;Ready;Disabled;NotPresent;Offline;Failed;Degraded;Unknown
// +kubebuilder:validation:Enum:=Starting;Ready;Disabled;NotPresent;Offline;Failed;Degraded;Drained;Unknown
type ResourceStatus string

const (
Expand All @@ -56,7 +56,7 @@ const (
NotPresentStatus ResourceStatus = "NotPresent"

// Offline means the resource is offline and cannot be communicated with. This differs
// fro the NotPresent state in that the resource is known to exist.
// from the NotPresent state in that the resource is known to exist.
OfflineStatus ResourceStatus = "Offline"

// Failed means the resource has failed during startup or execution.
Expand All @@ -66,6 +66,9 @@ const (
// recovery actions may alleviate a degraded status.
DegradedStatus ResourceStatus = "Degraded"

// Drained means the resource has had its pods drained from the node.
DrainedStatus ResourceStatus = "Drained"

// Unknown means the resource status is unknown.
UnknownStatus ResourceStatus = "Unknown"
)
3 changes: 2 additions & 1 deletion api/v1alpha2/servers_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var serverslog = logf.Log.WithName("servers-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *Servers) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/storage_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var storagelog = logf.Log.WithName("storage-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *Storage) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha2/systemconfiguration_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Hewlett Packard Enterprise Development LP
* Copyright 2023-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 @@ -27,6 +27,7 @@ import (
// log is for logging in this package.
var systemconfigurationlog = logf.Log.WithName("systemconfiguration-resource")

// SetupWebhookWithManager will setup the manager to manage the webhooks
func (r *SystemConfiguration) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
31 changes: 20 additions & 11 deletions api/v1alpha2/webhook_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021-2023.
Copyright 2021-2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@ import (
"fmt"
"net"
"path/filepath"
"runtime"
"testing"
"time"

Expand All @@ -30,8 +31,8 @@ import (

admissionv1 "k8s.io/api/admission/v1"
//+kubebuilder:scaffold:imports
"k8s.io/apimachinery/pkg/runtime"
// "k8s.io/client-go/rest"
apimachineryruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
Expand All @@ -44,7 +45,7 @@ import (
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.

// var cfg *rest.Config
var cfg *rest.Config
var k8sClient client.Client
var testEnv *envtest.Environment
var ctx context.Context
Expand All @@ -65,16 +66,27 @@ var _ = BeforeSuite(func() {
testEnv = &envtest.Environment{
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: false,

// The BinaryAssetsDirectory is only required if you want to run the tests directly
// without call the makefile target test. If not informed it will look for the
// default path defined in controller-runtime which is /usr/local/kubebuilder/.
// Note that you must have the required binaries setup under the bin directory to perform
// the tests directly. When we run make test it will be setup and used automatically.
BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s",
fmt.Sprintf("1.29.0-%s-%s", runtime.GOOS, runtime.GOARCH)),

WebhookInstallOptions: envtest.WebhookInstallOptions{
Paths: []string{filepath.Join("..", "..", "config", "webhook")},
},
}

cfg, err := testEnv.Start()
var err error
// cfg is defined in this file globally.
cfg, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

scheme := runtime.NewScheme()
scheme := apimachineryruntime.NewScheme()
err = AddToScheme(scheme)
Expect(err).NotTo(HaveOccurred())

Expand Down Expand Up @@ -109,9 +121,7 @@ var _ = BeforeSuite(func() {
go func() {
defer GinkgoRecover()
err = mgr.Start(ctx)
if err != nil {
Expect(err).NotTo(HaveOccurred())
}
Expect(err).NotTo(HaveOccurred())
}()

// wait for the webhook server to get ready
Expand All @@ -122,8 +132,7 @@ var _ = BeforeSuite(func() {
if err != nil {
return err
}
conn.Close()
return nil
return conn.Close()
}).Should(Succeed())

})
Expand Down
8 changes: 6 additions & 2 deletions api/v1alpha2/workflow_webhook.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Hewlett Packard Enterprise Development LP
* Copyright 2021-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 @@ -44,14 +44,16 @@ var workflowlog = logf.Log.WithName("workflow-resource")

var c client.Client

// SetupWebhookWithManager connects the webhook with the manager
// SetupWebhookWithManager will setup the manager to manage the webhooks
func (w *Workflow) SetupWebhookWithManager(mgr ctrl.Manager) error {
c = mgr.GetClient()
return ctrl.NewWebhookManagedBy(mgr).
For(w).
Complete()
}

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-dataworkflowservices-github-io-v1alpha2-workflow,mutating=true,failurePolicy=fail,sideEffects=None,groups=dataworkflowservices.github.io,resources=workflows,verbs=create,versions=v1alpha2,name=mworkflow.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Defaulter = &Workflow{}
Expand All @@ -71,6 +73,8 @@ func (w *Workflow) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
// NOTE: The 'path' attribute must follow a specific pattern and should not be modified directly here.
// Modifying the path for an invalid path can cause API server errors; failing to locate the webhook.
//+kubebuilder:webhook:path=/validate-dataworkflowservices-github-io-v1alpha2-workflow,mutating=false,failurePolicy=fail,sideEffects=None,groups=dataworkflowservices.github.io,resources=workflows,verbs=create;update,versions=v1alpha2,name=vworkflow.kb.io,admissionReviewVersions={v1,v1beta1}

var _ webhook.Validator = &Workflow{}
Expand Down
8 changes: 7 additions & 1 deletion api/v1alpha2/workflow_webhook_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021, 2022 Hewlett Packard Enterprise Development LP
* Copyright 2021-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 @@ -33,6 +33,12 @@ import (
// http://onsi.github.io/ginkgo to learn more.

var _ = Describe("Workflow Webhook", func() {

// We already have api/<spoke_ver>/conversion_test.go that is
// digging deep into the conversion routines, and we have
// internal/controllers/conversion_test.go that is verifing that the
// conversion webhook is hooked up to those routines.

var (
workflow *Workflow
)
Expand Down
4 changes: 2 additions & 2 deletions config/craystack/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resources:
- ../default

patchesStrategicMerge:
patches:
# Arguments for the controller manager that are specific to craystack
- manager_environment_patch.yaml
- path: manager_environment_patch.yaml

4 changes: 4 additions & 0 deletions config/crd/bases/dataworkflowservices.github.io_storages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ spec:
- Offline
- Failed
- Degraded
- Drained
- Unknown
type: string
type: object
Expand Down Expand Up @@ -326,6 +327,7 @@ spec:
- Offline
- Failed
- Degraded
- Drained
- Unknown
type: string
type: object
Expand Down Expand Up @@ -374,6 +376,7 @@ spec:
- Offline
- Failed
- Degraded
- Drained
- Unknown
type: string
wearLevel:
Expand Down Expand Up @@ -403,6 +406,7 @@ spec:
- Offline
- Failed
- Degraded
- Drained
- Unknown
type: string
type:
Expand Down
Loading

0 comments on commit 0d2c6ad

Please sign in to comment.