Skip to content

Commit 51dea22

Browse files
authored
Merge pull request #1056 from fluxcd/gitrepository-v1
GA: Promote GitRepository API to `source.toolkit.fluxcd.io/v1`
2 parents 98ebc9f + f2da9bf commit 51dea22

File tree

66 files changed

+4115
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4115
-1314
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ manifests: controller-gen ## Generate manifests, e.g. CRD, RBAC, etc.
117117
cd api; $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config="../config/crd/bases"
118118

119119
api-docs: gen-crd-api-reference-docs ## Generate API reference documentation
120-
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/source.md
120+
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1beta2 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1beta2/source.md
121+
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/v1/source.md
121122

122123
tidy: ## Run go mod tidy
123124
cd api; rm -f go.sum; go mod tidy -compat=1.20

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
domain: toolkit.fluxcd.io
22
repo: github.com/fluxcd/source-controller
33
resources:
4+
- group: source
5+
kind: GitRepository
6+
version: v1
47
- group: source
58
kind: GitRepository
69
version: v1beta2

api/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.18
44

55
require (
66
github.com/fluxcd/pkg/apis/acl v0.1.0
7-
github.com/fluxcd/pkg/apis/meta v0.19.1
8-
k8s.io/apimachinery v0.26.2
7+
github.com/fluxcd/pkg/apis/meta v1.0.0
8+
k8s.io/apimachinery v0.26.3
99
sigs.k8s.io/controller-runtime v0.14.5
1010
)
1111

api/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/fluxcd/pkg/apis/acl v0.1.0 h1:EoAl377hDQYL3WqanWCdifauXqXbMyFuK82NnX6pH4Q=
55
github.com/fluxcd/pkg/apis/acl v0.1.0/go.mod h1:zfEZzz169Oap034EsDhmCAGgnWlcWmIObZjYMusoXS8=
6-
github.com/fluxcd/pkg/apis/meta v0.19.1 h1:fCI5CnTXpAqr67UlaI9q0H+OztMKB5kDTr6xV6vlAo0=
7-
github.com/fluxcd/pkg/apis/meta v0.19.1/go.mod h1:ZPPMYrPnWwPQYNEGM/Uc0N4SurUPS3xNI3IIpCQEfuM=
6+
github.com/fluxcd/pkg/apis/meta v1.0.0 h1:i9IGHd/VNEZELX7mepkiYFbJxs2J5znaB4cN9z2nPm8=
7+
github.com/fluxcd/pkg/apis/meta v1.0.0/go.mod h1:04ZdpZYm1x+aL93K4daNHW1UX6E8K7Gyf5za9OhrE+U=
88
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
99
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
1010
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -74,8 +74,8 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
7474
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
7575
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
7676
k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ=
77-
k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ=
78-
k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
77+
k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k=
78+
k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
7979
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=
8080
k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
8181
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y=

api/v1/artifact_types.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
Copyright 2023 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"path"
21+
"strings"
22+
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
)
25+
26+
// Artifact represents the output of a Source reconciliation.
27+
type Artifact struct {
28+
// Path is the relative file path of the Artifact. It can be used to locate
29+
// the file in the root of the Artifact storage on the local file system of
30+
// the controller managing the Source.
31+
// +required
32+
Path string `json:"path"`
33+
34+
// URL is the HTTP address of the Artifact as exposed by the controller
35+
// managing the Source. It can be used to retrieve the Artifact for
36+
// consumption, e.g. by another controller applying the Artifact contents.
37+
// +required
38+
URL string `json:"url"`
39+
40+
// Revision is a human-readable identifier traceable in the origin source
41+
// system. It can be a Git commit SHA, Git tag, a Helm chart version, etc.
42+
// +required
43+
Revision string `json:"revision"`
44+
45+
// Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
46+
// +optional
47+
// +kubebuilder:validation:Pattern="^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
48+
Digest string `json:"digest,omitempty"`
49+
50+
// LastUpdateTime is the timestamp corresponding to the last update of the
51+
// Artifact.
52+
// +required
53+
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
54+
55+
// Size is the number of bytes in the file.
56+
// +optional
57+
Size *int64 `json:"size,omitempty"`
58+
59+
// Metadata holds upstream information such as OCI annotations.
60+
// +optional
61+
Metadata map[string]string `json:"metadata,omitempty"`
62+
}
63+
64+
// HasRevision returns if the given revision matches the current Revision of
65+
// the Artifact.
66+
func (in *Artifact) HasRevision(revision string) bool {
67+
if in == nil {
68+
return false
69+
}
70+
return in.Revision == revision
71+
}
72+
73+
// HasDigest returns if the given digest matches the current Digest of the
74+
// Artifact.
75+
func (in *Artifact) HasDigest(digest string) bool {
76+
if in == nil {
77+
return false
78+
}
79+
return in.Digest == digest
80+
}
81+
82+
// ArtifactDir returns the artifact dir path in the form of
83+
// '<kind>/<namespace>/<name>'.
84+
func ArtifactDir(kind, namespace, name string) string {
85+
kind = strings.ToLower(kind)
86+
return path.Join(kind, namespace, name)
87+
}
88+
89+
// ArtifactPath returns the artifact path in the form of
90+
// '<kind>/<namespace>/name>/<filename>'.
91+
func ArtifactPath(kind, namespace, name, filename string) string {
92+
return path.Join(ArtifactDir(kind, namespace, name), filename)
93+
}

