Skip to content

Commit

Permalink
Merge pull request acorn-io#1718 from iwilltry42/iwilltry42/issue1563
Browse files Browse the repository at this point in the history
fix: resolvelocal should always return full ID if image is found (acorn-io#1563)
  • Loading branch information
cjellick authored Jun 7, 2023
2 parents 2b477e2 + 2abd810 commit 7882f4c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
35 changes: 35 additions & 0 deletions integration/client/apps/apps_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package apps

import (
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -461,3 +462,37 @@ func TestAppRun(t *testing.T) {
assert.Equal(t, "secret", app.Spec.Secrets[0].Secret)
assert.Equal(t, "value", app.Spec.DeployArgs["key"])
}

func TestAppRunImageVariations(t *testing.T) {
helper.EnsureCRDs(t)
restConfig := helper.StartAPI(t)

ctx := helper.GetCTX(t)
kclient := helper.MustReturn(kclient.Default)
ns := helper.TempNamespace(t, kclient)

imageID := client2.NewImage(t, ns.Name)

c, err := client.New(restConfig, "", ns.Name)
if err != nil {
t.Fatal(err)
}

if err := c.ImageTag(ctx, imageID, "foo/bar:baz"); err != nil {
t.Fatal(err)
}

imageNames := []string{
"foo/bar:baz",
imageID,
fmt.Sprintf("sha256:%s", imageID),
imageID[:8],
}

for _, imageName := range imageNames {
_, err := c.AppRun(ctx, imageName, nil)
if err != nil {
t.Fatal(err)
}
}
}
6 changes: 2 additions & 4 deletions pkg/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ func ResolveLocal(ctx context.Context, c kclient.Client, namespace, image string
if IsLocalReference(image) {
return "", false, err
}
return image, false, nil
} else if err != nil {
return "", false, err
} else if !localImage.Remote {
// The name will match the name we used to lookup, so trim the digest
return strings.TrimPrefix(localImage.Digest, "sha256:"), true, nil
}
return image, false, nil
return strings.TrimPrefix(localImage.Digest, "sha256:"), !localImage.Remote, nil
}

0 comments on commit 7882f4c

Please sign in to comment.