Skip to content

Commit

Permalink
Merge pull request #2130 from shiftstack/imagecontroller
Browse files Browse the repository at this point in the history
✨ OpenStackImage controller
  • Loading branch information
k8s-ci-robot authored Aug 13, 2024
2 parents 6701f61 + 3090a6c commit 90da86d
Show file tree
Hide file tree
Showing 147 changed files with 25,714 additions and 243 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ linters-settings:
sections:
- standard
- default
- prefix(github.com/k-orc/openstack-resource-controller)
- prefix(sigs.k8s.io/cluster-api-provider-openstack)
gocritic:
enabled-tags:
Expand Down Expand Up @@ -130,6 +131,9 @@ linters-settings:
alias: controlplanev1alpha4
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
alias: controlplanev1
# ORC
- pkg: github.com/k-orc/openstack-resource-controller/api/v1alpha1
alias: orcv1alpha1

nolintlint:
# https://github.com/golangci/golangci-lint/issues/3228
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ ARG goproxy=https://proxy.golang.org
ENV GOPROXY=$goproxy

# Copy the Go Modules manifests
RUN mkdir orc
COPY go.mod go.mod
COPY go.sum go.sum
COPY orc/go.mod orc/go.mod
COPY orc/go.sum orc/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
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ TEST_PATHS ?= ./...
test: $(ARTIFACTS) $(GOTESTSUM) kubebuilder_assets
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.test.xml --junitfile-hide-empty-pkg --jsonfile $(ARTIFACTS)/test-output.log -- \
-v $(TEST_PATHS) $(TEST_ARGS)
$(MAKE) -C $(REPO_ROOT)/orc test

E2E_TEMPLATES_DIR=test/e2e/data/infrastructure-openstack
E2E_KUSTOMIZE_DIR=test/e2e/data/kustomize
Expand Down Expand Up @@ -250,10 +251,12 @@ $(GO_APIDIFF): # Build go-apidiff.
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Lint codebase
$(GOLANGCI_LINT) run -v --fast=false
$(MAKE) -C $(REPO_ROOT)/orc lint

.PHONY: lint-update
lint-update: $(GOLANGCI_LINT) ## Lint codebase
$(GOLANGCI_LINT) run -v --fast=false --fix
$(MAKE) -C $(REPO_ROOT)/orc lint-fix

lint-fast: $(GOLANGCI_LINT) ## Run only faster linters to detect possible issues
$(GOLANGCI_LINT) run -v --fast=true
Expand All @@ -264,11 +267,13 @@ lint-fast: $(GOLANGCI_LINT) ## Run only faster linters to detect possible issues

.PHONY: modules
modules: ## Runs go mod to ensure proper vendoring.
$(MAKE) -C $(REPO_ROOT)/orc modules
go mod tidy
cd $(TOOLS_DIR); go mod tidy
cd $(REPO_ROOT)/hack/codegen; go mod tidy

.PHONY: generate
generate: templates generate-controller-gen generate-codegen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code
generate: templates generate-orc generate-controller-gen generate-codegen generate-conversion-gen generate-go generate-manifests generate-api-docs ## Generate all generated code

.PHONY: generate-go
generate-go: $(MOCKGEN)
Expand All @@ -280,9 +285,14 @@ generate-controller-gen: $(CONTROLLER_GEN)
paths=./api/... \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt

.PHONY: generate-codegen
generate-codegen: generate-controller-gen
./hack/update-codegen.sh

.PHONY: generate-orc
generate-orc:
$(MAKE) -C $(REPO_ROOT)/orc generate

.PHONY: generate-conversion-gen
capo_module := sigs.k8s.io/cluster-api-provider-openstack
generate-conversion-gen: $(CONVERSION_GEN)
Expand All @@ -308,6 +318,7 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
paths=./ \
paths=./controllers/... \
paths=./internal/controllers/... \
output:rbac:dir=$(RBAC_ROOT) \
rbac:roleName=manager-role

Expand Down
7 changes: 4 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ resources:
kind: OpenStackClusterTemplate
version: v1alpha7
- group: infrastructure
version: v1beta1
kind: OpenStackCluster
- group: infrastructure
version: v1beta1
kind: OpenStackMachine
- group: infrastructure
kind: OpenStackMachine
version: v1beta1
- group: infrastructure
kind: OpenStackMachineTemplate
version: v1beta1
- group: infrastructure
kind: OpenStackClusterTemplate
version: v1beta1
Expand All @@ -47,4 +47,5 @@ resources:
- group: infrastructure
kind: OpenStackServer
version: v1alpha1
- group: infrastructure
version: "2"
2 changes: 2 additions & 0 deletions api/v1beta1/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
InstanceDeleteFailedReason = "InstanceDeleteFailed"
// OpenstackErrorReason used when there is an error communicating with OpenStack.
OpenStackErrorReason = "OpenStackError"
// DependencyFailedReason indicates that a dependent object failed.
DependencyFailedReason = "DependencyFailed"
)

const (
Expand Down
13 changes: 12 additions & 1 deletion api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ type OpenStackMachineTemplateResource struct {
Spec OpenStackMachineSpec `json:"spec"`
}

// ImageParam describes a glance image. It can be specified by ID or filter.
type ResourceReference struct {
// Name is the name of the referenced resource
Name string `json:"name"`
}

// ImageParam describes a glance image. It can be specified by ID, filter, or a
// reference to an ORC Image.
// +kubebuilder:validation:MaxProperties:=1
// +kubebuilder:validation:MinProperties:=1
type ImageParam struct {
Expand All @@ -42,6 +48,11 @@ type ImageParam struct {
// be raised.
// +optional
Filter *ImageFilter `json:"filter,omitempty"`

// ImageRef is a reference to an ORC Image in the same namespace as the
// referring object.
// +optional
ImageRef *ResourceReference `json:"imageRef,omitempty"`
}

// ImageFilter describes a query for an image.
Expand Down
20 changes: 20 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

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

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

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

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

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

3 changes: 3 additions & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ resources:
- ../webhook
- ../certmanager

# ORC
- ../../orc/config/crd

patches:
# Provide customizable hook for make targets.
- path: manager_image_patch.yaml
Expand Down
20 changes: 20 additions & 0 deletions config/rbac/role.yaml

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

25 changes: 25 additions & 0 deletions controllers/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

// This file provides a minimal exported interface to non-exported controllers

import (
imagecontroller "sigs.k8s.io/cluster-api-provider-openstack/internal/controllers/image"
)

var ImageController = imagecontroller.New
Loading

0 comments on commit 90da86d

Please sign in to comment.