Skip to content

Commit 9c9b321

Browse files
authored
Merge pull request #50 from fluxcd/ref-serialization
git: fix reference json serialization
2 parents f2bff90 + ca884a9 commit 9c9b321

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

api/v1alpha1/gitrepository_types.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ type GitRepositorySpec struct {
4242
// +required
4343
Interval metav1.Duration `json:"interval"`
4444

45-
// The timeout for remote git operations like cloning.
46-
// +kubebuilder:validation:Default=20s
45+
// The timeout for remote git operations like cloning, default to 20s.
4746
// +optional
4847
Timeout *metav1.Duration `json:"timeout,omitempty"`
4948

@@ -61,20 +60,19 @@ type GitRepositorySpec struct {
6160
type GitRepositoryRef struct {
6261
// The git branch to checkout, defaults to master.
6362
// +optional
64-
Branch string `json:"branch"`
63+
Branch string `json:"branch,omitempty"`
6564

6665
// The git tag to checkout, takes precedence over branch.
6766
// +optional
68-
Tag string `json:"tag"`
67+
Tag string `json:"tag,omitempty"`
6968

7069
// The git tag semver expression, takes precedence over tag.
7170
// +optional
72-
SemVer string `json:"semver"`
71+
SemVer string `json:"semver,omitempty"`
7372

74-
// The git commit sha to checkout, if specified tag filters will be
75-
// ignored.
73+
// The git commit sha to checkout, if specified tag filters will be ignored.
7674
// +optional
77-
Commit string `json:"commit"`
75+
Commit string `json:"commit,omitempty"`
7876
}
7977

8078
// GitRepositoryVerification defines the OpenPGP signature verification process.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ spec:
8383
type: string
8484
type: object
8585
timeout:
86-
description: The timeout for remote git operations like cloning.
86+
description: The timeout for remote git operations like cloning, default
87+
to 20s.
8788
type: string
8889
url:
8990
description: The repository URL, can be a HTTP or SSH address.

controllers/helmchart_controller_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,15 @@ var _ = Describe("HelmChartReconciler", func() {
157157
return k8sClient.Get(context.Background(), key, c)
158158
}).ShouldNot(Succeed())
159159

160+
exists := func(path string) bool {
161+
// wait for tmp sync on macOS
162+
time.Sleep(time.Second)
163+
_, err := os.Stat(path)
164+
return err == nil
165+
}
166+
160167
By("Expecting GC on delete")
161-
Eventually(storage.ArtifactExist(*got.Status.Artifact), timeout, interval).ShouldNot(BeTrue())
168+
Eventually(exists(got.Status.Artifact.Path), timeout, interval).ShouldNot(BeTrue())
162169
})
163170

164171
It("Filters versions", func() {

controllers/helmrepository_controller_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,15 @@ var _ = Describe("HelmRepositoryReconciler", func() {
139139
return k8sClient.Get(context.Background(), key, r)
140140
}).ShouldNot(Succeed())
141141

142+
exists := func(path string) bool {
143+
// wait for tmp sync on macOS
144+
time.Sleep(time.Second)
145+
_, err := os.Stat(path)
146+
return err == nil
147+
}
148+
142149
By("Expecting GC after delete")
143-
Eventually(storage.ArtifactExist(*got.Status.Artifact), timeout, interval).ShouldNot(BeTrue())
150+
Eventually(exists(got.Status.Artifact.Path), timeout, interval).ShouldNot(BeTrue())
144151
})
145152

146153
It("Authenticates when basic auth credentials are provided", func() {

docs/spec/v1alpha1/gitrepositories.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ type GitRepositorySpec struct {
2727
// The interval at which to check for repository updates.
2828
Interval metav1.Duration `json:"interval"`
2929

30-
// The timeout for remote git operations like cloning.
31-
// +kubebuilder:validation:Default=20s
30+
// The timeout for remote git operations like cloning, default to 20s.
3231
// +optional
3332
Timeout *metav1.Duration `json:"timeout,omitempty"`
3433

@@ -50,20 +49,19 @@ Git repository reference:
5049
type GitRepositoryRef struct {
5150
// The git branch to checkout, defaults to master.
5251
// +optional
53-
Branch string `json:"branch"`
52+
Branch string `json:"branch,omitempty"`
5453

5554
// The git tag to checkout, takes precedence over branch.
5655
// +optional
57-
Tag string `json:"tag"`
56+
Tag string `json:"tag,omitempty"`
5857

5958
// The git tag semver expression, takes precedence over tag.
6059
// +optional
61-
SemVer string `json:"semver"`
60+
SemVer string `json:"semver,omitempty"`
6261

63-
// The git commit sha to checkout, if specified branch and tag filters will
64-
// ignored.
62+
// The git commit sha to checkout, if specified tag filters will be ignored.
6563
// +optional
66-
Commit string `json:"commit"`
64+
Commit string `json:"commit,omitempty"`
6765
}
6866
```
6967

0 commit comments

Comments
 (0)