diff --git a/api/v1alpha1/artifact.go b/api/v1alpha1/artifact.go
index ff3e59ff..b9bac76b 100644
--- a/api/v1alpha1/artifact.go
+++ b/api/v1alpha1/artifact.go
@@ -23,9 +23,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
-// Artifact represents the output of a source synchronisation
+// Artifact represents the output of a source synchronisation.
type Artifact struct {
- // Path is the local file path of this artifact.
+ // Path is the relative file path of this artifact.
// +required
Path string `json:"path"`
@@ -33,12 +33,16 @@ type Artifact struct {
// +required
URL string `json:"url"`
- // Revision is a human readable identifier traceable in the origin source system.
- // It can be a commit sha, git tag, a helm index timestamp,
- // a helm chart version, a checksum, etc.
+ // Revision is a human readable identifier traceable in the origin
+ // source system. It can be a Git commit sha, Git tag, a Helm index
+ // timestamp, a Helm chart version, etc.
// +optional
Revision string `json:"revision"`
+ // Checksum is the SHA1 checksum of the artifact.
+ // +optional
+ Checksum string `json:"checksum"`
+
// LastUpdateTime is the timestamp corresponding to the last
// update of this artifact.
// +required
@@ -46,14 +50,14 @@ type Artifact struct {
}
// ArtifactDir returns the artifact dir path in the form of
-// //
+// //.
func ArtifactDir(kind, namespace, name string) string {
kind = strings.ToLower(kind)
return path.Join(kind, namespace, name)
}
// ArtifactPath returns the artifact path in the form of
-// ///
+// ///.
func ArtifactPath(kind, namespace, name, filename string) string {
return path.Join(ArtifactDir(kind, namespace, name), filename)
}
diff --git a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml
index 2a339ee9..e60d5852 100644
--- a/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml
+++ b/config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml
@@ -129,18 +129,21 @@ spec:
description: Artifact represents the output of the last successful
repository sync.
properties:
+ checksum:
+ description: Checksum is the SHA1 checksum of the artifact.
+ type: string
lastUpdateTime:
description: LastUpdateTime is the timestamp corresponding to
the last update of this artifact.
format: date-time
type: string
path:
- description: Path is the local file path of this artifact.
+ description: Path is the relative file path of this artifact.
type: string
revision:
description: Revision is a human readable identifier traceable
- in the origin source system. It can be a commit sha, git tag,
- a helm index timestamp, a helm chart version, a checksum, etc.
+ in the origin source system. It can be a Git commit sha, Git
+ tag, a Helm index timestamp, a Helm chart version, etc.
type: string
url:
description: URL is the HTTP address of this artifact.
diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml
index e66ef34d..d1125575 100644
--- a/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml
+++ b/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml
@@ -101,18 +101,21 @@ spec:
description: Artifact represents the output of the last successful
chart sync.
properties:
+ checksum:
+ description: Checksum is the SHA1 checksum of the artifact.
+ type: string
lastUpdateTime:
description: LastUpdateTime is the timestamp corresponding to
the last update of this artifact.
format: date-time
type: string
path:
- description: Path is the local file path of this artifact.
+ description: Path is the relative file path of this artifact.
type: string
revision:
description: Revision is a human readable identifier traceable
- in the origin source system. It can be a commit sha, git tag,
- a helm index timestamp, a helm chart version, a checksum, etc.
+ in the origin source system. It can be a Git commit sha, Git
+ tag, a Helm index timestamp, a Helm chart version, etc.
type: string
url:
description: URL is the HTTP address of this artifact.
diff --git a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml
index e165ee19..8f7f675e 100644
--- a/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml
+++ b/config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml
@@ -81,18 +81,21 @@ spec:
description: Artifact represents the output of the last successful
repository sync.
properties:
+ checksum:
+ description: Checksum is the SHA1 checksum of the artifact.
+ type: string
lastUpdateTime:
description: LastUpdateTime is the timestamp corresponding to
the last update of this artifact.
format: date-time
type: string
path:
- description: Path is the local file path of this artifact.
+ description: Path is the relative file path of this artifact.
type: string
revision:
description: Revision is a human readable identifier traceable
- in the origin source system. It can be a commit sha, git tag,
- a helm index timestamp, a helm chart version, a checksum, etc.
+ in the origin source system. It can be a Git commit sha, Git
+ tag, a Helm index timestamp, a Helm chart version, etc.
type: string
url:
description: URL is the HTTP address of this artifact.
diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go
index b1aa96fc..eed5478f 100644
--- a/controllers/gitrepository_controller.go
+++ b/controllers/gitrepository_controller.go
@@ -212,8 +212,10 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
}
}
+ // TODO(hidde): implement checksum when https://github.com/fluxcd/source-controller/pull/133
+ // has been merged.
artifact := r.Storage.ArtifactFor(repository.Kind, repository.ObjectMeta.GetObjectMeta(),
- fmt.Sprintf("%s.tar.gz", commit.Hash.String()), revision)
+ fmt.Sprintf("%s.tar.gz", commit.Hash.String()), revision, "")
// create artifact dir
err = r.Storage.MkdirAll(artifact)
diff --git a/controllers/helmchart_controller.go b/controllers/helmchart_controller.go
index 8c02c2f1..58f07c4b 100644
--- a/controllers/helmchart_controller.go
+++ b/controllers/helmchart_controller.go
@@ -261,7 +261,7 @@ func (r *HelmChartReconciler) reconcileFromHelmRepository(ctx context.Context,
sum := r.Storage.Checksum(chartBytes)
artifact := r.Storage.ArtifactFor(chart.Kind, chart.GetObjectMeta(),
- fmt.Sprintf("%s-%s-%s.tgz", cv.Name, cv.Version, sum), cv.Version)
+ fmt.Sprintf("%s-%s-%s.tgz", cv.Name, cv.Version, sum), cv.Version, sum)
// create artifact dir
err = r.Storage.MkdirAll(artifact)
@@ -365,8 +365,10 @@ func (r *HelmChartReconciler) reconcileFromGitRepository(ctx context.Context,
return chart, nil
}
+ // TODO(hidde): implement checksum when https://github.com/fluxcd/source-controller/pull/133
+ // has been merged.
artifact := r.Storage.ArtifactFor(chart.Kind, chart.ObjectMeta.GetObjectMeta(),
- fmt.Sprintf("%s-%s.tgz", chartMetadata.Name, chartMetadata.Version), chartMetadata.Version)
+ fmt.Sprintf("%s-%s.tgz", chartMetadata.Name, chartMetadata.Version), chartMetadata.Version, "")
// create artifact dir
err = r.Storage.MkdirAll(artifact)
diff --git a/controllers/helmrepository_controller.go b/controllers/helmrepository_controller.go
index 1bd37268..feb28b76 100644
--- a/controllers/helmrepository_controller.go
+++ b/controllers/helmrepository_controller.go
@@ -229,7 +229,7 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, repository sou
sum := r.Storage.Checksum(index)
artifact := r.Storage.ArtifactFor(repository.Kind, repository.ObjectMeta.GetObjectMeta(),
- fmt.Sprintf("index-%s.yaml", sum), sum)
+ fmt.Sprintf("index-%s.yaml", sum), i.Generated.Format(time.RFC3339Nano), sum)
// create artifact dir
err = r.Storage.MkdirAll(artifact)
diff --git a/controllers/storage.go b/controllers/storage.go
index 9bb7814a..6df68106 100644
--- a/controllers/storage.go
+++ b/controllers/storage.go
@@ -70,7 +70,7 @@ func NewStorage(basePath string, hostname string, timeout time.Duration) (*Stora
}
// ArtifactFor returns an artifact for the v1alpha1.Source.
-func (s *Storage) ArtifactFor(kind string, metadata metav1.Object, fileName, revision string) sourcev1.Artifact {
+func (s *Storage) ArtifactFor(kind string, metadata metav1.Object, fileName, revision, checksum string) sourcev1.Artifact {
path := sourcev1.ArtifactPath(kind, metadata.GetNamespace(), metadata.GetName(), fileName)
localPath := filepath.Join(s.BasePath, path)
url := fmt.Sprintf("http://%s/%s", s.Hostname, path)
@@ -79,6 +79,7 @@ func (s *Storage) ArtifactFor(kind string, metadata metav1.Object, fileName, rev
Path: localPath,
URL: url,
Revision: revision,
+ Checksum: checksum,
LastUpdateTime: metav1.Now(),
}
}
diff --git a/docs/api/source.md b/docs/api/source.md
index b32eea5f..b7294757 100644
--- a/docs/api/source.md
+++ b/docs/api/source.md
@@ -458,7 +458,7 @@ HelmRepositoryStatus
HelmChartStatus,
HelmRepositoryStatus)
-Artifact represents the output of a source synchronisation
+Artifact represents the output of a source synchronisation.