feat: add a post-registry-login trigger

This allows other plugins to execute commands after a registry has been authenticated against.
This commit is contained in:
Jose Diaz-Gonzalez
2024-01-18 22:25:23 -05:00
parent d89e2ba2bb
commit 98d0a95ae6
3 changed files with 33 additions and 0 deletions

View File

@@ -1757,6 +1757,20 @@ APP="$1"
haproxy-build-config "$APP"
```
### `post-registry-login`
- Description: Allows running a command after the a registry has been logged into
- Invoked by: `dokku registry:login`
- Arguments: `$DOCKER_REGISTRY_SERVER $DOCKER_REGISTRY_USER`
- Example:
```shell
#!/usr/bin/env bash
# the DOCKER_REGISTRY_PASS env var is also set
echo "$DOCKER_REGISTRY_PASS"
```
### `post-release-builder`
> [!WARNING]

View File

@@ -16,6 +16,7 @@ import (
type PlugnTriggerInput struct {
Args []string
CaptureOutput bool
Env map[string]string
StreamStdio bool
Trigger string
}
@@ -42,6 +43,11 @@ func CallPlugnTrigger(input PlugnTriggerInput) (execute.ExecResult, error) {
if isatty && !input.CaptureOutput {
env = append(env, "FORCE_TTY=1")
}
if input.Env != nil {
for k, v := range input.Env {
env = append(env, fmt.Sprintf("%s=%s", k, v))
}
}
args := []string{"trigger", input.Trigger}
args = append(args, input.Args...)

View File

@@ -53,6 +53,19 @@ func CommandLogin(server string, username string, password string, passwordStdin
return errors.New("Failed to log into registry")
}
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "post-registry-login",
Args: []string{server, username},
StreamStdio: true,
CaptureOutput: false,
Env: map[string]string{
"DOCKER_REGISTRY_PASS": password,
},
})
if err != nil {
return err
}
return nil
}