Refactor to adopt k8s standardized Condition type
Updates to use metav1.Condition type and removes references for deprecated corev1.Condition* constants and uses the new k8s api/meta helpers in place of the old pkg/apis/meta types. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
parent
35c6fd7884
commit
00bb853d0e
|
@ -3,7 +3,7 @@ module github.com/fluxcd/source-controller/api
|
|||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0
|
||||
k8s.io/api v0.19.3
|
||||
k8s.io/apimachinery v0.19.3
|
||||
sigs.k8s.io/controller-runtime v0.6.3
|
||||
|
|
|
@ -63,6 +63,8 @@ github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
|
|||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0 h1:bxoFQtZM6OLLj0+n3h6ga7IEWUtGEDJPc65OWiXSMvY=
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0/go.mod h1:50RLLSfqM4LlQrh/+5LiJVf7Hjdthee8WDdXBvpjBdA=
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0 h1:o2YkfGgf0j8sKeZs8cBmmmMKLA7kEoS1qYViOial1Ds=
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0/go.mod h1:wOzQQx8CdtUQCGaLzqGu4QgnNxYkI6/wvdvlovxWhF0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
|
|
|
@ -19,6 +19,7 @@ package v1beta1
|
|||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -85,7 +86,7 @@ type BucketStatus struct {
|
|||
|
||||
// Conditions holds the conditions for the Bucket.
|
||||
// +optional
|
||||
Conditions []meta.Condition `json:"conditions,omitempty"`
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// URL is the download link for the artifact output of the last Bucket sync.
|
||||
// +optional
|
||||
|
@ -106,22 +107,22 @@ const (
|
|||
BucketOperationFailedReason string = "BucketOperationFailed"
|
||||
)
|
||||
|
||||
// BucketProgressing resets the conditions of the Bucket to meta.Condition of
|
||||
// BucketProgressing resets the conditions of the Bucket to metav1.Condition of
|
||||
// type meta.ReadyCondition with status 'Unknown' and meta.ProgressingReason
|
||||
// reason and message. It returns the modified Bucket.
|
||||
func BucketProgressing(bucket Bucket) Bucket {
|
||||
bucket.Status.ObservedGeneration = bucket.Generation
|
||||
bucket.Status.URL = ""
|
||||
bucket.Status.Conditions = []meta.Condition{}
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, corev1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
bucket.Status.Conditions = []metav1.Condition{}
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
return bucket
|
||||
}
|
||||
|
||||
// SetBucketCondition sets the given condition with the given status, reason and
|
||||
// message on the Bucket.
|
||||
func SetBucketCondition(bucket *Bucket, conditionType string, status corev1.ConditionStatus, reason, message string) {
|
||||
func SetBucketCondition(bucket *Bucket, conditionType string, status metav1.ConditionStatus, reason, message string) {
|
||||
bucket.Status.Conditions = meta.FilterOutCondition(bucket.Status.Conditions, conditionType)
|
||||
bucket.Status.Conditions = append(bucket.Status.Conditions, meta.Condition{
|
||||
bucket.Status.Conditions = append(bucket.Status.Conditions, metav1.Condition{
|
||||
Type: conditionType,
|
||||
Status: status,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
|
@ -136,22 +137,22 @@ func SetBucketCondition(bucket *Bucket, conditionType string, status corev1.Cond
|
|||
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
|
||||
bucket.Status.Artifact = &artifact
|
||||
bucket.Status.URL = url
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, corev1.ConditionTrue, reason, message)
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||
return bucket
|
||||
}
|
||||
|
||||
// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
|
||||
// the given reason and message. It returns the modified Bucket.
|
||||
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, corev1.ConditionFalse, reason, message)
|
||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||
return bucket
|
||||
}
|
||||
|
||||
// BucketReadyMessage returns the message of the meta.Condition of type
|
||||
// BucketReadyMessage returns the message of the metav1.Condition of type
|
||||
// meta.ReadyCondition with status 'True' if present, or an empty string.
|
||||
func BucketReadyMessage(bucket Bucket) string {
|
||||
if c := meta.GetCondition(bucket.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == corev1.ConditionTrue {
|
||||
if c := apimeta.FindStatusCondition(bucket.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == metav1.ConditionTrue {
|
||||
return c.Message
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package v1beta1
|
|||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -105,7 +106,7 @@ type GitRepositoryStatus struct {
|
|||
|
||||
// Conditions holds the conditions for the GitRepository.
|
||||
// +optional
|
||||
Conditions []meta.Condition `json:"conditions,omitempty"`
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// URL is the download link for the artifact output of the last repository
|
||||
// sync.
|
||||
|
@ -128,22 +129,22 @@ const (
|
|||
)
|
||||
|
||||
// GitRepositoryProgressing resets the conditions of the GitRepository to
|
||||
// meta.Condition of type meta.ReadyCondition with status 'Unknown' and
|
||||
// metav1.Condition of type meta.ReadyCondition with status 'Unknown' and
|
||||
// meta.ProgressingReason reason and message. It returns the modified
|
||||
// GitRepository.
|
||||
func GitRepositoryProgressing(repository GitRepository) GitRepository {
|
||||
repository.Status.ObservedGeneration = repository.Generation
|
||||
repository.Status.URL = ""
|
||||
repository.Status.Conditions = []meta.Condition{}
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
repository.Status.Conditions = []metav1.Condition{}
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
return repository
|
||||
}
|
||||
|
||||
// SetGitRepositoryCondition sets the given condition with the given status,
|
||||
// reason and message on the GitRepository.
|
||||
func SetGitRepositoryCondition(repository *GitRepository, condition string, status corev1.ConditionStatus, reason, message string) {
|
||||
func SetGitRepositoryCondition(repository *GitRepository, condition string, status metav1.ConditionStatus, reason, message string) {
|
||||
repository.Status.Conditions = meta.FilterOutCondition(repository.Status.Conditions, condition)
|
||||
repository.Status.Conditions = append(repository.Status.Conditions, meta.Condition{
|
||||
repository.Status.Conditions = append(repository.Status.Conditions, metav1.Condition{
|
||||
Type: condition,
|
||||
Status: status,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
|
@ -158,7 +159,7 @@ func SetGitRepositoryCondition(repository *GitRepository, condition string, stat
|
|||
func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason, message string) GitRepository {
|
||||
repository.Status.Artifact = &artifact
|
||||
repository.Status.URL = url
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionTrue, reason, message)
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||
return repository
|
||||
}
|
||||
|
||||
|
@ -166,15 +167,15 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason
|
|||
// to 'False', with the given reason and message. It returns the modified
|
||||
// GitRepository.
|
||||
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionFalse, reason, message)
|
||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||
return repository
|
||||
}
|
||||
|
||||
// GitRepositoryReadyMessage returns the message of the meta.Condition of type
|
||||
// GitRepositoryReadyMessage returns the message of the metav1.Condition of type
|
||||
// meta.ReadyCondition with status 'True' if present, or an empty string.
|
||||
func GitRepositoryReadyMessage(repository GitRepository) string {
|
||||
if c := meta.GetCondition(repository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == corev1.ConditionTrue {
|
||||
if c := apimeta.FindStatusCondition(repository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == metav1.ConditionTrue {
|
||||
return c.Message
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package v1beta1
|
|||
|
||||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -77,7 +77,7 @@ type HelmChartStatus struct {
|
|||
|
||||
// Conditions holds the conditions for the HelmChart.
|
||||
// +optional
|
||||
Conditions []meta.Condition `json:"conditions,omitempty"`
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// URL is the download link for the last chart pulled.
|
||||
// +optional
|
||||
|
@ -112,16 +112,16 @@ const (
|
|||
func HelmChartProgressing(chart HelmChart) HelmChart {
|
||||
chart.Status.ObservedGeneration = chart.Generation
|
||||
chart.Status.URL = ""
|
||||
chart.Status.Conditions = []meta.Condition{}
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, corev1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
chart.Status.Conditions = []metav1.Condition{}
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
return chart
|
||||
}
|
||||
|
||||
// SetHelmChartCondition sets the given condition with the given status, reason
|
||||
// and message on the HelmChart.
|
||||
func SetHelmChartCondition(chart *HelmChart, condition string, status corev1.ConditionStatus, reason, message string) {
|
||||
func SetHelmChartCondition(chart *HelmChart, condition string, status metav1.ConditionStatus, reason, message string) {
|
||||
chart.Status.Conditions = meta.FilterOutCondition(chart.Status.Conditions, condition)
|
||||
chart.Status.Conditions = append(chart.Status.Conditions, meta.Condition{
|
||||
chart.Status.Conditions = append(chart.Status.Conditions, metav1.Condition{
|
||||
Type: condition,
|
||||
Status: status,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
|
@ -136,7 +136,7 @@ func SetHelmChartCondition(chart *HelmChart, condition string, status corev1.Con
|
|||
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
|
||||
chart.Status.Artifact = &artifact
|
||||
chart.Status.URL = url
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, corev1.ConditionTrue, reason, message)
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||
return chart
|
||||
}
|
||||
|
||||
|
@ -144,15 +144,15 @@ func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message str
|
|||
// 'False', with the given reason and message. It returns the modified
|
||||
// HelmChart.
|
||||
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, corev1.ConditionFalse, reason, message)
|
||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||
return chart
|
||||
}
|
||||
|
||||
// HelmChartReadyMessage returns the message of the meta.ReadyCondition with
|
||||
// status 'True', or an empty string.
|
||||
func HelmChartReadyMessage(chart HelmChart) string {
|
||||
if c := meta.GetCondition(chart.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == corev1.ConditionTrue {
|
||||
if c := apimeta.FindStatusCondition(chart.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == metav1.ConditionTrue {
|
||||
return c.Message
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package v1beta1
|
|||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -63,7 +64,7 @@ type HelmRepositoryStatus struct {
|
|||
|
||||
// Conditions holds the conditions for the HelmRepository.
|
||||
// +optional
|
||||
Conditions []meta.Condition `json:"conditions,omitempty"`
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// URL is the download link for the last index fetched.
|
||||
// +optional
|
||||
|
@ -85,22 +86,22 @@ const (
|
|||
)
|
||||
|
||||
// HelmRepositoryProgressing resets the conditions of the HelmRepository to
|
||||
// meta.Condition of type meta.ReadyCondition with status 'Unknown' and
|
||||
// metav1.Condition of type meta.ReadyCondition with status 'Unknown' and
|
||||
// meta.ProgressingReason reason and message. It returns the modified
|
||||
// HelmRepository.
|
||||
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
|
||||
repository.Status.ObservedGeneration = repository.Generation
|
||||
repository.Status.URL = ""
|
||||
repository.Status.Conditions = []meta.Condition{}
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
repository.Status.Conditions = []metav1.Condition{}
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||
return repository
|
||||
}
|
||||
|
||||
// SetHelmRepositoryCondition sets the given condition with the given status,
|
||||
// reason and message on the HelmRepository.
|
||||
func SetHelmRepositoryCondition(repository *HelmRepository, condition string, status corev1.ConditionStatus, reason, message string) {
|
||||
func SetHelmRepositoryCondition(repository *HelmRepository, condition string, status metav1.ConditionStatus, reason, message string) {
|
||||
repository.Status.Conditions = meta.FilterOutCondition(repository.Status.Conditions, condition)
|
||||
repository.Status.Conditions = append(repository.Status.Conditions, meta.Condition{
|
||||
repository.Status.Conditions = append(repository.Status.Conditions, metav1.Condition{
|
||||
Type: condition,
|
||||
Status: status,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
|
@ -115,7 +116,7 @@ func SetHelmRepositoryCondition(repository *HelmRepository, condition string, st
|
|||
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
|
||||
repository.Status.Artifact = &artifact
|
||||
repository.Status.URL = url
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionTrue, reason, message)
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||
return repository
|
||||
}
|
||||
|
||||
|
@ -123,15 +124,15 @@ func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reas
|
|||
// HelmRepository to 'False', with the given reason and message. It returns the
|
||||
// modified HelmRepository.
|
||||
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, corev1.ConditionFalse, reason, message)
|
||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||
return repository
|
||||
}
|
||||
|
||||
// HelmRepositoryReadyMessage returns the message of the meta.Condition of type
|
||||
// HelmRepositoryReadyMessage returns the message of the metav1.Condition of type
|
||||
// meta.ReadyCondition with status 'True' if present, or an empty string.
|
||||
func HelmRepositoryReadyMessage(repository HelmRepository) string {
|
||||
if c := meta.GetCondition(repository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == corev1.ConditionTrue {
|
||||
if c := apimeta.FindStatusCondition(repository.Status.Conditions, meta.ReadyCondition); c != nil {
|
||||
if c.Status == metav1.ConditionTrue {
|
||||
return c.Message
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ limitations under the License.
|
|||
package v1beta1
|
||||
|
||||
import (
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
|
@ -138,7 +137,7 @@ func (in *BucketStatus) DeepCopyInto(out *BucketStatus) {
|
|||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]meta.Condition, len(*in))
|
||||
*out = make([]metav1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
|
@ -280,7 +279,7 @@ func (in *GitRepositoryStatus) DeepCopyInto(out *GitRepositoryStatus) {
|
|||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]meta.Condition, len(*in))
|
||||
*out = make([]metav1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
|
@ -399,7 +398,7 @@ func (in *HelmChartStatus) DeepCopyInto(out *HelmChartStatus) {
|
|||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]meta.Condition, len(*in))
|
||||
*out = make([]metav1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
|
@ -511,7 +510,7 @@ func (in *HelmRepositoryStatus) DeepCopyInto(out *HelmRepositoryStatus) {
|
|||
*out = *in
|
||||
if in.Conditions != nil {
|
||||
in, out := &in.Conditions, &out.Conditions
|
||||
*out = make([]meta.Condition, len(*in))
|
||||
*out = make([]metav1.Condition, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
|
|
|
@ -129,30 +129,69 @@ spec:
|
|||
conditions:
|
||||
description: Conditions holds the conditions for the Bucket.
|
||||
items:
|
||||
description: Condition contains condition information of a toolkit
|
||||
resource.
|
||||
description: "Condition contains details for one aspect of the current
|
||||
state of this API Resource. --- This struct is intended for direct
|
||||
use as an array at the field path .status.conditions. For example,
|
||||
type FooStatus struct{ // Represents the observations of a
|
||||
foo's current state. // Known .status.conditions.type are:
|
||||
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
|
||||
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
|
||||
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
|
||||
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
|
||||
\n // other fields }"
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding
|
||||
to the last status change of this condition.
|
||||
description: lastTransitionTime is the last time the condition
|
||||
transitioned from one status to another. This should be when
|
||||
the underlying condition changed. If that is not known, then
|
||||
using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: Message is a human readable description of the
|
||||
details of the last transition, complementing reason.
|
||||
description: message is a human readable message indicating
|
||||
details about the transition. This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: observedGeneration represents the .metadata.generation
|
||||
that the condition was set based upon. For instance, if .metadata.generation
|
||||
is currently 12, but the .status.conditions[x].observedGeneration
|
||||
is 9, the condition is out of date with respect to the current
|
||||
state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation
|
||||
for the condition's last transition.
|
||||
description: reason contains a programmatic identifier indicating
|
||||
the reason for the condition's last transition. Producers
|
||||
of specific condition types may define expected values and
|
||||
meanings for this field, and whether the values are considered
|
||||
a guaranteed API. The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of ('True', 'False',
|
||||
'Unknown').
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: Type of the condition.
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
--- Many .condition.type values are consistent across resources
|
||||
like Available, but because arbitrary conditions can be useful
|
||||
(see .node.status.conditions), the ability to deconflict is
|
||||
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
|
|
|
@ -157,30 +157,69 @@ spec:
|
|||
conditions:
|
||||
description: Conditions holds the conditions for the GitRepository.
|
||||
items:
|
||||
description: Condition contains condition information of a toolkit
|
||||
resource.
|
||||
description: "Condition contains details for one aspect of the current
|
||||
state of this API Resource. --- This struct is intended for direct
|
||||
use as an array at the field path .status.conditions. For example,
|
||||
type FooStatus struct{ // Represents the observations of a
|
||||
foo's current state. // Known .status.conditions.type are:
|
||||
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
|
||||
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
|
||||
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
|
||||
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
|
||||
\n // other fields }"
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding
|
||||
to the last status change of this condition.
|
||||
description: lastTransitionTime is the last time the condition
|
||||
transitioned from one status to another. This should be when
|
||||
the underlying condition changed. If that is not known, then
|
||||
using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: Message is a human readable description of the
|
||||
details of the last transition, complementing reason.
|
||||
description: message is a human readable message indicating
|
||||
details about the transition. This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: observedGeneration represents the .metadata.generation
|
||||
that the condition was set based upon. For instance, if .metadata.generation
|
||||
is currently 12, but the .status.conditions[x].observedGeneration
|
||||
is 9, the condition is out of date with respect to the current
|
||||
state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation
|
||||
for the condition's last transition.
|
||||
description: reason contains a programmatic identifier indicating
|
||||
the reason for the condition's last transition. Producers
|
||||
of specific condition types may define expected values and
|
||||
meanings for this field, and whether the values are considered
|
||||
a guaranteed API. The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of ('True', 'False',
|
||||
'Unknown').
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: Type of the condition.
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
--- Many .condition.type values are consistent across resources
|
||||
like Available, but because arbitrary conditions can be useful
|
||||
(see .node.status.conditions), the ability to deconflict is
|
||||
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
|
|
|
@ -133,30 +133,69 @@ spec:
|
|||
conditions:
|
||||
description: Conditions holds the conditions for the HelmChart.
|
||||
items:
|
||||
description: Condition contains condition information of a toolkit
|
||||
resource.
|
||||
description: "Condition contains details for one aspect of the current
|
||||
state of this API Resource. --- This struct is intended for direct
|
||||
use as an array at the field path .status.conditions. For example,
|
||||
type FooStatus struct{ // Represents the observations of a
|
||||
foo's current state. // Known .status.conditions.type are:
|
||||
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
|
||||
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
|
||||
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
|
||||
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
|
||||
\n // other fields }"
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding
|
||||
to the last status change of this condition.
|
||||
description: lastTransitionTime is the last time the condition
|
||||
transitioned from one status to another. This should be when
|
||||
the underlying condition changed. If that is not known, then
|
||||
using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: Message is a human readable description of the
|
||||
details of the last transition, complementing reason.
|
||||
description: message is a human readable message indicating
|
||||
details about the transition. This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: observedGeneration represents the .metadata.generation
|
||||
that the condition was set based upon. For instance, if .metadata.generation
|
||||
is currently 12, but the .status.conditions[x].observedGeneration
|
||||
is 9, the condition is out of date with respect to the current
|
||||
state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation
|
||||
for the condition's last transition.
|
||||
description: reason contains a programmatic identifier indicating
|
||||
the reason for the condition's last transition. Producers
|
||||
of specific condition types may define expected values and
|
||||
meanings for this field, and whether the values are considered
|
||||
a guaranteed API. The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of ('True', 'False',
|
||||
'Unknown').
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: Type of the condition.
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
--- Many .condition.type values are consistent across resources
|
||||
like Available, but because arbitrary conditions can be useful
|
||||
(see .node.status.conditions), the ability to deconflict is
|
||||
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
|
|
|
@ -108,30 +108,69 @@ spec:
|
|||
conditions:
|
||||
description: Conditions holds the conditions for the HelmRepository.
|
||||
items:
|
||||
description: Condition contains condition information of a toolkit
|
||||
resource.
|
||||
description: "Condition contains details for one aspect of the current
|
||||
state of this API Resource. --- This struct is intended for direct
|
||||
use as an array at the field path .status.conditions. For example,
|
||||
type FooStatus struct{ // Represents the observations of a
|
||||
foo's current state. // Known .status.conditions.type are:
|
||||
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
|
||||
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
|
||||
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
|
||||
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
|
||||
\n // other fields }"
|
||||
properties:
|
||||
lastTransitionTime:
|
||||
description: LastTransitionTime is the timestamp corresponding
|
||||
to the last status change of this condition.
|
||||
description: lastTransitionTime is the last time the condition
|
||||
transitioned from one status to another. This should be when
|
||||
the underlying condition changed. If that is not known, then
|
||||
using the time when the API field changed is acceptable.
|
||||
format: date-time
|
||||
type: string
|
||||
message:
|
||||
description: Message is a human readable description of the
|
||||
details of the last transition, complementing reason.
|
||||
description: message is a human readable message indicating
|
||||
details about the transition. This may be an empty string.
|
||||
maxLength: 32768
|
||||
type: string
|
||||
observedGeneration:
|
||||
description: observedGeneration represents the .metadata.generation
|
||||
that the condition was set based upon. For instance, if .metadata.generation
|
||||
is currently 12, but the .status.conditions[x].observedGeneration
|
||||
is 9, the condition is out of date with respect to the current
|
||||
state of the instance.
|
||||
format: int64
|
||||
minimum: 0
|
||||
type: integer
|
||||
reason:
|
||||
description: Reason is a brief machine readable explanation
|
||||
for the condition's last transition.
|
||||
description: reason contains a programmatic identifier indicating
|
||||
the reason for the condition's last transition. Producers
|
||||
of specific condition types may define expected values and
|
||||
meanings for this field, and whether the values are considered
|
||||
a guaranteed API. The value should be a CamelCase string.
|
||||
This field may not be empty.
|
||||
maxLength: 1024
|
||||
minLength: 1
|
||||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||
type: string
|
||||
status:
|
||||
description: Status of the condition, one of ('True', 'False',
|
||||
'Unknown').
|
||||
description: status of the condition, one of True, False, Unknown.
|
||||
enum:
|
||||
- "True"
|
||||
- "False"
|
||||
- Unknown
|
||||
type: string
|
||||
type:
|
||||
description: Type of the condition.
|
||||
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||
--- Many .condition.type values are consistent across resources
|
||||
like Available, but because arbitrary conditions can be useful
|
||||
(see .node.status.conditions), the ability to deconflict is
|
||||
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
|
||||
maxLength: 316
|
||||
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||
type: string
|
||||
required:
|
||||
- lastTransitionTime
|
||||
- message
|
||||
- reason
|
||||
- status
|
||||
- type
|
||||
type: object
|
||||
|
|
|
@ -31,6 +31,8 @@ import (
|
|||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
|
@ -211,7 +213,7 @@ func (r *BucketReconciler) reconcile(ctx context.Context, bucket sourcev1.Bucket
|
|||
|
||||
// return early on unchanged revision
|
||||
artifact := r.Storage.NewArtifactFor(bucket.Kind, bucket.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", revision))
|
||||
if meta.HasReadyCondition(bucket.Status.Conditions) && bucket.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if meta.InReadyCondition(bucket.Status.Conditions) && bucket.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if artifact.URL != bucket.GetArtifact().URL {
|
||||
r.Storage.SetArtifactURL(bucket.GetArtifact())
|
||||
bucket.Status.URL = r.Storage.SetHostname(bucket.Status.URL)
|
||||
|
@ -401,12 +403,12 @@ func (r *BucketReconciler) recordReadiness(bucket sourcev1.Bucket) {
|
|||
).Error(err, "unable to record readiness metric")
|
||||
return
|
||||
}
|
||||
if rc := meta.GetCondition(bucket.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
if rc := apimeta.FindStatusCondition(bucket.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, *rc, !bucket.DeletionTimestamp.IsZero())
|
||||
} else {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, meta.Condition{
|
||||
r.MetricsRecorder.RecordCondition(*objRef, metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: corev1.ConditionUnknown,
|
||||
Status: metav1.ConditionUnknown,
|
||||
}, !bucket.DeletionTimestamp.IsZero())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import (
|
|||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
"github.com/go-logr/logr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
|
@ -198,7 +200,7 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
|
|||
|
||||
// return early on unchanged revision
|
||||
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash.String()))
|
||||
if meta.HasReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if meta.InReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if artifact.URL != repository.GetArtifact().URL {
|
||||
r.Storage.SetArtifactURL(repository.GetArtifact())
|
||||
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
||||
|
@ -360,12 +362,12 @@ func (r *GitRepositoryReconciler) recordReadiness(repository sourcev1.GitReposit
|
|||
).Error(err, "unable to record readiness metric")
|
||||
return
|
||||
}
|
||||
if rc := meta.GetCondition(repository.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
if rc := apimeta.FindStatusCondition(repository.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, *rc, !repository.DeletionTimestamp.IsZero())
|
||||
} else {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, meta.Condition{
|
||||
r.MetricsRecorder.RecordCondition(*objRef, metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: corev1.ConditionUnknown,
|
||||
Status: metav1.ConditionUnknown,
|
||||
}, !repository.DeletionTimestamp.IsZero())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/config"
|
||||
|
@ -84,7 +83,7 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
|
||||
waitForReason string
|
||||
|
||||
expectStatus corev1.ConditionStatus
|
||||
expectStatus metav1.ConditionStatus
|
||||
expectMessage string
|
||||
expectRevision string
|
||||
}
|
||||
|
@ -157,7 +156,7 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
defer k8sClient.Delete(context.Background(), created)
|
||||
|
||||
got := &sourcev1.GitRepository{}
|
||||
var cond meta.Condition
|
||||
var cond metav1.Condition
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
for _, c := range got.Status.Conditions {
|
||||
|
@ -180,59 +179,59 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
reference: &sourcev1.GitRepositoryRef{Branch: "some-branch"},
|
||||
createRefs: []string{"refs/heads/some-branch"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "some-branch",
|
||||
}),
|
||||
Entry("branch non existing", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{Branch: "invalid-branch"},
|
||||
waitForReason: sourcev1.GitOperationFailedReason,
|
||||
expectStatus: corev1.ConditionFalse,
|
||||
expectStatus: metav1.ConditionFalse,
|
||||
expectMessage: "couldn't find remote ref",
|
||||
}),
|
||||
Entry("tag", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{Tag: "some-tag"},
|
||||
createRefs: []string{"refs/tags/some-tag"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "some-tag",
|
||||
}),
|
||||
Entry("tag non existing", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{Tag: "invalid-tag"},
|
||||
waitForReason: sourcev1.GitOperationFailedReason,
|
||||
expectStatus: corev1.ConditionFalse,
|
||||
expectStatus: metav1.ConditionFalse,
|
||||
expectMessage: "couldn't find remote ref",
|
||||
}),
|
||||
Entry("semver", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{SemVer: "1.0.0"},
|
||||
createRefs: []string{"refs/tags/v1.0.0"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "v1.0.0",
|
||||
}),
|
||||
Entry("semver range", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{SemVer: ">=0.1.0 <1.0.0"},
|
||||
createRefs: []string{"refs/tags/0.1.0", "refs/tags/0.1.1", "refs/tags/0.2.0", "refs/tags/1.0.0"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "0.2.0",
|
||||
}),
|
||||
Entry("mixed semver range", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{SemVer: ">=0.1.0 <1.0.0"},
|
||||
createRefs: []string{"refs/tags/0.1.0", "refs/tags/v0.1.1", "refs/tags/v0.2.0", "refs/tags/1.0.0"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "v0.2.0",
|
||||
}),
|
||||
Entry("semver invalid", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{SemVer: "1.2.3.4"},
|
||||
waitForReason: sourcev1.GitOperationFailedReason,
|
||||
expectStatus: corev1.ConditionFalse,
|
||||
expectStatus: metav1.ConditionFalse,
|
||||
expectMessage: "semver parse range error: improper constraint: 1.2.3.4",
|
||||
}),
|
||||
Entry("semver no match", refTestCase{
|
||||
reference: &sourcev1.GitRepositoryRef{SemVer: "1.0.0"},
|
||||
waitForReason: sourcev1.GitOperationFailedReason,
|
||||
expectStatus: corev1.ConditionFalse,
|
||||
expectStatus: metav1.ConditionFalse,
|
||||
expectMessage: "no match found for semver: 1.0.0",
|
||||
}),
|
||||
Entry("commit", refTestCase{
|
||||
|
@ -240,7 +239,7 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
Commit: "<commit>",
|
||||
},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "master",
|
||||
}),
|
||||
Entry("commit in branch", refTestCase{
|
||||
|
@ -250,7 +249,7 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
},
|
||||
createRefs: []string{"refs/heads/some-branch"},
|
||||
waitForReason: sourcev1.GitOperationSucceedReason,
|
||||
expectStatus: corev1.ConditionTrue,
|
||||
expectStatus: metav1.ConditionTrue,
|
||||
expectRevision: "some-branch",
|
||||
}),
|
||||
Entry("invalid commit", refTestCase{
|
||||
|
@ -259,7 +258,7 @@ var _ = Describe("GitRepositoryReconciler", func() {
|
|||
Commit: "invalid",
|
||||
},
|
||||
waitForReason: sourcev1.GitOperationFailedReason,
|
||||
expectStatus: corev1.ConditionFalse,
|
||||
expectStatus: metav1.ConditionFalse,
|
||||
expectMessage: "git commit 'invalid' not found: object not found",
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -33,6 +33,8 @@ import (
|
|||
"helm.sh/helm/v3/pkg/chartutil"
|
||||
"helm.sh/helm/v3/pkg/getter"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
|
@ -423,7 +425,7 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
|
|||
// Return early if the revision is still the same as the current chart artifact
|
||||
newArtifact := r.Storage.NewArtifactFor(chart.Kind, chart.ObjectMeta.GetObjectMeta(), helmChart.Metadata.Version,
|
||||
fmt.Sprintf("%s-%s.tgz", helmChart.Metadata.Name, helmChart.Metadata.Version))
|
||||
if !force && meta.HasReadyCondition(chart.Status.Conditions) && chart.GetArtifact().HasRevision(newArtifact.Revision) {
|
||||
if !force && meta.InReadyCondition(chart.Status.Conditions) && chart.GetArtifact().HasRevision(newArtifact.Revision) {
|
||||
if newArtifact.URL != artifact.URL {
|
||||
r.Storage.SetArtifactURL(chart.GetArtifact())
|
||||
chart.Status.URL = r.Storage.SetHostname(chart.Status.URL)
|
||||
|
@ -677,12 +679,12 @@ func (r *HelmChartReconciler) recordReadiness(chart sourcev1.HelmChart) {
|
|||
).Error(err, "unable to record readiness metric")
|
||||
return
|
||||
}
|
||||
if rc := meta.GetCondition(chart.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
if rc := apimeta.FindStatusCondition(chart.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, *rc, !chart.DeletionTimestamp.IsZero())
|
||||
} else {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, meta.Condition{
|
||||
r.MetricsRecorder.RecordCondition(*objRef, metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: corev1.ConditionUnknown,
|
||||
Status: metav1.ConditionUnknown,
|
||||
}, !chart.DeletionTimestamp.IsZero())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ var _ = Describe("HelmChartReconciler", func() {
|
|||
By("Expecting artifact")
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return meta.HasReadyCondition(got.Status.Conditions)
|
||||
return meta.InReadyCondition(got.Status.Conditions)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
Expect(got.Status.Artifact).ToNot(BeNil())
|
||||
})
|
||||
|
|
|
@ -28,6 +28,8 @@ import (
|
|||
"github.com/go-logr/logr"
|
||||
"helm.sh/helm/v3/pkg/getter"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
kuberecorder "k8s.io/client-go/tools/record"
|
||||
|
@ -202,7 +204,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
|
|||
repository.ObjectMeta.GetObjectMeta(),
|
||||
chartRepo.Index.Generated.Format(time.RFC3339Nano),
|
||||
fmt.Sprintf("index-%s.yaml", url.PathEscape(chartRepo.Index.Generated.Format(time.RFC3339Nano))))
|
||||
if meta.HasReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if meta.InReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||
if artifact.URL != repository.GetArtifact().URL {
|
||||
r.Storage.SetArtifactURL(repository.GetArtifact())
|
||||
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
||||
|
@ -334,12 +336,12 @@ func (r *HelmRepositoryReconciler) recordReadiness(repository sourcev1.HelmRepos
|
|||
).Error(err, "unable to record readiness metric")
|
||||
return
|
||||
}
|
||||
if rc := meta.GetCondition(repository.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
if rc := apimeta.FindStatusCondition(repository.Status.Conditions, meta.ReadyCondition); rc != nil {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, *rc, !repository.DeletionTimestamp.IsZero())
|
||||
} else {
|
||||
r.MetricsRecorder.RecordCondition(*objRef, meta.Condition{
|
||||
r.MetricsRecorder.RecordCondition(*objRef, metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: corev1.ConditionUnknown,
|
||||
Status: metav1.ConditionUnknown,
|
||||
}, !repository.DeletionTimestamp.IsZero())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ string
|
|||
<td>
|
||||
<code>metadata</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#objectmeta-v1-meta">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#objectmeta-v1-meta">
|
||||
Kubernetes meta/v1.ObjectMeta
|
||||
</a>
|
||||
</em>
|
||||
|
@ -136,7 +136,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -241,7 +241,7 @@ string
|
|||
<td>
|
||||
<code>metadata</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#objectmeta-v1-meta">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#objectmeta-v1-meta">
|
||||
Kubernetes meta/v1.ObjectMeta
|
||||
</a>
|
||||
</em>
|
||||
|
@ -279,7 +279,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -416,7 +416,7 @@ string
|
|||
<td>
|
||||
<code>metadata</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#objectmeta-v1-meta">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#objectmeta-v1-meta">
|
||||
Kubernetes meta/v1.ObjectMeta
|
||||
</a>
|
||||
</em>
|
||||
|
@ -555,7 +555,7 @@ string
|
|||
<td>
|
||||
<code>metadata</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#objectmeta-v1-meta">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#objectmeta-v1-meta">
|
||||
Kubernetes meta/v1.ObjectMeta
|
||||
</a>
|
||||
</em>
|
||||
|
@ -593,7 +593,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -726,7 +726,7 @@ string
|
|||
<td>
|
||||
<code>lastUpdateTime</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#time-v1-meta">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#time-v1-meta">
|
||||
Kubernetes meta/v1.Time
|
||||
</a>
|
||||
</em>
|
||||
|
@ -819,7 +819,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -908,8 +908,8 @@ int64
|
|||
<td>
|
||||
<code>conditions</code><br>
|
||||
<em>
|
||||
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition">
|
||||
[]github.com/fluxcd/pkg/apis/meta.Condition
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#condition-v1-meta">
|
||||
[]Kubernetes meta/v1.Condition
|
||||
</a>
|
||||
</em>
|
||||
</td>
|
||||
|
@ -1049,7 +1049,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -1170,8 +1170,8 @@ int64
|
|||
<td>
|
||||
<code>conditions</code><br>
|
||||
<em>
|
||||
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition">
|
||||
[]github.com/fluxcd/pkg/apis/meta.Condition
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#condition-v1-meta">
|
||||
[]Kubernetes meta/v1.Condition
|
||||
</a>
|
||||
</em>
|
||||
</td>
|
||||
|
@ -1243,7 +1243,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -1373,8 +1373,8 @@ int64
|
|||
<td>
|
||||
<code>conditions</code><br>
|
||||
<em>
|
||||
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition">
|
||||
[]github.com/fluxcd/pkg/apis/meta.Condition
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#condition-v1-meta">
|
||||
[]Kubernetes meta/v1.Condition
|
||||
</a>
|
||||
</em>
|
||||
</td>
|
||||
|
@ -1445,7 +1445,7 @@ string
|
|||
<td>
|
||||
<code>secretRef</code><br>
|
||||
<em>
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#localobjectreference-v1-core">
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#localobjectreference-v1-core">
|
||||
Kubernetes core/v1.LocalObjectReference
|
||||
</a>
|
||||
</em>
|
||||
|
@ -1524,8 +1524,8 @@ int64
|
|||
<td>
|
||||
<code>conditions</code><br>
|
||||
<em>
|
||||
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition">
|
||||
[]github.com/fluxcd/pkg/apis/meta.Condition
|
||||
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#condition-v1-meta">
|
||||
[]Kubernetes meta/v1.Condition
|
||||
</a>
|
||||
</em>
|
||||
</td>
|
||||
|
|
4
go.mod
4
go.mod
|
@ -6,11 +6,11 @@ replace github.com/fluxcd/source-controller/api => ./api
|
|||
|
||||
require (
|
||||
github.com/Masterminds/semver/v3 v3.1.0
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0
|
||||
github.com/fluxcd/pkg/gittestserver v0.0.2
|
||||
github.com/fluxcd/pkg/helmtestserver v0.0.1
|
||||
github.com/fluxcd/pkg/lockedfile v0.0.5
|
||||
github.com/fluxcd/pkg/runtime v0.2.0
|
||||
github.com/fluxcd/pkg/runtime v0.3.0
|
||||
github.com/fluxcd/pkg/ssh v0.0.5
|
||||
github.com/fluxcd/pkg/untar v0.0.5
|
||||
github.com/fluxcd/pkg/version v0.0.1
|
||||
|
|
8
go.sum
8
go.sum
|
@ -222,16 +222,16 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZM
|
|||
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0 h1:bxoFQtZM6OLLj0+n3h6ga7IEWUtGEDJPc65OWiXSMvY=
|
||||
github.com/fluxcd/pkg/apis/meta v0.2.0/go.mod h1:50RLLSfqM4LlQrh/+5LiJVf7Hjdthee8WDdXBvpjBdA=
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0 h1:o2YkfGgf0j8sKeZs8cBmmmMKLA7kEoS1qYViOial1Ds=
|
||||
github.com/fluxcd/pkg/apis/meta v0.3.0/go.mod h1:wOzQQx8CdtUQCGaLzqGu4QgnNxYkI6/wvdvlovxWhF0=
|
||||
github.com/fluxcd/pkg/gittestserver v0.0.2 h1:11aKRVuuHiyeaicdN4wPNSMy/dUarQkrPrg0uUgDcTw=
|
||||
github.com/fluxcd/pkg/gittestserver v0.0.2/go.mod h1:GW8N9d1o8/+mXWnSzs02qCB5WlArWQHdMpDPf7b/GZg=
|
||||
github.com/fluxcd/pkg/helmtestserver v0.0.1 h1:8RcLZdg7Zr9ZqyijsIIASjjMXQtF4UWP4Uds4iK2VJM=
|
||||
github.com/fluxcd/pkg/helmtestserver v0.0.1/go.mod h1:GR8LriiU7PqZSTH4Xe6Cimpig2VVPB29PeUXJjNJYfA=
|
||||
github.com/fluxcd/pkg/lockedfile v0.0.5 h1:C3T8wfdff1UY1bvplmCkGOLrdMWJHO8Q8+tdlEXJYzQ=
|
||||
github.com/fluxcd/pkg/lockedfile v0.0.5/go.mod h1:uAtPUBId6a2RqO84MTH5HKGX0SbM1kNW3Wr/FhYyDVA=
|
||||
github.com/fluxcd/pkg/runtime v0.2.0 h1:aZmSLuyA9pF/KANf4wi7pZIICE19BKTYFSPRbl6WHtY=
|
||||
github.com/fluxcd/pkg/runtime v0.2.0/go.mod h1:P1/S8TOSuJgVPU0SRahWzbNxLWYoUwvBcPCNGc+dWWg=
|
||||
github.com/fluxcd/pkg/runtime v0.3.0 h1:WpeTmDT2meIe4NsU081I8zmUGgTYs3bIMRgs9F3Lj90=
|
||||
github.com/fluxcd/pkg/runtime v0.3.0/go.mod h1:gPe6JgfPB4EDh5gaVkuI0SPuATk3PmclbFa1kPcZrKE=
|
||||
github.com/fluxcd/pkg/ssh v0.0.5 h1:rnbFZ7voy2JBlUfMbfyqArX2FYaLNpDhccGFC3qW83A=
|
||||
github.com/fluxcd/pkg/ssh v0.0.5/go.mod h1:7jXPdXZpc0ttMNz2kD9QuMi3RNn/e0DOFbj0Tij/+Hs=
|
||||
github.com/fluxcd/pkg/testserver v0.0.2 h1:SoaMtO9cE5p/wl2zkGudzflnEHd9mk68CGjZOo7w0Uk=
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
},
|
||||
{
|
||||
"typeMatchPrefix": "^k8s\\.io/(api|apimachinery/pkg/apis)/",
|
||||
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
|
||||
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
|
||||
},
|
||||
{
|
||||
"typeMatchPrefix": "^github.com/fluxcd/pkg/apis/meta\\.Condition$",
|
||||
|
|
Loading…
Reference in New Issue