generated from giantswarm/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* drop apiextensions * remove unused * add changelog * use released apiextensions-application * replace jwt-go * replace etcd
- Loading branch information
Showing
26 changed files
with
1,702 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Directories. | ||
API_DIR := api | ||
CRD_DIR := config/crd | ||
SCRIPTS_DIR := hack | ||
TOOLS_DIR := $(SCRIPTS_DIR)/tools | ||
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) | ||
|
||
# Binaries. | ||
# Need to use abspath so we can invoke these from subdirectories | ||
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen) | ||
|
||
BUILD_COLOR = "" | ||
GEN_COLOR = "" | ||
NO_COLOR = "" | ||
|
||
ifneq (, $(shell command -v tput)) | ||
ifeq ($(shell test `tput colors` -ge 8 && echo "yes"), yes) | ||
BUILD_COLOR = \033[0;34m | ||
GEN_COLOR = \033[0;32m | ||
NO_COLOR = \033[0m | ||
endif | ||
endif | ||
|
||
DEEPCOPY_BASE = zz_generated.deepcopy | ||
MODULE = $(shell go list -m) | ||
BOILERPLATE = $(SCRIPTS_DIR)/boilerplate.go.txt | ||
YEAR = $(shell date +'%Y') | ||
|
||
DEEPCOPY_FILES := $(shell find $(API_DIR) -name $(DEEPCOPY_BASE).go) | ||
|
||
all: generate | ||
|
||
$(CONTROLLER_GEN): $(TOOLS_DIR)/controller-gen/go.mod | ||
@echo "$(BUILD_COLOR)Building controller-gen$(NO_COLOR)" | ||
cd $(TOOLS_DIR)/controller-gen \ | ||
&& go build -tags=tools -o $(CONTROLLER_GEN) sigs.k8s.io/controller-tools/cmd/controller-gen | ||
|
||
.PHONY: generate | ||
generate: | ||
@$(MAKE) generate-deepcopy | ||
@$(MAKE) generate-manifests | ||
|
||
.PHONY: verify | ||
verify: | ||
@$(MAKE) clean-generated | ||
@$(MAKE) generate | ||
git diff --exit-code | ||
|
||
.PHONY: generate-deepcopy | ||
generate-deepcopy: $(CONTROLLER_GEN) | ||
@echo "$(GEN_COLOR)Generating deepcopy$(NO_COLOR)" | ||
$(CONTROLLER_GEN) \ | ||
object:headerFile=$(BOILERPLATE),year=$(YEAR) \ | ||
paths=./$(API_DIR)/... | ||
|
||
.PHONY: generate-manifests | ||
generate-manifests: $(CONTROLLER_GEN) | ||
@echo "$(GEN_COLOR)Generating CRDs$(NO_COLOR)" | ||
$(CONTROLLER_GEN) \ | ||
crd \ | ||
paths=./$(API_DIR)/... \ | ||
output:dir="./$(CRD_DIR)" | ||
|
||
.PHONY: clean-generated | ||
clean-generated: | ||
@echo "$(GEN_COLOR)Cleaning generated files$(NO_COLOR)" | ||
rm -rf $(CRD_DIR) $(DEEPCOPY_FILES) | ||
|
||
.PHONY: clean-tools | ||
clean-tools: | ||
@echo "$(GEN_COLOR)Cleaning tools$(NO_COLOR)" | ||
rm -rf $(TOOLS_BIN_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
// +kubebuilder:storageversion | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:resource:categories=common;config;giantswarm | ||
// +k8s:openapi-gen=true | ||
|
||
// Config represents configuration of an App. | ||
type Config struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
Spec ConfigSpec `json:"spec"` | ||
// +kubebuilder:validation:Optional | ||
// Status part of the Config resource. | ||
Status ConfigStatus `json:"status,omitempty"` | ||
} | ||
|
||
// ConfigSpec is the spec part for the Config resource. | ||
// +k8s:openapi-gen=true | ||
type ConfigSpec struct { | ||
// App details for which the configuration should be generated. | ||
App ConfigSpecApp `json:"app"` | ||
} | ||
|
||
// ConfigSpecApp holds the information about the App to be configured. | ||
// +k8s:openapi-gen=true | ||
type ConfigSpecApp struct { | ||
// Name is the name of the App. | ||
Name string `json:"name"` | ||
// Version is the version of the App. | ||
Version string `json:"version"` | ||
// Catalog is the name of the App's App Catalog. | ||
Catalog string `json:"catalog"` | ||
} | ||
|
||
// ConfigStatus holds status information about the generated configuration. | ||
// +k8s:openapi-gen=true | ||
type ConfigStatus struct { | ||
// +kubebuilder:validation:Optional | ||
// App details for which the configuration was generated. | ||
App ConfigStatusApp `json:"app,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// Config holds the references to the generated configuration. | ||
Config ConfigStatusConfig `json:"config,omitempty"` | ||
// +kubebuilder:validation:Optional | ||
// Version of the giantswarm/config repository used to generate the | ||
// configuration. | ||
Version string `json:"version,omitempty"` | ||
} | ||
|
||
// ConfigStatusApp holds the information about the App used to generate | ||
// referenced configuration. | ||
// +k8s:openapi-gen=true | ||
type ConfigStatusApp struct { | ||
// Name is the name of the App. | ||
Name string `json:"name"` | ||
// Version is the version of the App. | ||
Version string `json:"version"` | ||
// Catalog is the name of the App's App Catalog. | ||
Catalog string `json:"catalog"` | ||
} | ||
|
||
// ConfigStatusConfig holds configuration ConfigMap and Secret references to be | ||
// used to configure the App. | ||
// +k8s:openapi-gen=true | ||
type ConfigStatusConfig struct { | ||
ConfigMapRef ConfigStatusConfigConfigMapRef `json:"configMapRef"` | ||
SecretRef ConfigStatusConfigSecretRef `json:"secretRef"` | ||
} | ||
|
||
// ConfigStatusConfigConfigMapRef contains a reference to the generated ConfigMap. | ||
// +k8s:openapi-gen=true | ||
type ConfigStatusConfigConfigMapRef struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
} | ||
|
||
// ConfigStatusConfigSecretRef contains a reference to the generated Secret. | ||
// +k8s:openapi-gen=true | ||
type ConfigStatusConfigSecretRef struct { | ||
Name string `json:"name"` | ||
Namespace string `json:"namespace"` | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
type ConfigList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
Items []Config `json:"items"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package v1alpha1 | ||
|
||
import "testing" | ||
|
||
func Test_Config_Spec_Status_App(t *testing.T) { | ||
t.Log("ensure ConfigSpecApp ConfigStatusApp have identical fields") | ||
specApp := ConfigSpecApp{} | ||
_ = ConfigStatusApp(specApp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// +k8s:openapi-gen=true | ||
// +k8s:deepcopy-gen=package,register | ||
|
||
// +groupName=core.giantswarm.io | ||
package v1alpha1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const ( | ||
group = "core.giantswarm.io" | ||
version = "v1alpha1" | ||
) | ||
|
||
// knownTypes is the full list of objects to register with the scheme. It | ||
// should contain all zero values of custom objects and custom object lists | ||
// in the group version. | ||
var knownTypes = []runtime.Object{ | ||
&Config{}, | ||
&ConfigList{}, | ||
} | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{ | ||
Group: group, | ||
Version: version, | ||
} | ||
|
||
var ( | ||
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
|
||
// AddToScheme is used by the generated client. | ||
AddToScheme = schemeBuilder.AddToScheme | ||
) | ||
|
||
// Adds the list of known types to api.Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, knownTypes...) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
Oops, something went wrong.