Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 0840812

Browse files
authored
chore: revert multi-registry support (#311)
1 parent 0cc14f4 commit 0840812

File tree

8 files changed

+11
-111
lines changed

8 files changed

+11
-111
lines changed

_docs/content/_index.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,6 @@ steps:
9595
tags: latest
9696
```
9797

98-
#### Push to multiple registries
99-
100-
```yaml
101-
kind: pipeline
102-
name: default
103-
104-
steps:
105-
- name: docker
106-
image: thegeeklab/drone-docker-buildx:23
107-
privileged: true
108-
settings:
109-
repo:
110-
- octocat/example
111-
- ghcr.io/octocat/example
112-
tags: latest
113-
registries:
114-
- username: octocat
115-
password: docker-password
116-
- registry: ghcr.io
117-
username: octocat
118-
password: ghrc-password
119-
```
120-
12198
## Build
12299

123100
Build the binary with the following command:

_docs/data/data.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ properties:
208208
description: |
209209
Repository name for the image. If the image is to be pushed to registries other than the default DockerHub,
210210
it is necessary to set `repo` as fully-qualified name.
211-
type: list
211+
type: string
212212
required: false
213213

214214
- name: registry
@@ -293,8 +293,3 @@ properties:
293293
This should be used with caution and avoided whenever possible.
294294
type: list
295295
required: false
296-
297-
- name: registries
298-
description: List of registry credentials. Check out the Examples for more information.
299-
type: list
300-
required: false

cmd/drone-docker-buildx/config.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
235235
Destination: &settings.Build.Compress,
236236
Category: category,
237237
},
238-
&cli.StringSliceFlag{
238+
&cli.StringFlag{
239239
Name: "repo",
240240
EnvVars: []string{"PLUGIN_REPO"},
241241
Usage: "repository name for the image",
@@ -246,7 +246,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
246246
Name: "docker.registry",
247247
EnvVars: []string{"PLUGIN_REGISTRY", "DOCKER_REGISTRY"},
248248
Usage: "docker registry to authenticate with",
249-
Value: plugin.DefaultRegistry,
249+
Value: "https://index.docker.io/v1/",
250250
Destination: &settings.Login.Registry,
251251
Category: category,
252252
},
@@ -328,13 +328,5 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
328328
Value: &drone.StringSliceFlag{},
329329
Category: category,
330330
},
331-
&cli.StringFlag{
332-
Name: "docker.registries",
333-
EnvVars: []string{"PLUGIN_REGISTRIES"},
334-
Usage: "credentials for registries",
335-
Value: "[]",
336-
Destination: &settings.Login.RegistriesRaw,
337-
Category: category,
338-
},
339331
}
340332
}

go.mod

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@ require (
66
github.com/coreos/go-semver v0.3.1
77
github.com/joho/godotenv v1.5.1
88
github.com/sirupsen/logrus v1.9.3
9-
github.com/stretchr/testify v1.7.0
109
github.com/thegeeklab/drone-plugin-lib/v2 v2.3.4
1110
github.com/urfave/cli/v2 v2.25.5
1211
golang.org/x/sys v0.11.0
1312
)
1413

15-
require (
16-
github.com/davecgh/go-spew v1.1.1 // indirect
17-
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
)
19-
2014
require (
2115
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
2216
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2317
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
24-
gopkg.in/yaml.v3 v3.0.1 // indirect
2518
)

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsr
2525
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2626
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
2727
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
28-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2928
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3029
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3130
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

plugin/docker.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// helper function to create the docker login command.
14-
func commandLogin(login RegistryData) *execabs.Cmd {
14+
func commandLogin(login Login) *execabs.Cmd {
1515
if login.Email != "" {
1616
return commandLoginEmail(login)
1717
}
@@ -28,7 +28,7 @@ func commandLogin(login RegistryData) *execabs.Cmd {
2828
)
2929
}
3030

31-
func commandLoginEmail(login RegistryData) *execabs.Cmd {
31+
func commandLoginEmail(login Login) *execabs.Cmd {
3232
args := []string{
3333
"login",
3434
"-u", login.Username,
@@ -140,10 +140,8 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd {
140140
args = append(args, "--platform", strings.Join(build.Platforms.Value(), ","))
141141
}
142142

143-
for _, repo := range build.Repo.Value() {
144-
for _, arg := range build.Tags.Value() {
145-
args = append(args, "-t", fmt.Sprintf("%s:%s", repo, arg))
146-
}
143+
for _, arg := range build.Tags.Value() {
144+
args = append(args, "-t", fmt.Sprintf("%s:%s", build.Repo, arg))
147145
}
148146

149147
for _, arg := range build.ExtraTags.Value() {

plugin/impl.go

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package plugin
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"os"
76
"path/filepath"
@@ -32,17 +31,11 @@ type Daemon struct {
3231

3332
// Login defines Docker login parameters.
3433
type Login struct {
35-
RegistryData
36-
Config string
37-
Registries []RegistryData
38-
RegistriesRaw string
39-
}
40-
41-
type RegistryData struct {
4234
Registry string // Docker registry address
4335
Username string // Docker registry username
4436
Password string // Docker registry password
4537
Email string // Docker registry email
38+
Config string // Docker Auth Config
4639
}
4740

4841
// Build defines Docker build parameters.
@@ -63,7 +56,7 @@ type Build struct {
6356
CacheFrom []string // Docker build cache-from
6457
CacheTo string // Docker build cache-to
6558
Compress bool // Docker build compress
66-
Repo cli.StringSlice // Docker build repositories
59+
Repo string // Docker build repository
6760
NoCache bool // Docker build no-cache
6861
AddHost cli.StringSlice // Docker build add-host
6962
Quiet bool // Docker build quiet
@@ -83,10 +76,7 @@ type Settings struct {
8376
Dryrun bool
8477
}
8578

86-
const (
87-
strictFilePerm = 0o600
88-
DefaultRegistry = "https://index.docker.io/v1/"
89-
)
79+
const strictFilePerm = 0o600
9080

9181
// Validate handles the settings validation of the plugin.
9282
func (p *Plugin) Validate() error {
@@ -118,16 +108,6 @@ func (p *Plugin) Validate() error {
118108
}
119109
}
120110

121-
if err := json.Unmarshal([]byte(p.settings.Login.RegistriesRaw), &p.settings.Login.Registries); err != nil {
122-
return fmt.Errorf("error unmarshal registries: %w", err)
123-
}
124-
125-
for i, registryData := range p.settings.Login.Registries {
126-
if registryData.Registry == "" {
127-
p.settings.Login.Registries[i].Registry = DefaultRegistry
128-
}
129-
}
130-
131111
return nil
132112
}
133113

@@ -187,16 +167,7 @@ func (p *Plugin) Execute() error {
187167

188168
// login to the Docker registry
189169
if p.settings.Login.Password != "" {
190-
cmd := commandLogin(p.settings.Login.RegistryData)
191-
192-
err := cmd.Run()
193-
if err != nil {
194-
return fmt.Errorf("error authenticating: %w", err)
195-
}
196-
}
197-
198-
for _, registryData := range p.settings.Login.Registries {
199-
cmd := commandLogin(registryData)
170+
cmd := commandLogin(p.settings.Login)
200171

201172
err := cmd.Run()
202173
if err != nil {
@@ -214,8 +185,6 @@ func (p *Plugin) Execute() error {
214185
switch {
215186
case p.settings.Login.Password != "":
216187
logrus.Info("Detected registry credentials")
217-
case len(p.settings.Login.Registries) > 0:
218-
logrus.Info("Detected multiple registry credentials")
219188
case p.settings.Login.Config != "":
220189
logrus.Info("Detected registry credentials file")
221190
default:

plugin/impl_test.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)