Skip to content

Commit

Permalink
feat: implement devlake-config creating logic
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hu <tao.hu@merico.dev>
  • Loading branch information
daniel-hutao committed Oct 11, 2022
1 parent ff087f0 commit 74b3113
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions internal/pkg/plugin/devlakeconfig/devlakeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func ApplyConfig(options plugininstaller.RawOptions) error {
func createConnections(host string, pluginName string, connections []Connection) error {
for _, c := range connections {
log.Infof("(%s)", c.Name)
renderAuthConfig(&c)
configs, err := json.Marshal(c)
if err != nil {
return err
Expand Down Expand Up @@ -73,6 +74,15 @@ func createConnection(url string, bodyWithJson []byte) error {
return fmt.Errorf(resp.Status)
}

func renderAuthConfig(connection *Connection) {
connection.Token = connection.Authx.Token
connection.Username = connection.Authx.Username
connection.Password = connection.Authx.Password
connection.AppId = connection.Authx.AppId
connection.SecretKey = connection.Authx.SecretKey
connection.Authx = Auth{}
}

func DeleteConfig(options plugininstaller.RawOptions) error {
// TODO(daniel-hutao): implement later
return nil
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/plugin/devlakeconfig/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ type DevLakePlugin struct {

type Connection struct {
staging.RestConnection `mapstructure:",squash"`
Auth Auth `mapstructure:"auth" validate:"required"`
Authx Auth `mapstructure:"auth" validate:"required"`
Auth `mapstructure:",squash"`
}

type Auth struct {
Expand Down

0 comments on commit 74b3113

Please sign in to comment.