misc: order imports and align digest aliases
Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
parent
eb4a38e421
commit
d62f4dc0c6
|
@ -21,12 +21,11 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fluxcd/source-controller/internal/digest"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
digestlib "github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
helmgetter "helm.sh/helm/v3/pkg/getter"
|
helmgetter "helm.sh/helm/v3/pkg/getter"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
@ -49,6 +48,7 @@ import (
|
||||||
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
"github.com/fluxcd/source-controller/internal/cache"
|
"github.com/fluxcd/source-controller/internal/cache"
|
||||||
|
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
||||||
serror "github.com/fluxcd/source-controller/internal/error"
|
serror "github.com/fluxcd/source-controller/internal/error"
|
||||||
"github.com/fluxcd/source-controller/internal/helm/getter"
|
"github.com/fluxcd/source-controller/internal/helm/getter"
|
||||||
"github.com/fluxcd/source-controller/internal/helm/repository"
|
"github.com/fluxcd/source-controller/internal/helm/repository"
|
||||||
|
@ -469,9 +469,9 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, sp *patc
|
||||||
|
|
||||||
// Early comparison to current Artifact.
|
// Early comparison to current Artifact.
|
||||||
if curArtifact := obj.GetArtifact(); curArtifact != nil {
|
if curArtifact := obj.GetArtifact(); curArtifact != nil {
|
||||||
curDig := digestlib.Digest(curArtifact.Digest)
|
curDig := digest.Digest(curArtifact.Digest)
|
||||||
if curDig == "" {
|
if curDig == "" {
|
||||||
curDig = digestlib.Digest(sourcev1.TransformLegacyRevision(curArtifact.Checksum))
|
curDig = digest.Digest(sourcev1.TransformLegacyRevision(curArtifact.Checksum))
|
||||||
}
|
}
|
||||||
if curDig.Validate() == nil {
|
if curDig.Validate() == nil {
|
||||||
// Short-circuit based on the fetched index being an exact match to the
|
// Short-circuit based on the fetched index being an exact match to the
|
||||||
|
@ -500,12 +500,12 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, sp *patc
|
||||||
// Check if index has changed compared to current Artifact revision.
|
// Check if index has changed compared to current Artifact revision.
|
||||||
var changed bool
|
var changed bool
|
||||||
if artifact := obj.Status.Artifact; artifact != nil {
|
if artifact := obj.Status.Artifact; artifact != nil {
|
||||||
curRev := digestlib.Digest(sourcev1.TransformLegacyRevision(artifact.Revision))
|
curRev := digest.Digest(sourcev1.TransformLegacyRevision(artifact.Revision))
|
||||||
changed = curRev.Validate() != nil || curRev != chartRepo.Revision(curRev.Algorithm())
|
changed = curRev.Validate() != nil || curRev != chartRepo.Revision(curRev.Algorithm())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate revision.
|
// Calculate revision.
|
||||||
revision := chartRepo.Revision(digest.Canonical)
|
revision := chartRepo.Revision(intdigest.Canonical)
|
||||||
if revision.Validate() != nil {
|
if revision.Validate() != nil {
|
||||||
e := &serror.Event{
|
e := &serror.Event{
|
||||||
Err: fmt.Errorf("failed to calculate revision: %w", err),
|
Err: fmt.Errorf("failed to calculate revision: %w", err),
|
||||||
|
|
|
@ -21,10 +21,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fluxcd/source-controller/internal/cache"
|
|
||||||
"github.com/fluxcd/source-controller/internal/digest"
|
|
||||||
digestlib "github.com/opencontainers/go-digest"
|
|
||||||
"helm.sh/helm/v3/pkg/repo"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -33,7 +29,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/opencontainers/go-digest"
|
||||||
helmgetter "helm.sh/helm/v3/pkg/getter"
|
helmgetter "helm.sh/helm/v3/pkg/getter"
|
||||||
|
"helm.sh/helm/v3/pkg/repo"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -50,6 +48,8 @@ import (
|
||||||
"github.com/fluxcd/pkg/runtime/patch"
|
"github.com/fluxcd/pkg/runtime/patch"
|
||||||
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
|
"github.com/fluxcd/source-controller/internal/cache"
|
||||||
|
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
||||||
"github.com/fluxcd/source-controller/internal/helm/getter"
|
"github.com/fluxcd/source-controller/internal/helm/getter"
|
||||||
"github.com/fluxcd/source-controller/internal/helm/repository"
|
"github.com/fluxcd/source-controller/internal/helm/repository"
|
||||||
sreconcile "github.com/fluxcd/source-controller/internal/reconcile"
|
sreconcile "github.com/fluxcd/source-controller/internal/reconcile"
|
||||||
|
@ -316,7 +316,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
server options
|
server options
|
||||||
url string
|
url string
|
||||||
secret *corev1.Secret
|
secret *corev1.Secret
|
||||||
beforeFunc func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digestlib.Digest)
|
beforeFunc func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digest.Digest)
|
||||||
afterFunc func(t *WithT, obj *sourcev1.HelmRepository, artifact sourcev1.Artifact, chartRepo *repository.ChartRepository)
|
afterFunc func(t *WithT, obj *sourcev1.HelmRepository, artifact sourcev1.Artifact, chartRepo *repository.ChartRepository)
|
||||||
want sreconcile.Result
|
want sreconcile.Result
|
||||||
wantErr bool
|
wantErr bool
|
||||||
|
@ -371,7 +371,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
"password": []byte("1234"),
|
"password": []byte("1234"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "basic-auth"}
|
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "basic-auth"}
|
||||||
},
|
},
|
||||||
want: sreconcile.ResultSuccess,
|
want: sreconcile.ResultSuccess,
|
||||||
|
@ -402,7 +402,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
"caFile": tlsCA,
|
"caFile": tlsCA,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "ca-file"}
|
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "ca-file"}
|
||||||
},
|
},
|
||||||
want: sreconcile.ResultSuccess,
|
want: sreconcile.ResultSuccess,
|
||||||
|
@ -433,7 +433,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
"caFile": []byte("invalid"),
|
"caFile": []byte("invalid"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "invalid-ca"}
|
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "invalid-ca"}
|
||||||
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
||||||
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
||||||
|
@ -455,7 +455,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Invalid URL makes FetchFailed=True and returns stalling error",
|
name: "Invalid URL makes FetchFailed=True and returns stalling error",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.URL = strings.ReplaceAll(obj.Spec.URL, "http://", "")
|
obj.Spec.URL = strings.ReplaceAll(obj.Spec.URL, "http://", "")
|
||||||
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
||||||
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
||||||
|
@ -478,7 +478,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Unsupported scheme makes FetchFailed=True and returns stalling error",
|
name: "Unsupported scheme makes FetchFailed=True and returns stalling error",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.URL = strings.ReplaceAll(obj.Spec.URL, "http://", "ftp://")
|
obj.Spec.URL = strings.ReplaceAll(obj.Spec.URL, "http://", "ftp://")
|
||||||
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
||||||
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
||||||
|
@ -501,7 +501,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Missing secret returns FetchFailed=True and returns error",
|
name: "Missing secret returns FetchFailed=True and returns error",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "non-existing"}
|
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "non-existing"}
|
||||||
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
||||||
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
||||||
|
@ -531,7 +531,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
"username": []byte("git"),
|
"username": []byte("git"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "malformed-basic-auth"}
|
obj.Spec.SecretRef = &meta.LocalObjectReference{Name: "malformed-basic-auth"}
|
||||||
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
conditions.MarkReconciling(obj, meta.ProgressingReason, "foo")
|
||||||
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
conditions.MarkUnknown(obj, meta.ReadyCondition, "foo", "bar")
|
||||||
|
@ -553,7 +553,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Stored index with same digest and revision",
|
name: "Stored index with same digest and revision",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digest.Digest) {
|
||||||
obj.Status.Artifact = &sourcev1.Artifact{
|
obj.Status.Artifact = &sourcev1.Artifact{
|
||||||
Revision: revision.String(),
|
Revision: revision.String(),
|
||||||
Digest: digest.String(),
|
Digest: digest.String(),
|
||||||
|
@ -579,7 +579,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Stored index with same checksum and (legacy) revision",
|
name: "Stored index with same checksum and (legacy) revision",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digest.Digest) {
|
||||||
obj.Status.Artifact = &sourcev1.Artifact{
|
obj.Status.Artifact = &sourcev1.Artifact{
|
||||||
Revision: revision.Hex(),
|
Revision: revision.Hex(),
|
||||||
Checksum: digest.Hex(),
|
Checksum: digest.Hex(),
|
||||||
|
@ -604,7 +604,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Stored index with different digest and same revision",
|
name: "Stored index with different digest and same revision",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, digest digest.Digest) {
|
||||||
obj.Status.Artifact = &sourcev1.Artifact{
|
obj.Status.Artifact = &sourcev1.Artifact{
|
||||||
Revision: revision.String(),
|
Revision: revision.String(),
|
||||||
Digest: "sha256:80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
Digest: "sha256:80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
||||||
|
@ -632,7 +632,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Stored index with different revision and digest",
|
name: "Stored index with different revision and digest",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Status.Artifact = &sourcev1.Artifact{
|
obj.Status.Artifact = &sourcev1.Artifact{
|
||||||
Revision: "80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
Revision: "80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
||||||
Checksum: "80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
Checksum: "80bb3dd67c63095d985850459834ea727603727a370079de90d221191d375a86",
|
||||||
|
@ -660,7 +660,7 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Existing artifact makes ArtifactOutdated=True",
|
name: "Existing artifact makes ArtifactOutdated=True",
|
||||||
protocol: "http",
|
protocol: "http",
|
||||||
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digestlib.Digest) {
|
beforeFunc: func(t *WithT, obj *sourcev1.HelmRepository, revision, checksum digest.Digest) {
|
||||||
obj.Status.Artifact = &sourcev1.Artifact{
|
obj.Status.Artifact = &sourcev1.Artifact{
|
||||||
Path: "some-path",
|
Path: "some-path",
|
||||||
Revision: "some-rev",
|
Revision: "some-rev",
|
||||||
|
@ -769,13 +769,13 @@ func TestHelmRepositoryReconciler_reconcileSource(t *testing.T) {
|
||||||
|
|
||||||
// NOTE: checksum will be empty in beforeFunc for invalid repo
|
// NOTE: checksum will be empty in beforeFunc for invalid repo
|
||||||
// configurations as the client can't get the repo.
|
// configurations as the client can't get the repo.
|
||||||
var revision, checksum digestlib.Digest
|
var revision, checksum digest.Digest
|
||||||
if validSecret {
|
if validSecret {
|
||||||
g.Expect(newChartRepo.CacheIndex()).To(Succeed())
|
g.Expect(newChartRepo.CacheIndex()).To(Succeed())
|
||||||
checksum = newChartRepo.Digest(digest.Canonical)
|
checksum = newChartRepo.Digest(intdigest.Canonical)
|
||||||
|
|
||||||
g.Expect(newChartRepo.LoadFromPath()).To(Succeed())
|
g.Expect(newChartRepo.LoadFromPath()).To(Succeed())
|
||||||
revision = newChartRepo.Revision(digest.Canonical)
|
revision = newChartRepo.Revision(intdigest.Canonical)
|
||||||
}
|
}
|
||||||
if tt.beforeFunc != nil {
|
if tt.beforeFunc != nil {
|
||||||
tt.beforeFunc(g, obj, revision, checksum)
|
tt.beforeFunc(g, obj, revision, checksum)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
securejoin "github.com/cyphar/filepath-securejoin"
|
securejoin "github.com/cyphar/filepath-securejoin"
|
||||||
"github.com/fluxcd/go-git/v5/plumbing/format/gitignore"
|
"github.com/fluxcd/go-git/v5/plumbing/format/gitignore"
|
||||||
digestlib "github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kerrors "k8s.io/apimachinery/pkg/util/errors"
|
kerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import (
|
||||||
"github.com/fluxcd/pkg/untar"
|
"github.com/fluxcd/pkg/untar"
|
||||||
|
|
||||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
|
||||||
"github.com/fluxcd/source-controller/internal/digest"
|
intdigest "github.com/fluxcd/source-controller/internal/digest"
|
||||||
sourcefs "github.com/fluxcd/source-controller/internal/fs"
|
sourcefs "github.com/fluxcd/source-controller/internal/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ func (s *Storage) Archive(artifact *sourcev1.Artifact, dir string, filter Archiv
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
md, err := digest.NewMultiDigester(digest.Canonical, digestlib.SHA256)
|
md, err := intdigest.NewMultiDigester(intdigest.Canonical, digest.SHA256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create digester: %w", err)
|
return fmt.Errorf("failed to create digester: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -455,8 +455,8 @@ func (s *Storage) Archive(artifact *sourcev1.Artifact, dir string, filter Archiv
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
artifact.Digest = md.Digest(digest.Canonical).String()
|
artifact.Digest = md.Digest(intdigest.Canonical).String()
|
||||||
artifact.Checksum = md.Digest(digestlib.SHA256).Encoded()
|
artifact.Checksum = md.Digest(digest.SHA256).Encoded()
|
||||||
artifact.LastUpdateTime = metav1.Now()
|
artifact.LastUpdateTime = metav1.Now()
|
||||||
artifact.Size = &sz.written
|
artifact.Size = &sz.written
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ func (s *Storage) AtomicWriteFile(artifact *sourcev1.Artifact, reader io.Reader,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
md, err := digest.NewMultiDigester(digest.Canonical, digestlib.SHA256)
|
md, err := intdigest.NewMultiDigester(intdigest.Canonical, digest.SHA256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create digester: %w", err)
|
return fmt.Errorf("failed to create digester: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -501,8 +501,8 @@ func (s *Storage) AtomicWriteFile(artifact *sourcev1.Artifact, reader io.Reader,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
artifact.Digest = md.Digest(digest.Canonical).String()
|
artifact.Digest = md.Digest(intdigest.Canonical).String()
|
||||||
artifact.Checksum = md.Digest(digestlib.SHA256).Encoded()
|
artifact.Checksum = md.Digest(digest.SHA256).Encoded()
|
||||||
artifact.LastUpdateTime = metav1.Now()
|
artifact.LastUpdateTime = metav1.Now()
|
||||||
artifact.Size = &sz.written
|
artifact.Size = &sz.written
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ func (s *Storage) Copy(artifact *sourcev1.Artifact, reader io.Reader) (err error
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
md, err := digest.NewMultiDigester(digest.Canonical, digestlib.SHA256)
|
md, err := intdigest.NewMultiDigester(intdigest.Canonical, digest.SHA256)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create digester: %w", err)
|
return fmt.Errorf("failed to create digester: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -543,8 +543,8 @@ func (s *Storage) Copy(artifact *sourcev1.Artifact, reader io.Reader) (err error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
artifact.Digest = md.Digest(digest.Canonical).String()
|
artifact.Digest = md.Digest(intdigest.Canonical).String()
|
||||||
artifact.Checksum = md.Digest(digestlib.SHA256).Encoded()
|
artifact.Checksum = md.Digest(digest.SHA256).Encoded()
|
||||||
artifact.LastUpdateTime = metav1.Now()
|
artifact.LastUpdateTime = metav1.Now()
|
||||||
artifact.Size = &sz.written
|
artifact.Size = &sz.written
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
digestlib "github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"helm.sh/helm/v3/pkg/chart"
|
"helm.sh/helm/v3/pkg/chart"
|
||||||
helmgetter "helm.sh/helm/v3/pkg/getter"
|
helmgetter "helm.sh/helm/v3/pkg/getter"
|
||||||
"helm.sh/helm/v3/pkg/repo"
|
"helm.sh/helm/v3/pkg/repo"
|
||||||
|
@ -512,7 +512,7 @@ func TestChartRepository_Revision(t *testing.T) {
|
||||||
r := newChartRepository()
|
r := newChartRepository()
|
||||||
r.Index = repo.NewIndexFile()
|
r.Index = repo.NewIndexFile()
|
||||||
|
|
||||||
for _, algo := range []digestlib.Algorithm{digestlib.SHA256, digestlib.SHA512} {
|
for _, algo := range []digest.Algorithm{digest.SHA256, digest.SHA512} {
|
||||||
t.Run(algo.String(), func(t *testing.T) {
|
t.Run(algo.String(), func(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
|
@ -528,14 +528,14 @@ func TestChartRepository_Revision(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
r := newChartRepository()
|
r := newChartRepository()
|
||||||
g.Expect(r.Revision(digestlib.SHA256)).To(BeEmpty())
|
g.Expect(r.Revision(digest.SHA256)).To(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("from cache", func(t *testing.T) {
|
t.Run("from cache", func(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
algo := digestlib.SHA256
|
algo := digest.SHA256
|
||||||
expect := digestlib.Digest("sha256:fake")
|
expect := digest.Digest("sha256:fake")
|
||||||
|
|
||||||
r := newChartRepository()
|
r := newChartRepository()
|
||||||
r.Index = repo.NewIndexFile()
|
r.Index = repo.NewIndexFile()
|
||||||
|
@ -555,7 +555,7 @@ func TestChartRepository_Digest(t *testing.T) {
|
||||||
r := newChartRepository()
|
r := newChartRepository()
|
||||||
r.Path = p
|
r.Path = p
|
||||||
|
|
||||||
for _, algo := range []digestlib.Algorithm{digestlib.SHA256, digestlib.SHA512} {
|
for _, algo := range []digest.Algorithm{digest.SHA256, digest.SHA512} {
|
||||||
t.Run(algo.String(), func(t *testing.T) {
|
t.Run(algo.String(), func(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
|
@ -571,14 +571,14 @@ func TestChartRepository_Digest(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
r := newChartRepository()
|
r := newChartRepository()
|
||||||
g.Expect(r.Digest(digestlib.SHA256)).To(BeEmpty())
|
g.Expect(r.Digest(digest.SHA256)).To(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("from cache", func(t *testing.T) {
|
t.Run("from cache", func(t *testing.T) {
|
||||||
g := NewWithT(t)
|
g := NewWithT(t)
|
||||||
|
|
||||||
algo := digestlib.SHA256
|
algo := digest.SHA256
|
||||||
expect := digestlib.Digest("sha256:fake")
|
expect := digest.Digest("sha256:fake")
|
||||||
|
|
||||||
i := filepath.Join(t.TempDir(), "index.yaml")
|
i := filepath.Join(t.TempDir(), "index.yaml")
|
||||||
g.Expect(os.WriteFile(i, []byte(`apiVersion: v1`), 0o644)).To(Succeed())
|
g.Expect(os.WriteFile(i, []byte(`apiVersion: v1`), 0o644)).To(Succeed())
|
||||||
|
|
Loading…
Reference in New Issue