From 461c015273d1a50e8e34573b6477b77dcd531f12 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sun, 12 Apr 2020 13:15:56 +0300 Subject: [PATCH] Add artifact type to API --- api/v1alpha1/artifact.go | 41 +++++++++++++++++++ api/v1alpha1/condition_types.go | 16 ++++++++ api/v1alpha1/gitrepository_types.go | 9 ++-- api/v1alpha1/helmrepository_types.go | 9 ++-- api/v1alpha1/zz_generated.deepcopy.go | 30 +++++++++++--- .../source.fluxcd.io_gitrepositories.yaml | 34 +++++++++++---- .../source.fluxcd.io_helmrepositories.yaml | 31 +++++++++++--- 7 files changed, 141 insertions(+), 29 deletions(-) create mode 100644 api/v1alpha1/artifact.go diff --git a/api/v1alpha1/artifact.go b/api/v1alpha1/artifact.go new file mode 100644 index 00000000..7f58e48e --- /dev/null +++ b/api/v1alpha1/artifact.go @@ -0,0 +1,41 @@ +/* +Copyright 2020 The Flux CD contributors. + +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 v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// Artifact represents the output of a source synchronisation +type Artifact struct { + // Path is the local file path of this artifact. + // +required + Path string `json:"path"` + + // URL is the HTTP address of this artifact. + // +required + URL string `json:"url"` + + // Revision is a human readable identifier traceable in the origin source system. + // It can be a commit sha, git tag, a helm index timestamp, + // a helm chart version, a checksum, etc. + // +optional + Revision string `json:"revision"` + + // LastUpdateTime is the timestamp corresponding to the last + // update of this artifact. + // +required + LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` +} diff --git a/api/v1alpha1/condition_types.go b/api/v1alpha1/condition_types.go index cbfecb1f..b9ea19b9 100644 --- a/api/v1alpha1/condition_types.go +++ b/api/v1alpha1/condition_types.go @@ -1,3 +1,19 @@ +/* +Copyright 2020 The Flux CD contributors. + +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 v1alpha1 import ( diff --git a/api/v1alpha1/gitrepository_types.go b/api/v1alpha1/gitrepository_types.go index 5ae44276..44ad82fa 100644 --- a/api/v1alpha1/gitrepository_types.go +++ b/api/v1alpha1/gitrepository_types.go @@ -67,14 +67,13 @@ type GitRepositoryStatus struct { // +optional Conditions []SourceCondition `json:"conditions,omitempty"` - // LastUpdateTime is the timestamp corresponding to the last status - // change of this repository. + // URL is the download link for the artifact output of the last repository sync. // +optional - LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + URL string `json:"url,omitempty"` - // Path to the artifact output of the last repository sync. + // Artifact represents the output of the last successful repository sync. // +optional - Artifact string `json:"artifacts,omitempty"` + Artifact *Artifact `json:"artifact,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1alpha1/helmrepository_types.go b/api/v1alpha1/helmrepository_types.go index 7b85081a..8c239abe 100644 --- a/api/v1alpha1/helmrepository_types.go +++ b/api/v1alpha1/helmrepository_types.go @@ -37,14 +37,13 @@ type HelmRepositoryStatus struct { // +optional Conditions []SourceCondition `json:"conditions,omitempty"` - // LastUpdateTime is the timestamp corresponding to the last status - // change of this repository. + // URL is the download link for the last index fetched. // +optional - LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + URL string `json:"url,omitempty"` - // Path to the artifact of the last repository index. + // Artifact represents the output of the last successful repository sync. // +optional - Artifact string `json:"artifact,omitempty"` + Artifact *Artifact `json:"artifact,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index ded75ecb..f8388374 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -25,6 +25,22 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Artifact) DeepCopyInto(out *Artifact) { + *out = *in + in.LastUpdateTime.DeepCopyInto(&out.LastUpdateTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Artifact. +func (in *Artifact) DeepCopy() *Artifact { + if in == nil { + return nil + } + out := new(Artifact) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitRepository) DeepCopyInto(out *GitRepository) { *out = *in @@ -135,9 +151,10 @@ func (in *GitRepositoryStatus) DeepCopyInto(out *GitRepositoryStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.LastUpdateTime != nil { - in, out := &in.LastUpdateTime, &out.LastUpdateTime - *out = (*in).DeepCopy() + if in.Artifact != nil { + in, out := &in.Artifact, &out.Artifact + *out = new(Artifact) + (*in).DeepCopyInto(*out) } } @@ -236,9 +253,10 @@ func (in *HelmRepositoryStatus) DeepCopyInto(out *HelmRepositoryStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.LastUpdateTime != nil { - in, out := &in.LastUpdateTime, &out.LastUpdateTime - *out = (*in).DeepCopy() + if in.Artifact != nil { + in, out := &in.Artifact, &out.Artifact + *out = new(Artifact) + (*in).DeepCopyInto(*out) } } diff --git a/config/crd/bases/source.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.fluxcd.io_gitrepositories.yaml index 92c7cf37..ebb3c7a5 100644 --- a/config/crd/bases/source.fluxcd.io_gitrepositories.yaml +++ b/config/crd/bases/source.fluxcd.io_gitrepositories.yaml @@ -93,9 +93,30 @@ spec: status: description: GitRepositoryStatus defines the observed state of GitRepository properties: - artifacts: - description: Path to the artifact output of the last repository sync. - type: string + artifact: + description: Artifact represents the output of the last successful repository + sync. + properties: + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to the + last update of this artifact. + format: date-time + type: string + path: + description: Path is the local file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable in + the origin source system. It can be a commit sha, git tag, a helm + index timestamp, a helm chart version, a checksum, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object conditions: items: description: SourceCondition contains condition information for a @@ -126,10 +147,9 @@ spec: - type type: object type: array - lastUpdateTime: - description: LastUpdateTime is the timestamp corresponding to the last - status change of this repository. - format: date-time + url: + description: URL is the download link for the artifact output of the + last repository sync. type: string type: object type: object diff --git a/config/crd/bases/source.fluxcd.io_helmrepositories.yaml b/config/crd/bases/source.fluxcd.io_helmrepositories.yaml index 17854da9..458b14c7 100644 --- a/config/crd/bases/source.fluxcd.io_helmrepositories.yaml +++ b/config/crd/bases/source.fluxcd.io_helmrepositories.yaml @@ -64,8 +64,29 @@ spec: description: HelmRepositoryStatus defines the observed state of HelmRepository properties: artifact: - description: Path to the artifact of the last repository index. - type: string + description: Artifact represents the output of the last successful repository + sync. + properties: + lastUpdateTime: + description: LastUpdateTime is the timestamp corresponding to the + last update of this artifact. + format: date-time + type: string + path: + description: Path is the local file path of this artifact. + type: string + revision: + description: Revision is a human readable identifier traceable in + the origin source system. It can be a commit sha, git tag, a helm + index timestamp, a helm chart version, a checksum, etc. + type: string + url: + description: URL is the HTTP address of this artifact. + type: string + required: + - path + - url + type: object conditions: items: description: SourceCondition contains condition information for a @@ -96,10 +117,8 @@ spec: - type type: object type: array - lastUpdateTime: - description: LastUpdateTime is the timestamp corresponding to the last - status change of this repository. - format: date-time + url: + description: URL is the download link for the last index fetched. type: string type: object type: object