Switch to new pkg/apis/meta SetResourceCondition
Use SetResourceCondition as a generic method to set conditions for CRs, implmeneting the ObjectWithStatusConditions interface used as input type. Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
parent
69f9bbdaa6
commit
b80f450b68
|
@ -3,7 +3,7 @@ module github.com/fluxcd/source-controller/api
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fluxcd/pkg/apis/meta v0.3.0
|
github.com/fluxcd/pkg/apis/meta v0.4.0
|
||||||
k8s.io/api v0.19.3
|
k8s.io/api v0.19.3
|
||||||
k8s.io/apimachinery v0.19.3
|
k8s.io/apimachinery v0.19.3
|
||||||
sigs.k8s.io/controller-runtime v0.6.3
|
sigs.k8s.io/controller-runtime v0.6.3
|
||||||
|
|
|
@ -65,6 +65,8 @@ github.com/fluxcd/pkg/apis/meta v0.2.0 h1:bxoFQtZM6OLLj0+n3h6ga7IEWUtGEDJPc65OWi
|
||||||
github.com/fluxcd/pkg/apis/meta v0.2.0/go.mod h1:50RLLSfqM4LlQrh/+5LiJVf7Hjdthee8WDdXBvpjBdA=
|
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 h1:o2YkfGgf0j8sKeZs8cBmmmMKLA7kEoS1qYViOial1Ds=
|
||||||
github.com/fluxcd/pkg/apis/meta v0.3.0/go.mod h1:wOzQQx8CdtUQCGaLzqGu4QgnNxYkI6/wvdvlovxWhF0=
|
github.com/fluxcd/pkg/apis/meta v0.3.0/go.mod h1:wOzQQx8CdtUQCGaLzqGu4QgnNxYkI6/wvdvlovxWhF0=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v0.4.0 h1:JChqB9GGgorW9HWKxirTVV0rzrcLyzBaVjinmqZ0iHA=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v0.4.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.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 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
|
|
|
@ -114,41 +114,24 @@ func BucketProgressing(bucket Bucket) Bucket {
|
||||||
bucket.Status.ObservedGeneration = bucket.Generation
|
bucket.Status.ObservedGeneration = bucket.Generation
|
||||||
bucket.Status.URL = ""
|
bucket.Status.URL = ""
|
||||||
bucket.Status.Conditions = []metav1.Condition{}
|
bucket.Status.Conditions = []metav1.Condition{}
|
||||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||||
return bucket
|
return bucket
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBucketCondition sets the given condition with the given status, reason and
|
|
||||||
// message on the Bucket.
|
|
||||||
func SetBucketCondition(bucket *Bucket, condition string, status metav1.ConditionStatus, reason, message string) {
|
|
||||||
conditions := &bucket.Status.Conditions
|
|
||||||
generation := bucket.GetGeneration()
|
|
||||||
newCondition := metav1.Condition{
|
|
||||||
Type: condition,
|
|
||||||
Status: status,
|
|
||||||
LastTransitionTime: metav1.Now(),
|
|
||||||
Reason: reason,
|
|
||||||
Message: message,
|
|
||||||
ObservedGeneration: generation,
|
|
||||||
}
|
|
||||||
|
|
||||||
apimeta.SetStatusCondition(conditions, newCondition)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BucketReady sets the given Artifact and URL on the Bucket and sets the
|
// BucketReady sets the given Artifact and URL on the Bucket and sets the
|
||||||
// meta.ReadyCondition to 'True', with the given reason and message. It returns
|
// meta.ReadyCondition to 'True', with the given reason and message. It returns
|
||||||
// the modified Bucket.
|
// the modified Bucket.
|
||||||
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
|
func BucketReady(bucket Bucket, artifact Artifact, url, reason, message string) Bucket {
|
||||||
bucket.Status.Artifact = &artifact
|
bucket.Status.Artifact = &artifact
|
||||||
bucket.Status.URL = url
|
bucket.Status.URL = url
|
||||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||||
return bucket
|
return bucket
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
|
// BucketNotReady sets the meta.ReadyCondition on the Bucket to 'False', with
|
||||||
// the given reason and message. It returns the modified Bucket.
|
// the given reason and message. It returns the modified Bucket.
|
||||||
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
|
func BucketNotReady(bucket Bucket, reason, message string) Bucket {
|
||||||
SetBucketCondition(&bucket, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
meta.SetResourceCondition(&bucket, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||||
return bucket
|
return bucket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +152,11 @@ func (in *Bucket) GetArtifact() *Artifact {
|
||||||
return in.Status.Artifact
|
return in.Status.Artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStatusConditions returns a pointer to the Status.Conditions slice
|
||||||
|
func (in *Bucket) GetStatusConditions() *[]metav1.Condition {
|
||||||
|
return &in.Status.Conditions
|
||||||
|
}
|
||||||
|
|
||||||
// GetInterval returns the interval at which the source is updated.
|
// GetInterval returns the interval at which the source is updated.
|
||||||
func (in *Bucket) GetInterval() metav1.Duration {
|
func (in *Bucket) GetInterval() metav1.Duration {
|
||||||
return in.Spec.Interval
|
return in.Spec.Interval
|
||||||
|
|
|
@ -136,34 +136,17 @@ func GitRepositoryProgressing(repository GitRepository) GitRepository {
|
||||||
repository.Status.ObservedGeneration = repository.Generation
|
repository.Status.ObservedGeneration = repository.Generation
|
||||||
repository.Status.URL = ""
|
repository.Status.URL = ""
|
||||||
repository.Status.Conditions = []metav1.Condition{}
|
repository.Status.Conditions = []metav1.Condition{}
|
||||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetGitRepositoryCondition sets the given condition with the given status,
|
|
||||||
// reason and message on the GitRepository.
|
|
||||||
func SetGitRepositoryCondition(repository *GitRepository, condition string, status metav1.ConditionStatus, reason, message string) {
|
|
||||||
conditions := &repository.Status.Conditions
|
|
||||||
generation := repository.GetGeneration()
|
|
||||||
newCondition := metav1.Condition{
|
|
||||||
Type: condition,
|
|
||||||
Status: status,
|
|
||||||
LastTransitionTime: metav1.Now(),
|
|
||||||
Reason: reason,
|
|
||||||
Message: message,
|
|
||||||
ObservedGeneration: generation,
|
|
||||||
}
|
|
||||||
|
|
||||||
apimeta.SetStatusCondition(conditions, newCondition)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GitRepositoryReady sets the given Artifact and URL on the GitRepository and
|
// GitRepositoryReady sets the given Artifact and URL on the GitRepository and
|
||||||
// sets the meta.ReadyCondition to 'True', with the given reason and message. It
|
// sets the meta.ReadyCondition to 'True', with the given reason and message. It
|
||||||
// returns the modified GitRepository.
|
// returns the modified GitRepository.
|
||||||
func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason, message string) GitRepository {
|
func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason, message string) GitRepository {
|
||||||
repository.Status.Artifact = &artifact
|
repository.Status.Artifact = &artifact
|
||||||
repository.Status.URL = url
|
repository.Status.URL = url
|
||||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +154,7 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason
|
||||||
// to 'False', with the given reason and message. It returns the modified
|
// to 'False', with the given reason and message. It returns the modified
|
||||||
// GitRepository.
|
// GitRepository.
|
||||||
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
|
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {
|
||||||
SetGitRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +175,11 @@ func (in *GitRepository) GetArtifact() *Artifact {
|
||||||
return in.Status.Artifact
|
return in.Status.Artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStatusConditions returns a pointer to the Status.Conditions slice
|
||||||
|
func (in *GitRepository) GetStatusConditions() *[]metav1.Condition {
|
||||||
|
return &in.Status.Conditions
|
||||||
|
}
|
||||||
|
|
||||||
// GetInterval returns the interval at which the source is updated.
|
// GetInterval returns the interval at which the source is updated.
|
||||||
func (in *GitRepository) GetInterval() metav1.Duration {
|
func (in *GitRepository) GetInterval() metav1.Duration {
|
||||||
return in.Spec.Interval
|
return in.Spec.Interval
|
||||||
|
|
|
@ -113,34 +113,17 @@ func HelmChartProgressing(chart HelmChart) HelmChart {
|
||||||
chart.Status.ObservedGeneration = chart.Generation
|
chart.Status.ObservedGeneration = chart.Generation
|
||||||
chart.Status.URL = ""
|
chart.Status.URL = ""
|
||||||
chart.Status.Conditions = []metav1.Condition{}
|
chart.Status.Conditions = []metav1.Condition{}
|
||||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||||
return chart
|
return chart
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHelmChartCondition sets the given condition with the given status, reason
|
|
||||||
// and message on the HelmChart.
|
|
||||||
func SetHelmChartCondition(chart *HelmChart, condition string, status metav1.ConditionStatus, reason, message string) {
|
|
||||||
conditions := &chart.Status.Conditions
|
|
||||||
generation := chart.GetGeneration()
|
|
||||||
newCondition := metav1.Condition{
|
|
||||||
Type: condition,
|
|
||||||
Status: status,
|
|
||||||
LastTransitionTime: metav1.Now(),
|
|
||||||
Reason: reason,
|
|
||||||
Message: message,
|
|
||||||
ObservedGeneration: generation,
|
|
||||||
}
|
|
||||||
|
|
||||||
apimeta.SetStatusCondition(conditions, newCondition)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HelmChartReady sets the given Artifact and URL on the HelmChart and sets the
|
// HelmChartReady sets the given Artifact and URL on the HelmChart and sets the
|
||||||
// meta.ReadyCondition to 'True', with the given reason and message. It returns
|
// meta.ReadyCondition to 'True', with the given reason and message. It returns
|
||||||
// the modified HelmChart.
|
// the modified HelmChart.
|
||||||
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
|
func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message string) HelmChart {
|
||||||
chart.Status.Artifact = &artifact
|
chart.Status.Artifact = &artifact
|
||||||
chart.Status.URL = url
|
chart.Status.URL = url
|
||||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||||
return chart
|
return chart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +131,7 @@ func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message str
|
||||||
// 'False', with the given reason and message. It returns the modified
|
// 'False', with the given reason and message. It returns the modified
|
||||||
// HelmChart.
|
// HelmChart.
|
||||||
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
|
func HelmChartNotReady(chart HelmChart, reason, message string) HelmChart {
|
||||||
SetHelmChartCondition(&chart, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
meta.SetResourceCondition(&chart, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||||
return chart
|
return chart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +152,11 @@ func (in *HelmChart) GetArtifact() *Artifact {
|
||||||
return in.Status.Artifact
|
return in.Status.Artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStatusConditions returns a pointer to the Status.Conditions slice
|
||||||
|
func (in *HelmChart) GetStatusConditions() *[]metav1.Condition {
|
||||||
|
return &in.Status.Conditions
|
||||||
|
}
|
||||||
|
|
||||||
// GetInterval returns the interval at which the source is updated.
|
// GetInterval returns the interval at which the source is updated.
|
||||||
func (in *HelmChart) GetInterval() metav1.Duration {
|
func (in *HelmChart) GetInterval() metav1.Duration {
|
||||||
return in.Spec.Interval
|
return in.Spec.Interval
|
||||||
|
|
|
@ -93,34 +93,17 @@ func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
|
||||||
repository.Status.ObservedGeneration = repository.Generation
|
repository.Status.ObservedGeneration = repository.Generation
|
||||||
repository.Status.URL = ""
|
repository.Status.URL = ""
|
||||||
repository.Status.Conditions = []metav1.Condition{}
|
repository.Status.Conditions = []metav1.Condition{}
|
||||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionUnknown, meta.ProgressingReason, "reconciliation in progress")
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHelmRepositoryCondition sets the given condition with the given status,
|
|
||||||
// reason and message on the HelmRepository.
|
|
||||||
func SetHelmRepositoryCondition(repository *HelmRepository, condition string, status metav1.ConditionStatus, reason, message string) {
|
|
||||||
conditions := &repository.Status.Conditions
|
|
||||||
generation := repository.GetGeneration()
|
|
||||||
newCondition := metav1.Condition{
|
|
||||||
Type: condition,
|
|
||||||
Status: status,
|
|
||||||
LastTransitionTime: metav1.Now(),
|
|
||||||
Reason: reason,
|
|
||||||
Message: message,
|
|
||||||
ObservedGeneration: generation,
|
|
||||||
}
|
|
||||||
|
|
||||||
apimeta.SetStatusCondition(conditions, newCondition)
|
|
||||||
}
|
|
||||||
|
|
||||||
// HelmRepositoryReady sets the given Artifact and URL on the HelmRepository and
|
// HelmRepositoryReady sets the given Artifact and URL on the HelmRepository and
|
||||||
// sets the meta.ReadyCondition to 'True', with the given reason and message. It
|
// sets the meta.ReadyCondition to 'True', with the given reason and message. It
|
||||||
// returns the modified HelmRepository.
|
// returns the modified HelmRepository.
|
||||||
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
|
func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reason, message string) HelmRepository {
|
||||||
repository.Status.Artifact = &artifact
|
repository.Status.Artifact = &artifact
|
||||||
repository.Status.URL = url
|
repository.Status.URL = url
|
||||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionTrue, reason, message)
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +111,7 @@ func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reas
|
||||||
// HelmRepository to 'False', with the given reason and message. It returns the
|
// HelmRepository to 'False', with the given reason and message. It returns the
|
||||||
// modified HelmRepository.
|
// modified HelmRepository.
|
||||||
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
|
func HelmRepositoryNotReady(repository HelmRepository, reason, message string) HelmRepository {
|
||||||
SetHelmRepositoryCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
meta.SetResourceCondition(&repository, meta.ReadyCondition, metav1.ConditionFalse, reason, message)
|
||||||
return repository
|
return repository
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +132,11 @@ func (in *HelmRepository) GetArtifact() *Artifact {
|
||||||
return in.Status.Artifact
|
return in.Status.Artifact
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStatusConditions returns a pointer to the Status.Conditions slice
|
||||||
|
func (in *HelmRepository) GetStatusConditions() *[]metav1.Condition {
|
||||||
|
return &in.Status.Conditions
|
||||||
|
}
|
||||||
|
|
||||||
// GetInterval returns the interval at which the source is updated.
|
// GetInterval returns the interval at which the source is updated.
|
||||||
func (in *HelmRepository) GetInterval() metav1.Duration {
|
func (in *HelmRepository) GetInterval() metav1.Duration {
|
||||||
return in.Spec.Interval
|
return in.Spec.Interval
|
||||||
|
|
|
@ -213,7 +213,7 @@ func (r *BucketReconciler) reconcile(ctx context.Context, bucket sourcev1.Bucket
|
||||||
|
|
||||||
// return early on unchanged revision
|
// return early on unchanged revision
|
||||||
artifact := r.Storage.NewArtifactFor(bucket.Kind, bucket.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", revision))
|
artifact := r.Storage.NewArtifactFor(bucket.Kind, bucket.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", revision))
|
||||||
if meta.InReadyCondition(bucket.Status.Conditions) && bucket.GetArtifact().HasRevision(artifact.Revision) {
|
if apimeta.IsStatusConditionTrue(bucket.Status.Conditions, meta.ReadyCondition) && bucket.GetArtifact().HasRevision(artifact.Revision) {
|
||||||
if artifact.URL != bucket.GetArtifact().URL {
|
if artifact.URL != bucket.GetArtifact().URL {
|
||||||
r.Storage.SetArtifactURL(bucket.GetArtifact())
|
r.Storage.SetArtifactURL(bucket.GetArtifact())
|
||||||
bucket.Status.URL = r.Storage.SetHostname(bucket.Status.URL)
|
bucket.Status.URL = r.Storage.SetHostname(bucket.Status.URL)
|
||||||
|
|
|
@ -200,7 +200,7 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
|
||||||
|
|
||||||
// return early on unchanged revision
|
// return early on unchanged revision
|
||||||
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash.String()))
|
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash.String()))
|
||||||
if meta.InReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
if apimeta.IsStatusConditionTrue(repository.Status.Conditions, meta.ReadyCondition) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||||
if artifact.URL != repository.GetArtifact().URL {
|
if artifact.URL != repository.GetArtifact().URL {
|
||||||
r.Storage.SetArtifactURL(repository.GetArtifact())
|
r.Storage.SetArtifactURL(repository.GetArtifact())
|
||||||
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
||||||
|
|
|
@ -425,7 +425,7 @@ func (r *HelmChartReconciler) reconcileFromTarballArtifact(ctx context.Context,
|
||||||
// Return early if the revision is still the same as the current chart artifact
|
// 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,
|
newArtifact := r.Storage.NewArtifactFor(chart.Kind, chart.ObjectMeta.GetObjectMeta(), helmChart.Metadata.Version,
|
||||||
fmt.Sprintf("%s-%s.tgz", helmChart.Metadata.Name, helmChart.Metadata.Version))
|
fmt.Sprintf("%s-%s.tgz", helmChart.Metadata.Name, helmChart.Metadata.Version))
|
||||||
if !force && meta.InReadyCondition(chart.Status.Conditions) && chart.GetArtifact().HasRevision(newArtifact.Revision) {
|
if !force && apimeta.IsStatusConditionTrue(chart.Status.Conditions, meta.ReadyCondition) && chart.GetArtifact().HasRevision(newArtifact.Revision) {
|
||||||
if newArtifact.URL != artifact.URL {
|
if newArtifact.URL != artifact.URL {
|
||||||
r.Storage.SetArtifactURL(chart.GetArtifact())
|
r.Storage.SetArtifactURL(chart.GetArtifact())
|
||||||
chart.Status.URL = r.Storage.SetHostname(chart.Status.URL)
|
chart.Status.URL = r.Storage.SetHostname(chart.Status.URL)
|
||||||
|
|
|
@ -42,6 +42,7 @@ import (
|
||||||
"helm.sh/helm/v3/pkg/chart/loader"
|
"helm.sh/helm/v3/pkg/chart/loader"
|
||||||
"helm.sh/helm/v3/pkg/chartutil"
|
"helm.sh/helm/v3/pkg/chartutil"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
|
@ -406,7 +407,7 @@ var _ = Describe("HelmChartReconciler", func() {
|
||||||
By("Expecting artifact")
|
By("Expecting artifact")
|
||||||
Eventually(func() bool {
|
Eventually(func() bool {
|
||||||
_ = k8sClient.Get(context.Background(), key, got)
|
_ = k8sClient.Get(context.Background(), key, got)
|
||||||
return meta.InReadyCondition(got.Status.Conditions)
|
return apimeta.IsStatusConditionTrue(got.Status.Conditions, meta.ReadyCondition)
|
||||||
}, timeout, interval).Should(BeTrue())
|
}, timeout, interval).Should(BeTrue())
|
||||||
Expect(got.Status.Artifact).ToNot(BeNil())
|
Expect(got.Status.Artifact).ToNot(BeNil())
|
||||||
})
|
})
|
||||||
|
|
|
@ -204,7 +204,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
|
||||||
repository.ObjectMeta.GetObjectMeta(),
|
repository.ObjectMeta.GetObjectMeta(),
|
||||||
chartRepo.Index.Generated.Format(time.RFC3339Nano),
|
chartRepo.Index.Generated.Format(time.RFC3339Nano),
|
||||||
fmt.Sprintf("index-%s.yaml", url.PathEscape(chartRepo.Index.Generated.Format(time.RFC3339Nano))))
|
fmt.Sprintf("index-%s.yaml", url.PathEscape(chartRepo.Index.Generated.Format(time.RFC3339Nano))))
|
||||||
if meta.InReadyCondition(repository.Status.Conditions) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
if apimeta.IsStatusConditionTrue(repository.Status.Conditions, meta.ReadyCondition) && repository.GetArtifact().HasRevision(artifact.Revision) {
|
||||||
if artifact.URL != repository.GetArtifact().URL {
|
if artifact.URL != repository.GetArtifact().URL {
|
||||||
r.Storage.SetArtifactURL(repository.GetArtifact())
|
r.Storage.SetArtifactURL(repository.GetArtifact())
|
||||||
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
repository.Status.URL = r.Storage.SetHostname(repository.Status.URL)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ replace github.com/fluxcd/source-controller/api => ./api
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/semver/v3 v3.1.0
|
github.com/Masterminds/semver/v3 v3.1.0
|
||||||
github.com/fluxcd/pkg/apis/meta v0.3.0
|
github.com/fluxcd/pkg/apis/meta v0.4.0
|
||||||
github.com/fluxcd/pkg/gittestserver v0.0.2
|
github.com/fluxcd/pkg/gittestserver v0.0.2
|
||||||
github.com/fluxcd/pkg/helmtestserver v0.0.1
|
github.com/fluxcd/pkg/helmtestserver v0.0.1
|
||||||
github.com/fluxcd/pkg/lockedfile v0.0.5
|
github.com/fluxcd/pkg/lockedfile v0.0.5
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -224,6 +224,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fluxcd/pkg/apis/meta v0.3.0 h1:o2YkfGgf0j8sKeZs8cBmmmMKLA7kEoS1qYViOial1Ds=
|
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/apis/meta v0.3.0/go.mod h1:wOzQQx8CdtUQCGaLzqGu4QgnNxYkI6/wvdvlovxWhF0=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v0.4.0 h1:JChqB9GGgorW9HWKxirTVV0rzrcLyzBaVjinmqZ0iHA=
|
||||||
|
github.com/fluxcd/pkg/apis/meta v0.4.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 h1:11aKRVuuHiyeaicdN4wPNSMy/dUarQkrPrg0uUgDcTw=
|
||||||
github.com/fluxcd/pkg/gittestserver v0.0.2/go.mod h1:GW8N9d1o8/+mXWnSzs02qCB5WlArWQHdMpDPf7b/GZg=
|
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 h1:8RcLZdg7Zr9ZqyijsIIASjjMXQtF4UWP4Uds4iK2VJM=
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#{{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$",
|
"typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Condition$",
|
||||||
"docsURLTemplate": "https://godoc.org/github.com/fluxcd/pkg/apis/meta#Condition"
|
"docsURLTemplate": "https://godoc.org/k8s.io/apimachinery/pkg/apis/meta/v1#Condition"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"typeDisplayNamePrefixOverrides": {
|
"typeDisplayNamePrefixOverrides": {
|
||||||
|
|
Loading…
Reference in New Issue