Skip to content

Commit

Permalink
Add Red Hat OpenShift Operator Bundle (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
arybolovlev authored Feb 18, 2025
1 parent a82dbaa commit 61caba5
Show file tree
Hide file tree
Showing 49 changed files with 456 additions and 185 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ terraform.tfstate*

# Dependency directories (remove the comment below to include it)
# vendor/

# OLM Bundle
bundle.Dockerfile
bundle/
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ ENV BIN_NAME=$BIN_NAME
LABEL name="HCP Terraform Operator"
LABEL vendor="HashiCorp"
LABEL release=$PRODUCT_REVISION
LABEL summary="HCP Terraform Operator for Kubernetes allows managing HCP Terraform / Terraform Enterprise resources via Kubernetes Custom Resources"
LABEL description="HCP Terraform Operator for Kubernetes allows managing HCP Terraform / Terraform Enterprise resources via Kubernetes Custom Resources"
LABEL summary="HCP Terraform Operator for Kubernetes allows managing HCP Terraform / Terraform Enterprise resources via Kubernetes Custom Resources."
LABEL description="HCP Terraform Operator for Kubernetes allows managing HCP Terraform / Terraform Enterprise resources via Kubernetes Custom Resources."

LABEL maintainer="Terraform Ecosystem - Hybrid Cloud Team <[email protected]>"
LABEL maintainer="HashiCorp <[email protected]>"
LABEL version=$PRODUCT_VERSION
LABEL revision=$PRODUCT_REVISION

Expand Down
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# hashicorp/hcp-terraform-operator-bundle:$VERSION and hashicorp/hcp-terraform-operator-catalog:$VERSION.
IMAGE_TAG_BASE ?= hashicorp/hcp-terraform-operator
IMAGE_TAG_BASE ?= registry.connect.redhat.com/hashicorp/hcp-terraform-operator

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
Expand All @@ -41,7 +41,7 @@ BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
# USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
# You can enable this value if you would like to use SHA Based Digests
# To enable set flag to true
USE_IMAGE_DIGESTS ?= false
USE_IMAGE_DIGESTS ?= true
ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif
Expand Down Expand Up @@ -112,9 +112,9 @@ helm-test: test-helm ## Run Helm chart tests. This is an alias for the test-helm

.PHONY: manifests
manifests: controller-gen docs ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." \
$(CONTROLLER_GEN) crd paths="./..." \
output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." \
$(CONTROLLER_GEN) crd paths="./..." \
output:crd:artifacts:config=charts/hcp-terraform-operator/crds
$(MAKE) copywrite

Expand Down Expand Up @@ -243,6 +243,7 @@ CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs-$(CRD_REF_DOCS_VERSION)
HELM_DOCS ?= $(LOCALBIN)/helm-docs-$(HELM_DOCS_VERSION)
HASHICORP_COPYWRITE ?= $(LOCALBIN)/copywrite-$(HASHICORP_COPYWRITE_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
YQ = $(LOCALBIN)/yq-$(YQ_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
Expand All @@ -252,6 +253,7 @@ CRD_REF_DOCS_VERSION ?= v0.1.0
HELM_DOCS_VERSION ?= v1.14.2
HASHICORP_COPYWRITE_VERSION ?= v0.19.0
GOLANGCI_LINT_VERSION ?= v1.61.0
YQ_VERSION ?= v4.44.3

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand All @@ -271,7 +273,7 @@ $(ENVTEST): $(LOCALBIN)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

.PHONY: crd-ref-docs
crd-ref-docs: $(CRD_REF_DOCS) ## Download crd-ref-docs locally if necessary.
Expand All @@ -288,6 +290,12 @@ install-copywrite: $(HASHICORP_COPYWRITE) ## Download HashiCorp copywrite locall
$(HASHICORP_COPYWRITE): $(LOCALBIN)
$(call go-install-tool,$(HASHICORP_COPYWRITE),github.com/hashicorp/copywrite,$(HASHICORP_COPYWRITE_VERSION))

.PHONY: yq
yq: $(YQ) ## Download yq locally if necessary.
$(YQ): $(LOCALBIN)
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,$(YQ_VERSION))
ln -s $(YQ) $(LOCALBIN)/yq

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
Expand Down Expand Up @@ -320,10 +328,11 @@ endif
endif

.PHONY: bundle
bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files.
bundle: manifests kustomize operator-sdk yq ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS)
./hack/add-bundle-annotations.sh
$(OPERATOR_SDK) bundle validate ./bundle

.PHONY: bundle-build
Expand All @@ -334,6 +343,11 @@ bundle-build: ## Build the bundle image.
bundle-push: ## Push the bundle image.
$(MAKE) docker-push IMG=$(BUNDLE_IMG)

.PHONY: bundle-clean
bundle-clean: ## Clean the bundle artifacts.
@rm -fr bundle/
@rm -f bundle.Dockerfile

.PHONY: opm
OPM = $(LOCALBIN)/opm
opm: ## Download opm locally if necessary.
Expand Down
1 change: 0 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
componentConfig: true
domain: terraform.io
layout:
- go.kubebuilder.io/v4
Expand Down
6 changes: 5 additions & 1 deletion api/v1alpha2/agentpool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ type AgentPoolStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// AgentPool is the Schema for the agentpools API.
// AgentPool manages HCP Terraform Agent Pools, HCP Terraform Agent Tokens and can perform HCP Terraform Agent scaling.
// More infromation:
// - https://developer.hashicorp.com/terraform/cloud-docs/agents/agent-pools
// - https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens#agent-api-tokens
// - https://developer.hashicorp.com/terraform/cloud-docs/agents
type AgentPool struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha2/module_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ type ModuleStatus struct {
//+kubebuilder:printcolumn:name="CV Status",type=string,JSONPath=`.status.configurationVersion.status`
//+kubebuilder:printcolumn:name="Run Status",type=string,JSONPath=`.status.run.status`

// Module is the Schema for the modules API
// Module implements the API-driven Run Workflow
// Module implements API-driven Run Workflows.
// More information:
// - https://developer.hashicorp.com/terraform/cloud-docs/run/api
type Module struct {
Expand Down
4 changes: 3 additions & 1 deletion api/v1alpha2/project_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ type ProjectStatus struct {
//+kubebuilder:printcolumn:name="Project Name",type=string,JSONPath=`.status.name`
//+kubebuilder:printcolumn:name="Project ID",type=string,JSONPath=`.status.id`

// Project is the Schema for the projects API
// Project manages HCP Terraform Projects.
// More information:
// - https://developer.hashicorp.com/terraform/cloud-docs/projects/manage
type Project struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion api/v1alpha2/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ type WorkspaceStatus struct {
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Workspace ID",type=string,JSONPath=`.status.workspaceID`

// Workspace is the Schema for the workspaces API
// Workspace manages HCP Terraform Workspaces.
// More information:
// - https://developer.hashicorp.com/terraform/cloud-docs/workspaces
type Workspace struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ spec:
- name: v1alpha2
schema:
openAPIV3Schema:
description: AgentPool is the Schema for the agentpools API.
description: |-
AgentPool manages HCP Terraform Agent Pools, HCP Terraform Agent Tokens and can perform HCP Terraform Agent scaling.
More infromation:
- https://developer.hashicorp.com/terraform/cloud-docs/agents/agent-pools
- https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens#agent-api-tokens
- https://developer.hashicorp.com/terraform/cloud-docs/agents
properties:
apiVersion:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ spec:
schema:
openAPIV3Schema:
description: |-
Module is the Schema for the modules API
Module implements the API-driven Run Workflow
Module implements API-driven Run Workflows.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/run/api
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ spec:
name: v1alpha2
schema:
openAPIV3Schema:
description: Project is the Schema for the projects API
description: |-
Project manages HCP Terraform Projects.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/projects/manage
properties:
apiVersion:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ spec:
name: v1alpha2
schema:
openAPIV3Schema:
description: Workspace is the Schema for the workspaces API
description: |-
Workspace manages HCP Terraform Workspaces.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/workspaces
properties:
apiVersion:
description: |-
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/app.terraform.io_agentpools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ spec:
- name: v1alpha2
schema:
openAPIV3Schema:
description: AgentPool is the Schema for the agentpools API.
description: |-
AgentPool manages HCP Terraform Agent Pools, HCP Terraform Agent Tokens and can perform HCP Terraform Agent scaling.
More infromation:
- https://developer.hashicorp.com/terraform/cloud-docs/agents/agent-pools
- https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens#agent-api-tokens
- https://developer.hashicorp.com/terraform/cloud-docs/agents
properties:
apiVersion:
description: |-
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/app.terraform.io_modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ spec:
schema:
openAPIV3Schema:
description: |-
Module is the Schema for the modules API
Module implements the API-driven Run Workflow
Module implements API-driven Run Workflows.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/run/api
properties:
Expand Down
5 changes: 4 additions & 1 deletion config/crd/bases/app.terraform.io_projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ spec:
name: v1alpha2
schema:
openAPIV3Schema:
description: Project is the Schema for the projects API
description: |-
Project manages HCP Terraform Projects.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/projects/manage
properties:
apiVersion:
description: |-
Expand Down
5 changes: 4 additions & 1 deletion config/crd/bases/app.terraform.io_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ spec:
name: v1alpha2
schema:
openAPIV3Schema:
description: Workspace is the Schema for the workspaces API
description: |-
Workspace manages HCP Terraform Workspaces.
More information:
- https://developer.hashicorp.com/terraform/cloud-docs/workspaces
properties:
apiVersion:
description: |-
Expand Down
8 changes: 5 additions & 3 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resources:
- bases/app.terraform.io_projects.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_workspaces.yaml
Expand All @@ -25,6 +25,8 @@ patchesStrategicMerge:
#- patches/cainjection_in_projects.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

#configurations:
#- kustomizeconfig.yaml
Loading

0 comments on commit 61caba5

Please sign in to comment.