Skip to content

Commit 464ee06

Browse files
rbeuque74rclsilver
authored andcommitted
fix: apiovh: allow µTask specific templating inside credentials
Signed-off-by: Romain Beuque <[email protected]>
1 parent 3743d36 commit 464ee06

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/plugins/builtin/apiovh/apiovh.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
"fmt"
77
"net/url"
88
"strings"
9-
"text/template"
109

1110
"github.com/ovh/configstore"
1211
"github.com/ovh/go-ovh/ovh"
1312

13+
"github.com/ovh/utask/engine/values"
1414
"github.com/ovh/utask/pkg/plugins/builtin/httputil"
1515
"github.com/ovh/utask/pkg/plugins/taskplugin"
1616
"github.com/ovh/utask/pkg/utils"
@@ -55,7 +55,7 @@ func validConfig(config interface{}) error {
5555
return fmt.Errorf("unknown method for gw runner: %q", cfg.Method)
5656
}
5757
// If the API credentials is a template, try to parse it.
58-
if strings.Index(cfg.Credentials, "{{") == -1 {
58+
if !strings.Contains(cfg.Credentials, "{{") {
5959
ovhCfgStr, err := configstore.GetItemValue(cfg.Credentials)
6060
if err != nil {
6161
return fmt.Errorf("can't retrieve credentials from configstore: %s", err)
@@ -74,7 +74,8 @@ func validConfig(config interface{}) error {
7474
return fmt.Errorf("can't create new OVH client: %s", err)
7575
}
7676
} else {
77-
if _, err := template.New("credentials").Parse(cfg.Credentials); err != nil {
77+
v := values.NewValues()
78+
if _, err := v.Apply(cfg.Credentials, nil, ""); err != nil {
7879
return fmt.Errorf("failed to parse credentials template: %w", err)
7980
}
8081
}

0 commit comments

Comments
 (0)