Compare commits
No commits in common. "fbe182580e28e0a0291c4cff0c2637d853807c4c" and "a4cb4bf42537cd409a9bce6ec32a8b833e98264d" have entirely different histories.
fbe182580e
...
a4cb4bf425
2 changed files with 3 additions and 27 deletions
|
@ -7,9 +7,11 @@ registry.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
delete-tag:
|
delete-tag:
|
||||||
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin
|
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin/plugin
|
||||||
secrets: [token]
|
secrets: [token]
|
||||||
settings:
|
settings:
|
||||||
|
token:
|
||||||
|
from_secret: scaleway_token
|
||||||
image-name: foo/bar
|
image-name: foo/bar
|
||||||
tag: latest
|
tag: latest
|
||||||
region: fr-par
|
region: fr-par
|
||||||
|
|
26
main.go
26
main.go
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -55,14 +54,6 @@ func (p *Plugin) Flags() []cli.Flag {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) Execute(ctx context.Context) error {
|
func (p *Plugin) Execute(ctx context.Context) error {
|
||||||
missingFlags := requiredFlags(p.Settings)
|
|
||||||
if len(missingFlags) != 0 {
|
|
||||||
log.Error().Msg("following flags are missing:")
|
|
||||||
for _, errMsg := range missingFlags {
|
|
||||||
log.Error().Msg("-" + errMsg)
|
|
||||||
}
|
|
||||||
return errors.New("missing required flags")
|
|
||||||
}
|
|
||||||
log.Info().Msg("start")
|
log.Info().Msg("start")
|
||||||
token := p.Settings.Token
|
token := p.Settings.Token
|
||||||
region := p.Settings.Region
|
region := p.Settings.Region
|
||||||
|
@ -87,23 +78,6 @@ func (p *Plugin) Execute(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func requiredFlags(settings *Settings) []string {
|
|
||||||
var errorList []string
|
|
||||||
if settings.ImageName == "" {
|
|
||||||
errorList = append(errorList, "image-name")
|
|
||||||
}
|
|
||||||
if settings.Tag == "" {
|
|
||||||
errorList = append(errorList, "tag")
|
|
||||||
}
|
|
||||||
if settings.Region == "" {
|
|
||||||
errorList = append(errorList, "region")
|
|
||||||
}
|
|
||||||
if settings.Token == "" {
|
|
||||||
errorList = append(errorList, "token")
|
|
||||||
}
|
|
||||||
return errorList
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
p := &Plugin{
|
p := &Plugin{
|
||||||
Settings: &Settings{},
|
Settings: &Settings{},
|
||||||
|
|
Loading…
Reference in a new issue