api/v1/condition_types.go

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
Copyright 2023 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
const SourceFinalizer = "finalizers.fluxcd.io"
20+
21+
const (
22+
// ArtifactInStorageCondition indicates the availability of the Artifact in
23+
// the storage.
24+
// If True, the Artifact is stored successfully.
25+
// This Condition is only present on the resource if the Artifact is
26+
// successfully stored.
27+
ArtifactInStorageCondition string = "ArtifactInStorage"
28+
29+
// ArtifactOutdatedCondition indicates the current Artifact of the Source
30+
// is outdated.
31+
// This is a "negative polarity" or "abnormal-true" type, and is only
32+
// present on the resource if it is True.
33+
ArtifactOutdatedCondition string = "ArtifactOutdated"
34+
35+
// SourceVerifiedCondition indicates the integrity verification of the
36+
// Source.
37+
// If True, the integrity check succeeded. If False, it failed.
38+
// This Condition is only present on the resource if the integrity check
39+
// is enabled.
40+
SourceVerifiedCondition string = "SourceVerified"
41+
42+
// FetchFailedCondition indicates a transient or persistent fetch failure
43+
// of an upstream Source.
44+
// If True, observations on the upstream Source revision may be impossible,
45+
// and the Artifact available for the Source may be outdated.
46+
// This is a "negative polarity" or "abnormal-true" type, and is only
47+
// present on the resource if it is True.
48+
FetchFailedCondition string = "FetchFailed"
49+
50+
// BuildFailedCondition indicates a transient or persistent build failure
51+
// of a Source's Artifact.
52+
// If True, the Source can be in an ArtifactOutdatedCondition.
53+
// This is a "negative polarity" or "abnormal-true" type, and is only
54+
// present on the resource if it is True.
55+
BuildFailedCondition string = "BuildFailed"
56+
57+
// StorageOperationFailedCondition indicates a transient or persistent
58+
// failure related to storage. If True, the reconciliation failed while
59+
// performing some filesystem operation.
60+
// This is a "negative polarity" or "abnormal-true" type, and is only
61+
// present on the resource if it is True.
62+
StorageOperationFailedCondition string = "StorageOperationFailed"
63+
)
64+
65+
// Reasons are provided as utility, and not part of the declarative API.
66+
const (
67+
// URLInvalidReason signals that a given Source has an invalid URL.
68+
URLInvalidReason string = "URLInvalid"
69+
70+
// AuthenticationFailedReason signals that a Secret does not have the
71+
// required fields, or the provided credentials do not match.
72+
AuthenticationFailedReason string = "AuthenticationFailed"
73+
74+
// VerificationError signals that the Source's verification
75+
// check failed.
76+
VerificationError string = "VerificationError"
77+
78+
// DirCreationFailedReason signals a failure caused by a directory creation
79+
// operation.
80+
DirCreationFailedReason string = "DirectoryCreationFailed"
81+
82+
// StatOperationFailedReason signals a failure caused by a stat operation on
83+
// a path.
84+
StatOperationFailedReason string = "StatOperationFailed"
85+
86+
// ReadOperationFailedReason signals a failure caused by a read operation.
87+
ReadOperationFailedReason string = "ReadOperationFailed"
88+
89+
// AcquireLockFailedReason signals a failure in acquiring lock.
90+
AcquireLockFailedReason string = "AcquireLockFailed"
91+
92+
// InvalidPathReason signals a failure caused by an invalid path.
93+
InvalidPathReason string = "InvalidPath"
94+
95+
// ArchiveOperationFailedReason signals a failure in archive operation.
96+
ArchiveOperationFailedReason string = "ArchiveOperationFailed"
97+
98+
// SymlinkUpdateFailedReason signals a failure in updating a symlink.
99+
SymlinkUpdateFailedReason string = "SymlinkUpdateFailed"
100+
101+
// ArtifactUpToDateReason signals that an existing Artifact is up-to-date
102+
// with the Source.
103+
ArtifactUpToDateReason string = "ArtifactUpToDate"
104+
105+
// CacheOperationFailedReason signals a failure in cache operation.
106+
CacheOperationFailedReason string = "CacheOperationFailed"
107+
)

api/v1/doc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright 2023 The Flux authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1 contains API Schema definitions for the source v1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=source.toolkit.fluxcd.io
20+
package v1

0 commit comments

Comments
 (0)