Created
November 25, 2021 06:26
-
-
Save shiimaxx/c8efe5e8abc907158c9720431af50c03 to your computer and use it in GitHub Desktop.
liyunContainerService/image-syncer で docker.io/ubuntu:20.04 のコンテナイメージを ECR に同期する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/AliyunContainerService/image-syncer/pkg/sync" | |
"github.com/AliyunContainerService/image-syncer/pkg/tools" | |
"github.com/sirupsen/logrus" | |
) | |
func main() { | |
logger := logrus.New() | |
dockerURL := "docker.io/ubuntu:20.04" | |
srcURL, err := tools.NewRepoURL(dockerURL) | |
if err != nil { | |
panic(err) | |
} | |
imageSource, err := sync.NewImageSource( | |
srcURL.GetRegistry(), | |
srcURL.GetRepoWithNamespace(), | |
srcURL.GetTag(), | |
"", | |
"", | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
ecrURL := "xxxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/ubuntu:20.04" | |
destURL, err := tools.NewRepoURL(ecrURL) | |
if err != nil { | |
panic(err) | |
} | |
ecrPassword := "password" | |
imageDestination, err := sync.NewImageDestination( | |
destURL.GetRegistry(), | |
destURL.GetRepoWithNamespace(), | |
destURL.GetTag(), | |
"AWS", | |
ecrPassword, | |
false, | |
) | |
if err != nil { | |
panic(err) | |
} | |
task := sync.NewTask(imageSource, imageDestination, []string{}, []string{}, logger) | |
if err := task.Run(); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment