FromString creates an Image using a string representation
(str string)
| 84 | |
| 85 | // FromString creates an Image using a string representation |
| 86 | func FromString(str string) (*Image, error) { |
| 87 | named, err := reference.ParseNamed(str) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | |
| 92 | // check for tag |
| 93 | hasTag := !isNameOnly(named) |
| 94 | |
| 95 | // implicit default tag |
| 96 | tagged := withDefaultTag(named) |
| 97 | |
| 98 | return &Image{ |
| 99 | image: tagged.(reference.NamedTagged), |
| 100 | tag: hasTag, |
| 101 | }, nil |
| 102 | } |
| 103 | |
| 104 | // Implementations below from docker/docker upstream |
| 105 | // TODO: once kubernetes updates Docker version these should be removed and use "github.com/docker/docker/reference" |