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
|
```yaml
|
||||||
delete-tag:
|
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]
|
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,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -54,6 +55,14 @@ 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
|
||||||
|
@ -78,6 +87,23 @@ 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