mirror of https://github.com/knative/func.git
Fix digest regex
Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
b4ba7f694b
commit
2f63fae705
|
@ -67,7 +67,7 @@ func (n *Pusher) Push(f bosonFunc.Function) (digest string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
var digestRE = regexp.MustCompile(`digest:\s+sha256:(?P<Digest>\w{64})`)
|
||||
var digestRE = regexp.MustCompile(`digest:\s+(sha256:\w{64})`)
|
||||
|
||||
// parseDigest tries to parse the last line from the output, which holds the pushed image digest
|
||||
// The output should contain line like this:
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package docker
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_parseDigest(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
arg string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "basic test",
|
||||
arg: "latest: digest: sha256:a278a91112d17f8bde6b5f802a3317c7c752cf88078dae6f4b5a0784deb81782 size: 2613",
|
||||
want: "sha256:a278a91112d17f8bde6b5f802a3317c7c752cf88078dae6f4b5a0784deb81782",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := parseDigest(tt.arg); got != tt.want {
|
||||
t.Errorf("parseDigest() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue