Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Moving api -> apis and setting multigroup: true #26

Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Build the manager binary
FROM golang:1.15 as builder

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 main.go main.go
COPY apis/ apis/
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager 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 .
USER 65532:65532

ENTRYPOINT ["/manager"]
1 change: 1 addition & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
domain: cluster.x-k8s.io
layout: go.kubebuilder.io/v3
projectName: cluster-api-provider-nested
multigroup: true
repo: sigs.k8s.io/cluster-api-provider-nested
resources:
- group: controlplane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

controlplanev1alpha4 "sigs.k8s.io/cluster-api-provider-nested/api/v1alpha4"
controlplanev1alpha4 "sigs.k8s.io/cluster-api-provider-nested/apis/controlplane/v1alpha4"
)

// NestedControlPlaneReconciler reconciles a NestedControlPlane object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

controlplanev1alpha4 "sigs.k8s.io/cluster-api-provider-nested/api/v1alpha4"
controlplanev1alpha4 "sigs.k8s.io/cluster-api-provider-nested/apis/controlplane/v1alpha4"
// +kubebuilder:scaffold:imports
)

Expand Down
17 changes: 15 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog"
"k8s.io/klog/klogr"
Expand All @@ -34,6 +35,9 @@ import (
"sigs.k8s.io/cluster-api/util"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"

controlplanev1alpha4 "sigs.k8s.io/cluster-api-provider-nested/apis/controlplane/v1alpha4"
controlplanecontrollers "sigs.k8s.io/cluster-api-provider-nested/controllers/controlplane"
// +kubebuilder:scaffold:imports
)

Expand All @@ -56,8 +60,9 @@ var (
func init() {
klog.InitFlags(nil)

_ = clientgoscheme.AddToScheme(scheme)
_ = clusterv1.AddToScheme(scheme)
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
utilruntime.Must(controlplanev1alpha4.AddToScheme(scheme))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utilruntime.Must() will fail if the types aren't loaded.

// +kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -141,6 +146,14 @@ func main() {
}

// TODO(community): Register controllers and webhooks here.
if err = (&controlplanecontrollers.NestedControlPlaneReconciler{
Client: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("controlplane").WithName("NestedControlPlane"),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "NestedControlPlane")
os.Exit(1)
}

// +kubebuilder:scaffold:builder
setupLog.Info("Starting manager", "version", version.Get().String())
Expand Down