Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to kubebuilder multigroup support #207

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY apis/ apis/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY third_party/ third_party/
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ e2e: manager manifests verify-license goe2e

# Runs e2e tests (expects a configured cluster)
goe2e:
KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test --tags=e2e ./controllers/test
KUBEBUILDER_ASSETS="$(ROOT)/bin/$(PLATFORM)/" go test --tags=e2e ./controllers/datadoghq/test

# Build manager binary
.PHONY: manager
Expand Down Expand Up @@ -178,7 +178,7 @@ install-tools: bin/$(PLATFORM)/golangci-lint bin/$(PLATFORM)/operator-sdk bin/$(

.PHONY: generate-openapi
generate-openapi: bin/$(PLATFORM)/openapi-gen
bin/$(PLATFORM)/openapi-gen --logtostderr=true -o "" -i ./api/v1alpha1 -O zz_generated.openapi -p ./api/v1alpha1 -h ./hack/boilerplate.go.txt -r "-"
bin/$(PLATFORM)/openapi-gen --logtostderr=true -o "" -i ./apis/datadoghq/v1alpha1 -O zz_generated.openapi -p ./apis/datadoghq/v1alpha1 -h ./hack/boilerplate.go.txt -r "-"

.PHONY: patch-crds
patch-crds: bin/$(PLATFORM)/yq
Expand Down
28 changes: 20 additions & 8 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
domain: datadoghq.com
layout: go.kubebuilder.io/v2
layout:
- go.kubebuilder.io/v3
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: watermarkpodautoscaler
repo: github.com/DataDog/watermarkpodautoscaler
resources:
-
# TODO(user): Uncomment the below line if this resource implements a controller, else delete it.
# controller: true
- api:
crdVersion: v1
namespaced: true
controller: true
domain: datadoghq.com
group: datadoghq
kind: WatermarkPodAutoscaler
# TODO(user): Update the package path for your API if the below value is incorrect.
path: github.com/DataDog/watermarkpodautoscaler/api/v1alpha1
path: github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: datadoghq.com
group: datadoghq
kind: RecommendWatermarkPodAutoscaler
path: github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1
version: v1alpha1
version: "3"
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package test
import (
"time"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down

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

2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.23.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v2
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ metadata:
]
capabilities: Basic Install
operators.operatorframework.io/builder: operator-sdk-v1.23.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: watermarkpodautoscaler.v0.5.2
namespace: placeholder
spec:
Expand Down
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ annotations:
operators.operatorframework.io.bundle.channel.default.v1: alpha
operators.operatorframework.io.metrics.builder: operator-sdk-v1.23.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v2
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

# Annotations for testing.
operators.operatorframework.io.test.mediatype.v1: scorecard+v1
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-wpa/app/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
)

// NewClient returns new client instance.
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-wpa/app/dryrun/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/cmd/kubectl-wpa/app/common"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ metadata:
]
capabilities: Basic Install
operators.operatorframework.io/builder: operator-sdk-v1.23.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
name: watermarkpodautoscaler.v0.6.0-rc.1
namespace: placeholder
spec:
Expand Down
2 changes: 2 additions & 0 deletions controllers/datadoghq/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package datadoghq containers all the WatermarkPodAutoscaler controller logic.
package datadoghq
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package controllers
package datadoghq

import (
"context"

datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/pkg/util"
logr "github.com/go-logr/logr"
)
Expand Down
4 changes: 2 additions & 2 deletions controllers/metrics.go → controllers/datadoghq/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package controllers
package datadoghq

import (
"os"
"strings"

datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"

"github.com/prometheus/client_golang/prometheus"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package controllers
package datadoghq

import (
"fmt"
"math"
"strings"
"time"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/pkg/math32"

metricsclient "github.com/DataDog/watermarkpodautoscaler/third_party/kubernetes/pkg/controller/podautoscaler/metrics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package controllers
package datadoghq

import (
"fmt"
"testing"
"time"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/third_party/kubernetes/pkg/controller/podautoscaler/metrics"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
Expand All @@ -27,9 +28,9 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/controllers"
"github.com/DataDog/watermarkpodautoscaler/controllers/test/utils"
datadoghqv1alpha1 "github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
controllers "github.com/DataDog/watermarkpodautoscaler/controllers/datadoghq"
"github.com/DataDog/watermarkpodautoscaler/controllers/datadoghq/test/utils"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -68,7 +69,7 @@ var _ = BeforeSuite(func(done Done) {
By("bootstrapping test environment")
testEnv = &envtest.Environment{
UseExistingCluster: datadoghqv1alpha1.NewBool(testConfig.useExistingCluster),
CRDDirectoryPaths: []string{filepath.Join("../..", "config", "crd", "bases", testConfig.crdVersion)},
CRDDirectoryPaths: []string{filepath.Join("../../..", "config", "crd", "bases", testConfig.crdVersion)},
}

// Not present in envtest.Environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/api/v1alpha1/test"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1"
"github.com/DataDog/watermarkpodautoscaler/apis/datadoghq/v1alpha1/test"
)

var _ = Describe("WatermarkPodAutoscaler Controller", func() {
Expand Down
Loading
Loading