11package plugin
22
33import (
4- "encoding/json"
54 "fmt"
65 "os"
76 "path/filepath"
@@ -32,17 +31,11 @@ type Daemon struct {
3231
3332// Login defines Docker login parameters.
3433type 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.
9282func (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 :
0 commit comments