diff --git a/_docs/content/_index.md b/_docs/content/_index.md index d9ecb25..ce1585e 100644 --- a/_docs/content/_index.md +++ b/_docs/content/_index.md @@ -95,36 +95,6 @@ steps: tags: latest ``` -**Multiple registries:** - -```yaml -kind: pipeline -name: default - -steps: - - name: docker - image: thegeeklab/drone-docker-buildx:23 - privileged: true - environment: - DOCKER_REGISTRY_PASSWORD: - from_secret: docker_registry_password - GITHUB_REGISTRY_PASSWORD: - from_secret: github_registry_password - settings: - repo: - - octocat/example - - ghcr.io/octocat/example - tags: latest - registries: | - registries: - - username: "octocat" - password: "$DOCKER_REGISTRY_PASSWORD" - - registry: "ghcr.io" - username: "octocat" - password: "$GITHUB_REGISTRY_PASSWORD" -``` - - ## Build Build the binary with the following command: diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index fea75e6..5981499 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -208,7 +208,7 @@ properties: description: | Repository name for the image. If the image is to be pushed to registries other than the default DockerHub, it is necessary to set `repo` as fully-qualified name. - type: list + type: string required: false - name: registry @@ -293,8 +293,3 @@ properties: This should be used with caution and avoided whenever possible. type: list required: false - - - name: registries - description: Credentials for multiple registries described in YAML format. Check out the Examples for more information. - type: string - required: false \ No newline at end of file diff --git a/cmd/drone-docker-buildx/config.go b/cmd/drone-docker-buildx/config.go index afb3d8d..8cc5415 100644 --- a/cmd/drone-docker-buildx/config.go +++ b/cmd/drone-docker-buildx/config.go @@ -235,7 +235,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Destination: &settings.Build.Compress, Category: category, }, - &cli.StringSliceFlag{ + &cli.StringFlag{ Name: "repo", EnvVars: []string{"PLUGIN_REPO"}, Usage: "repository name for the image", @@ -328,12 +328,5 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag { Value: &drone.StringSliceFlag{}, Category: category, }, - &cli.StringFlag{ - Name: "docker.registries", - EnvVars: []string{"PLUGIN_REGISTRIES"}, - Usage: "credentials for registries", - Destination: &settings.Login.RegistriesYaml, - Category: category, - }, } } diff --git a/go.mod b/go.mod index f643a76..4557394 100644 --- a/go.mod +++ b/go.mod @@ -15,5 +15,4 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - gopkg.in/yaml.v3 v3.0.1 ) diff --git a/plugin/docker.go b/plugin/docker.go index 3b2c0fa..01db78d 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -11,7 +11,7 @@ import ( ) // helper function to create the docker login command. -func commandLogin(login RegistryData) *execabs.Cmd { +func commandLogin(login Login) *execabs.Cmd { if login.Email != "" { return commandLoginEmail(login) } @@ -28,7 +28,7 @@ func commandLogin(login RegistryData) *execabs.Cmd { ) } -func commandLoginEmail(login RegistryData) *execabs.Cmd { +func commandLoginEmail(login Login) *execabs.Cmd { args := []string{ "login", "-u", login.Username, @@ -140,10 +140,8 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd { args = append(args, "--platform", strings.Join(build.Platforms.Value(), ",")) } - for _, repo := range build.Repo.Value() { - for _, arg := range build.Tags.Value() { - args = append(args, "-t", fmt.Sprintf("%s:%s", repo, arg)) - } + for _, arg := range build.Tags.Value() { + args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg)) } for _, arg := range build.ExtraTags.Value() { diff --git a/plugin/impl.go b/plugin/impl.go index ca82cf7..6651bac 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -9,7 +9,6 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "golang.org/x/sys/execabs" - "gopkg.in/yaml.v3" ) // Daemon defines Docker daemon parameters. @@ -32,20 +31,11 @@ type Daemon struct { // Login defines Docker login parameters. type Login struct { - RegistryData - Config string // Docker Auth Config - RegistriesYaml string // Docker Auth with YAML config -} - -type RegistryData struct { Registry string // Docker registry address Username string // Docker registry username Password string // Docker registry password Email string // Docker registry email -} - -type RegistriesYaml struct { - Registries []RegistryData `yaml:"registries"` + Config string // Docker Auth Config } // Build defines Docker build parameters. @@ -66,7 +56,7 @@ type Build struct { CacheFrom []string // Docker build cache-from CacheTo string // Docker build cache-to Compress bool // Docker build compress - Repo cli.StringSlice // Docker build repositories + Repo string // Docker build repository NoCache bool // Docker build no-cache AddHost cli.StringSlice // Docker build add-host Quiet bool // Docker build quiet @@ -177,7 +167,7 @@ func (p *Plugin) Execute() error { // login to the Docker registry if p.settings.Login.Password != "" { - cmd := commandLogin(p.settings.Login.RegistryData) + cmd := commandLogin(p.settings.Login) err := cmd.Run() if err != nil { @@ -185,28 +175,6 @@ func (p *Plugin) Execute() error { } } - if p.settings.Login.RegistriesYaml != "" { - var t RegistriesYaml - - err := yaml.Unmarshal([]byte(p.settings.Login.RegistriesYaml), &t) - if err != nil { - return fmt.Errorf("error unmarshal registries: %w", err) - } - - for _, registryData := range t.Registries { - if registryData.Registry == "" { - registryData.Registry = "https://index.docker.io/v1/" - } - - cmd := commandLogin(registryData) - - err := cmd.Run() - if err != nil { - return fmt.Errorf("error authenticating: %w", err) - } - } - } - if p.settings.Daemon.BuildkitConfig != "" { err := os.WriteFile(buildkitConfig, []byte(p.settings.Daemon.BuildkitConfig), strictFilePerm) if err != nil { @@ -217,8 +185,6 @@ func (p *Plugin) Execute() error { switch { case p.settings.Login.Password != "": logrus.Info("Detected registry credentials") - case p.settings.Login.RegistriesYaml != "": - logrus.Info("Detected multiple registry credentials") case p.settings.Login.Config != "": logrus.Info("Detected registry credentials file") default: