Skip to content

Commit

Permalink
fix: apiovh: allow µTask specific templating inside credentials
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Beuque <[email protected]>
  • Loading branch information
rbeuque74 authored and rclsilver committed Feb 28, 2024
1 parent 3743d36 commit 464ee06
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/plugins/builtin/apiovh/apiovh.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"fmt"
"net/url"
"strings"
"text/template"

"github.com/ovh/configstore"
"github.com/ovh/go-ovh/ovh"

"github.com/ovh/utask/engine/values"
"github.com/ovh/utask/pkg/plugins/builtin/httputil"
"github.com/ovh/utask/pkg/plugins/taskplugin"
"github.com/ovh/utask/pkg/utils"
Expand Down Expand Up @@ -55,7 +55,7 @@ func validConfig(config interface{}) error {
return fmt.Errorf("unknown method for gw runner: %q", cfg.Method)
}
// If the API credentials is a template, try to parse it.
if strings.Index(cfg.Credentials, "{{") == -1 {
if !strings.Contains(cfg.Credentials, "{{") {
ovhCfgStr, err := configstore.GetItemValue(cfg.Credentials)
if err != nil {
return fmt.Errorf("can't retrieve credentials from configstore: %s", err)
Expand All @@ -74,7 +74,8 @@ func validConfig(config interface{}) error {
return fmt.Errorf("can't create new OVH client: %s", err)
}
} else {
if _, err := template.New("credentials").Parse(cfg.Credentials); err != nil {
v := values.NewValues()
if _, err := v.Apply(cfg.Credentials, nil, ""); err != nil {
return fmt.Errorf("failed to parse credentials template: %w", err)
}
}
Expand Down

0 comments on commit 464ee06

Please sign in to comment.