Compare commits
3 commits
a4cb4bf425
...
fbe182580e
Author | SHA1 | Date | |
---|---|---|---|
fbe182580e | |||
4448d3afa1 | |||
a603a56306 |
2 changed files with 27 additions and 3 deletions
|
@ -7,11 +7,9 @@ registry.
|
|||
|
||||
```yaml
|
||||
delete-tag:
|
||||
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin/plugin
|
||||
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin
|
||||
secrets: [token]
|
||||
settings:
|
||||
token:
|
||||
from_secret: scaleway_token
|
||||
image-name: foo/bar
|
||||
tag: latest
|
||||
region: fr-par
|
||||
|
|
26
main.go
26
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -54,6 +55,14 @@ func (p *Plugin) Flags() []cli.Flag {
|
|||
}
|
||||
|
||||
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")
|
||||
token := p.Settings.Token
|
||||
region := p.Settings.Region
|
||||
|
@ -78,6 +87,23 @@ func (p *Plugin) Execute(ctx context.Context) error {
|
|||
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() {
|
||||
p := &Plugin{
|
||||
Settings: &Settings{},
|
||||
|
|
Loading…
Reference in a new issue