Compare commits

..

4 commits

Author SHA1 Message Date
6d2e7d3b92 Add Woodpecker CI pipeline
Some checks failed
ci/woodpecker/push/oci-image-build/1 Pipeline failed
ci/woodpecker/push/oci-image-build/2 Pipeline failed
2024-02-18 13:46:07 +01:00
6b5fb372e4 Add Dockerfile 2024-02-18 13:44:01 +01:00
cc9b4b7b4c Add project README 2024-02-18 13:43:21 +01:00
d0ba75af22 Fix flags name
Didn't understand the usage bevor.
2024-02-18 13:42:29 +01:00
4 changed files with 75 additions and 7 deletions

View file

@ -0,0 +1,25 @@
matrix:
PLATFORM:
- linux/amd64
- linux/arm64
labels:
platform: linux/amd64
steps:
build:
image: woodpeckerci/plugin-docker-buildx:2.3.0
group: build
settings:
registry: rg.fr-par.scw.cloud/hamburghammer
username: nologin
password:
from_secret: docker_token
dockerfile: Dockerfile
target: setup-image
repo: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin/plugin
tags: latest
pull_image: true
platforms: ${PLATFORM}
when:
- branch: main

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM docker.io/golang:1.21.5 AS build
WORKDIR /src
# create a cache
COPY go.* /src/
RUN go mod download
# compile
COPY * /src/
RUN CGO_ENABLED=0 go build -o /scaleway-delete-image-plugin .
FROM alpine:3.19
RUN apk -Uuv add curl ca-certificates
COPY --from=build /src/scaleway-delete-image-plugin /scaleway-delete-image-plugin
ENTRYPOINT /scaleway-delete-image-plugin

29
README.md Normal file
View file

@ -0,0 +1,29 @@
# Scaleway-Delete-Image-Plugin
Is a plugin for Woodpecker CI to delete an image tag from the Scaleway container
registry.
## Usage
```yaml
delete-tag:
image: rg.fr-par.scw.cloud/hamburghammer/scaleway-delete-image-plugin/plugin
secrets: [token]
settings:
token:
from_secret: scaleway_token
image-name: foo/bar
tag: latest
region: fr-par
```
## Configuration
Required options:
| Name | Description |
| ---------- | --------------------------------------- |
| token | Token for the Scaleway API |
| image-name | The image which should be deleted |
| tag | The tag that should be deleted |
| region | The Scaleway region the registry exists |

15
main.go
View file

@ -27,25 +27,26 @@ type Plugin struct {
func (p *Plugin) Flags() []cli.Flag { func (p *Plugin) Flags() []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "Scaleway API token", Name: "token",
Usage: "Token for the Scaleway API",
EnvVars: []string{"PLUGIN_TOKEN"}, EnvVars: []string{"PLUGIN_TOKEN"},
Destination: &p.Settings.Token, Destination: &p.Settings.Token,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "The image name to be deleted", Name: "image-name",
Usage: "hamburghammer/dchat/setup-image", Usage: "The image from which the tag should be deleted",
EnvVars: []string{"PLUGIN_IMAGE_NAME"}, EnvVars: []string{"PLUGIN_IMAGE_NAME"},
Destination: &p.Settings.ImageName, Destination: &p.Settings.ImageName,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "Tag of the image", Name: "tag",
Usage: "hamburghammer/dchat/setup-image", Usage: "The tag that should be deleted",
EnvVars: []string{"PLUGIN_IMAGE_NAME"}, EnvVars: []string{"PLUGIN_IMAGE_NAME"},
Destination: &p.Settings.Tag, Destination: &p.Settings.Tag,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "The Scaleway region from the registry", Name: "region",
Usage: "fr-par", Usage: "The Scaleway region the registry exists",
EnvVars: []string{"PLUGIN_REGION"}, EnvVars: []string{"PLUGIN_REGION"},
Destination: &p.Settings.Region, Destination: &p.Settings.Region,
}, },