Skip to content

Commit 4ab3c21

Browse files
committed
Delete Status.URL field from GitRepository v1
Usage of this field has not been recommended for a long time as it was best-effort based. Signed-off-by: Hidde Beydals <[email protected]>
1 parent 19ba61a commit 4ab3c21

File tree

5 files changed

+12
-61
lines changed

5 files changed

+12
-61
lines changed

api/v1/gitrepository_types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ type GitRepositoryStatus struct {
183183
// +optional
184184
Conditions []metav1.Condition `json:"conditions,omitempty"`
185185

186-
// URL is the dynamic fetch link for the latest Artifact.
187-
// It is provided on a "best effort" basis, and using the precise
188-
// GitRepositoryStatus.Artifact data is recommended.
189-
// +optional
190-
URL string `json:"url,omitempty"`
191-
192186
// Artifact represents the last successful GitRepository reconciliation.
193187
// +optional
194188
Artifact *Artifact `json:"artifact,omitempty"`

config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,6 @@ spec:
391391
description: ObservedRecurseSubmodules is the observed resource submodules
392392
configuration used to produce the current Artifact.
393393
type: boolean
394-
url:
395-
description: URL is the dynamic fetch link for the latest Artifact.
396-
It is provided on a "best effort" basis, and using the precise GitRepositoryStatus.Artifact
397-
data is recommended.
398-
type: string
399394
type: object
400395
type: object
401396
served: true

controllers/gitrepository_controller.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ func (r *GitRepositoryReconciler) reconcileStorage(ctx context.Context, sp *patc
392392
var artifactMissing bool
393393
if artifact := obj.GetArtifact(); artifact != nil && !r.Storage.ArtifactExist(*artifact) {
394394
obj.Status.Artifact = nil
395-
obj.Status.URL = ""
396395
artifactMissing = true
397396
// Remove the condition as the artifact doesn't exist.
398397
conditions.Delete(obj, sourcev1.ArtifactInStorageCondition)
@@ -415,7 +414,6 @@ func (r *GitRepositoryReconciler) reconcileStorage(ctx context.Context, sp *patc
415414
// Always update URLs to ensure hostname is up-to-date
416415
// TODO(hidde): we may want to send out an event only if we notice the URL has changed
417416
r.Storage.SetArtifactURL(obj.GetArtifact())
418-
obj.Status.URL = r.Storage.SetHostname(obj.Status.URL)
419417

420418
return sreconcile.ResultSuccess, nil
421419
}
@@ -700,15 +698,19 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, sp *pat
700698
obj.Status.ObservedRecurseSubmodules = obj.Spec.RecurseSubmodules
701699
obj.Status.ObservedInclude = obj.Spec.Include
702700

703-
// Update symlink on a "best effort" basis
704-
url, err := r.Storage.Symlink(artifact, "latest.tar.gz")
705-
if err != nil {
706-
r.eventLogf(ctx, obj, eventv1.EventTypeTrace, sourcev1.SymlinkUpdateFailedReason,
707-
"failed to update status URL symlink: %s", err)
708-
}
709-
if url != "" {
710-
obj.Status.URL = url
701+
// Remove the deprecated symlink.
702+
// TODO(hidde): remove 2 minor versions from introduction of v1.
703+
symArtifact := artifact.DeepCopy()
704+
symArtifact.Path = filepath.Join(filepath.Dir(symArtifact.Path), "latest.tar.gz")
705+
if fi, err := os.Lstat(r.Storage.LocalPath(artifact)); err == nil {
706+
if fi.Mode()&os.ModeSymlink != 0 {
707+
if err := os.Remove(r.Storage.LocalPath(*symArtifact)); err != nil {
708+
r.eventLogf(ctx, obj, eventv1.EventTypeTrace, sourcev1.SymlinkUpdateFailedReason,
709+
"failed to remove (deprecated) symlink: %s", err)
710+
}
711+
}
711712
}
713+
712714
conditions.Delete(obj, sourcev1.StorageOperationFailedCondition)
713715
return sreconcile.ResultSuccess, nil
714716
}

controllers/gitrepository_controller_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
864864
},
865865
afterFunc: func(t *WithT, obj *sourcev1.GitRepository) {
866866
t.Expect(obj.GetArtifact()).ToNot(BeNil())
867-
t.Expect(obj.Status.URL).ToNot(BeEmpty())
868867
},
869868
want: sreconcile.ResultSuccess,
870869
assertConditions: []metav1.Condition{
@@ -885,7 +884,6 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
885884
t.Expect(obj.GetArtifact()).ToNot(BeNil())
886885
t.Expect(obj.GetArtifact().Digest).To(Equal("sha256:60a3bf69f337cb5ec9ebd00abefbb6e7f2a2cf27158ecf438d52b2035b184172"))
887886
t.Expect(obj.Status.IncludedArtifacts).ToNot(BeEmpty())
888-
t.Expect(obj.Status.URL).ToNot(BeEmpty())
889887
},
890888
want: sreconcile.ResultSuccess,
891889
assertConditions: []metav1.Condition{
@@ -905,9 +903,6 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
905903
obj.Status.IncludedArtifacts = []*sourcev1.Artifact{{Revision: "main@sha1:b9b3feadba509cb9b22e968a5d27e96c2bc2ff91", Digest: "some-checksum"}}
906904
obj.Status.ObservedInclude = obj.Spec.Include
907905
},
908-
afterFunc: func(t *WithT, obj *sourcev1.GitRepository) {
909-
t.Expect(obj.Status.URL).To(BeEmpty())
910-
},
911906
want: sreconcile.ResultSuccess,
912907
assertConditions: []metav1.Condition{
913908
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'main@sha1:b9b3feadba509cb9b22e968a5d27e96c2bc2ff91'"),
@@ -954,27 +949,6 @@ func TestGitRepositoryReconciler_reconcileArtifact(t *testing.T) {
954949
afterFunc: func(t *WithT, obj *sourcev1.GitRepository) {
955950
t.Expect(obj.GetArtifact()).ToNot(BeNil())
956951
t.Expect(obj.GetArtifact().Digest).To(Equal("sha256:60a3bf69f337cb5ec9ebd00abefbb6e7f2a2cf27158ecf438d52b2035b184172"))
957-
t.Expect(obj.Status.URL).ToNot(BeEmpty())
958-
},
959-
want: sreconcile.ResultSuccess,
960-
assertConditions: []metav1.Condition{
961-
*conditions.TrueCondition(sourcev1.ArtifactInStorageCondition, meta.SucceededReason, "stored artifact for revision 'main@sha1:b9b3feadba509cb9b22e968a5d27e96c2bc2ff91'"),
962-
},
963-
},
964-
{
965-
name: "Creates latest symlink to the created artifact",
966-
dir: "testdata/git/repository",
967-
beforeFunc: func(obj *sourcev1.GitRepository) {
968-
obj.Spec.Interval = metav1.Duration{Duration: interval}
969-
},
970-
afterFunc: func(t *WithT, obj *sourcev1.GitRepository) {
971-
t.Expect(obj.GetArtifact()).ToNot(BeNil())
972-
973-
localPath := testStorage.LocalPath(*obj.GetArtifact())
974-
symlinkPath := filepath.Join(filepath.Dir(localPath), "latest.tar.gz")
975-
targetFile, err := os.Readlink(symlinkPath)
976-
t.Expect(err).NotTo(HaveOccurred())
977-
t.Expect(localPath).To(Equal(targetFile))
978952
},
979953
want: sreconcile.ResultSuccess,
980954
assertConditions: []metav1.Condition{

docs/api/v1/source.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -695,20 +695,6 @@ object.</p>
695695
</tr>
696696
<tr>
697697
<td>
698-
<code>url</code><br>
699-
<em>
700-
string
701-
</em>
702-
</td>
703-
<td>
704-
<em>(Optional)</em>
705-
<p>URL is the dynamic fetch link for the latest Artifact.
706-
It is provided on a &ldquo;best effort&rdquo; basis, and using the precise
707-
GitRepositoryStatus.Artifact data is recommended.</p>
708-
</td>
709-
</tr>
710-
<tr>
711-
<td>
712698
<code>artifact</code><br>
713699
<em>
714700
<a href="#source.toolkit.fluxcd.io/v1.Artifact">

0 commit comments

Comments
 (0)