-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from fluxcd/kustomize-api
Introduce Kustomize API group
- Loading branch information
Showing
7 changed files
with
894 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
VER?=0.0.1 | ||
MODULES=$(shell find . -mindepth 2 -maxdepth 4 -type f -name 'go.mod' | cut -c 3- | sed 's|/[^/]*$$||' | sort -u | tr / :) | ||
targets=$(addprefix test-, $(MODULES)) | ||
root_dir=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
all: | ||
$(MAKE) $(targets) | ||
|
@@ -14,7 +22,10 @@ fmt-%: | |
vet-%: | ||
cd $(subst :,/,$*); go vet ./... | ||
|
||
test-%: tidy-% fmt-% vet-% | ||
generate-%: controller-gen | ||
cd $(subst :,/,$*); $(CONTROLLER_GEN) object:headerFile="$(root_dir)/hack/boilerplate.go.txt" paths="./..." | ||
|
||
test-%: generate-% tidy-% fmt-% vet-% | ||
cd $(subst :,/,$*); go test ./... -coverprofile cover.out | ||
|
||
release-%: | ||
|
@@ -24,3 +35,19 @@ release-%: | |
git pull | ||
git tag "$(REL_PATH)/v$(VER)" | ||
git push origin "$(REL_PATH)/v$(VER)" | ||
|
||
# Find or download controller-gen | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ | ||
cd $$CONTROLLER_GEN_TMP_DIR ;\ | ||
go mod init tmp ;\ | ||
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif |
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,20 @@ | ||
/* | ||
Copyright 2021 The Flux 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 kustomize contains a selective set of Kustomize APIs for use by | ||
// toolkit components. | ||
// +kubebuilder:object:generate=true | ||
package kustomize |
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 @@ | ||
module github.com/fluxcd/pkg/apis/kustomize | ||
|
||
go 1.15 | ||
|
||
require k8s.io/apiextensions-apiserver v0.20.2 |
Large diffs are not rendered by default.
Oops, something went wrong.
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,115 @@ | ||
/* | ||
Copyright 2021 The Flux 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 kustomize | ||
|
||
import ( | ||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
) | ||
|
||
// Image contains an image name, a new name, a new tag or digest, | ||
// which will replace the original name and tag. | ||
type Image struct { | ||
// Name is a tag-less image name. | ||
// +required | ||
Name string `json:"name"` | ||
|
||
// NewName is the value used to replace the original name. | ||
// +optional | ||
NewName string `json:"newName,omitempty"` | ||
|
||
// NewTag is the value used to replace the original tag. | ||
// +optional | ||
NewTag string `json:"newTag,omitempty"` | ||
|
||
// Digest is the value used to replace the original image tag. | ||
// If digest is present NewTag value is ignored. | ||
// +optional | ||
Digest string `json:"digest,omitempty"` | ||
} | ||
|
||
// Selector specifies a set of resources. | ||
// Any resource that matches intersection of all conditions is included in this set. | ||
type Selector struct { | ||
// Group is the API group to select resources from. | ||
// Together with Version and Kind it is capable of unambiguously | ||
// identifying and/or selecting resources. | ||
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md | ||
// +optional | ||
Group string `json:"group,omitempty"` | ||
|
||
// Version of the API Group to select resources from. | ||
// Together with Group and Kind it is capable of unambiguously | ||
// identifying and/or selecting resources. | ||
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md | ||
// +optional | ||
Version string `json:"version,omitempty"` | ||
|
||
// Kind of the API Group to select resources from. | ||
// Together with Group and Version it is capable of unambiguously | ||
// identifying and/or selecting resources. | ||
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md | ||
// +optional | ||
Kind string `json:"kind,omitempty"` | ||
|
||
// Namespace to select resources from. | ||
// +optional | ||
Namespace string `json:"namespace,omitempty"` | ||
|
||
// Name to match resources with. | ||
// +optional | ||
Name string `json:"name,omitempty"` | ||
|
||
// AnnotationSelector is a string that follows the label selection expression | ||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api | ||
// It matches with the resource annotations. | ||
// +optional | ||
AnnotationSelector string `json:"annotationSelector,omitempty"` | ||
|
||
// LabelSelector is a string that follows the label selection expression | ||
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api | ||
// It matches with the resource labels. | ||
// +optional | ||
LabelSelector string `json:"labelSelector,omitempty"` | ||
} | ||
|
||
// JSON6902 is a JSON6902 operation object. | ||
// https://tools.ietf.org/html/rfc6902#section-4 | ||
type JSON6902 struct { | ||
// +kubebuilder:validation:Enum=test;remove;add;replace;move;copy | ||
// +required | ||
Op string `json:"op"` | ||
// +required | ||
Path string `json:"path"` | ||
// +optional | ||
From string `json:"from,omitempty"` | ||
// +optional | ||
Value *apiextensionsv1.JSON `json:"value,omitempty"` | ||
} | ||
|
||
// JSON6902Patch contains a JSON6902 patch and the target the patch | ||
// should be applied to. | ||
type JSON6902Patch struct { | ||
// Patch contains the JSON6902 patch document with an array of | ||
// operation objects. | ||
// +required | ||
Patch []JSON6902 `json:"patch"` | ||
|
||
// Target points to the resources that the patch document should | ||
// be applied to. | ||
// +required | ||
Target Selector `json:"target"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
/* | ||
Copyright 2021 The Flux 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. | ||
*/ |