Merge pull request #683 from fluxcd/fix-panic
This commit is contained in:
commit
0836d882ba
|
@ -255,14 +255,17 @@ func (r *HelmRepositoryReconciler) notify(oldObj, newObj *sourcev1.HelmRepositor
|
|||
sourcev1.GroupVersion.Group + "/checksum": newObj.Status.Artifact.Checksum,
|
||||
}
|
||||
|
||||
size := units.HumanSize(float64(*newObj.Status.Artifact.Size))
|
||||
humanReadableSize := "unknown size"
|
||||
if size := newObj.Status.Artifact.Size; size != nil {
|
||||
humanReadableSize = fmt.Sprintf("size %s", units.HumanSize(float64(*size)))
|
||||
}
|
||||
|
||||
var oldChecksum string
|
||||
if oldObj.GetArtifact() != nil {
|
||||
oldChecksum = oldObj.GetArtifact().Checksum
|
||||
}
|
||||
|
||||
message := fmt.Sprintf("stored fetched index of size %s from '%s'", size, chartRepo.URL)
|
||||
message := fmt.Sprintf("stored fetched index of %s from '%s'", humanReadableSize, chartRepo.URL)
|
||||
|
||||
// Notify on new artifact and failure recovery.
|
||||
if oldChecksum != newObj.GetArtifact().Checksum {
|
||||
|
|
|
@ -859,6 +859,15 @@ func TestHelmRepositoryReconciler_notify(t *testing.T) {
|
|||
res: sreconcile.ResultEmpty,
|
||||
resErr: errors.New("some error"),
|
||||
},
|
||||
{
|
||||
name: "new artifact with nil size",
|
||||
res: sreconcile.ResultSuccess,
|
||||
resErr: nil,
|
||||
newObjBeforeFunc: func(obj *sourcev1.HelmRepository) {
|
||||
obj.Status.Artifact = &sourcev1.Artifact{Revision: "xxx", Checksum: "yyy", Size: nil}
|
||||
},
|
||||
wantEvent: "Normal NewArtifact stored fetched index of unknown size",
|
||||
},
|
||||
{
|
||||
name: "new artifact",
|
||||
res: sreconcile.ResultSuccess,
|
||||
|
|
Loading…
Reference in New Issue