feat: add missing config-get triggers

This commit is contained in:
Jose Diaz-Gonzalez
2020-03-10 18:19:04 -04:00
parent 6d62835734
commit aa156b2834
7 changed files with 91 additions and 1 deletions

View File

@@ -201,6 +201,36 @@ help_content
esac
```
### `config-get`
- Description: Fetches the app config value for a key
- Invoked by:
- Arguments: `$APP $KEY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `config-get-global`
- Description: Fetches the global config value for a key
- Invoked by:
- Arguments: `$KEY`
- Example:
```shell
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
# TODO
```
### `core-post-deploy`
> To avoid issues with community plugins, this plugin trigger should be used *only* for core plugins. Please avoid using this trigger in your own plugins.

View File

@@ -0,0 +1 @@
hook

View File

@@ -0,0 +1 @@
hook

View File

@@ -2,3 +2,4 @@
/subcommands/*
/triggers/*
/triggers
/config-*

View File

@@ -1,5 +1,6 @@
SUBCOMMANDS = subcommands/export subcommands/get subcommands/set subcommands/unset subcommands/keys subcommands/bundle
BUILD = commands subcommands
TRIGGERS = triggers/config-get triggers/config-get-global
BUILD = commands subcommands triggers
PLUGIN_NAME = config
include ../../common.mk

View File

@@ -0,0 +1,35 @@
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
"github.com/dokku/dokku/plugins/config"
)
// main entrypoint to all triggers
func main() {
parts := strings.Split(os.Args[0], "/")
trigger := parts[len(parts)-1]
flag.Parse()
var err error
switch trigger {
case "config-get":
appName := flag.Arg(0)
key := flag.Arg(1)
config.TriggerConfigGet(appName, key)
case "config-get-global":
key := flag.Arg(0)
config.TriggerConfigGetGlobal(key)
default:
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
}
if err != nil {
common.LogFail(err.Error())
}
}

View File

@@ -0,0 +1,21 @@
package config
import "fmt"
func TriggerConfigGet(appName string, key string) error {
value, ok := Get(appName, key)
if ok {
fmt.Println(value)
}
return nil
}
func TriggerConfigGetGlobal(key string) error {
value, ok := Get("--global", key)
if ok {
fmt.Println(value)
}
return nil
}