Reputation: 11
cli, err := client.NewClientWithOpts(client.WithVersion("1.40"))
if err != nil {
return "", err
}
defer cli.Close()
authConfig := types.AuthConfig{
Username: "xxx",
Password: "xxx",
}
buildCtx, _ := archive.TarWithOptions("./", &archive.TarOptions{
ExcludePatterns: []string{".git"},
})
plain := "plain"
buildOpts := types.ImageBuildOptions{
Version: types.BuilderBuildKit,
Tags: []string{image},
BuildArgs: map[string]*string{
"progress": &plain,
},
AuthConfigs: map[string]types.AuthConfig{
f.CONFIG.HARBOR.Url: authConfig,
},
}
ctxWithTimeout, _ := context.WithTimeout(context.TODO(), time.Second*1800)
buildResponse, err := cli.ImageBuild(ctxWithTimeout, buildCtx, buildOpts)
if err != nil {
return "", err
}
hi,these code work well on Harbor API 1.9.0 but it cant work on Harbor API 2.0 i have read https://docs.docker.com/registry/spec/auth/token/ but still cant solve this problem look for some help thx
btw the username and password is correct
Upvotes: 1
Views: 99