Skip to content

harrypunk/copy-image-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy container image with google/go-containerregistry

An example of copying docker image, with simple username password, between two registries with crane.

TL,DR

Use multiple keychain and implement KeyChain interface

func (obj MyOjbect) Resolve(target authn.Resource) (authn.Authenticator, error) {
	reg := target.RegistryStr()
	if strings.Contains(src url, reg) {
		return &authn.Basic{
			Username: src username,
			Password: src password,
		}, nil
	} else {
		return &authn.Basic{
			Username: dest username,
			Password: dest password,
		}, nil
	}
}

func main() {
    	_ = crane.Copy(src url, dest url, crane.WithAuthFromKeychain(obj))
}

Credits

Releases

No releases published

Packages

No packages published