From 06513ea73e937cca6d11a50d74a95ebd34416e33 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sun, 6 Aug 2023 14:44:40 +0000 Subject: [PATCH] lint --- _docs/data/data.yaml | 2 +- plugin/docker.go | 2 +- plugin/impl.go | 32 +++++++++++++++----------------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index bdeba40..054becb 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -296,7 +296,7 @@ properties: - name: registries description: | - Credentials for registries. Ignored if password was set. + Credentials for registries. Example: ```yaml diff --git a/plugin/docker.go b/plugin/docker.go index 3d43e31..3b2c0fa 100644 --- a/plugin/docker.go +++ b/plugin/docker.go @@ -140,7 +140,7 @@ func commandBuild(build Build, dryrun bool) *execabs.Cmd { args = append(args, "--platform", strings.Join(build.Platforms.Value(), ",")) } - for _, repo := range build.Repo.Value() { + for _, repo := range build.Repo.Value() { for _, arg := range build.Tags.Value() { args = append(args, "-t", fmt.Sprintf("%s:%s", repo, arg)) } diff --git a/plugin/impl.go b/plugin/impl.go index 059bd17..68280f4 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -45,7 +45,7 @@ type RegistryData struct { } type RegistriesYaml struct { - Registries []RegistryData + Registries []RegistryData `yaml:"registries"` } // Build defines Docker build parameters. @@ -186,26 +186,24 @@ func (p *Plugin) Execute() error { } if p.settings.Login.RegistriesYaml != "" { - if p.settings.Login.Password == "" { - var t RegistriesYaml - err := yaml.Unmarshal([]byte(p.settings.Login.RegistriesYaml), &t) - if err != nil { - return fmt.Errorf("error unmarshal registries: %w", err) + 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/" } - for _, registryData := range t.Registries { - if registryData.Registry == "" { - registryData.Registry = "https://index.docker.io/v1/" - } + cmd := commandLogin(registryData) - cmd := commandLogin(registryData) - err := cmd.Run() - if err != nil { - return fmt.Errorf("error authenticating: %w", err) - } + err := cmd.Run() + if err != nil { + return fmt.Errorf("error authenticating: %w", err) } - } else { - logrus.Warn("Cannot use password and registries at same time!") } }