Skip to content

Commit

Permalink
Updated provision
Browse files Browse the repository at this point in the history
  • Loading branch information
parthiv11 committed Jun 29, 2023
1 parent af2695f commit 61ff5e1
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions plugins/cratedb/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import (
"github.com/1Password/shell-plugins/sdk/schema/fieldname"
)

var argsToProvision = []string{
"--username", fieldname.Username,
"--hosts", fieldname.Host,
}

type crateArgsProvisioner struct {
}

Expand All @@ -24,17 +19,20 @@ func (p crateArgsProvisioner) Provision(ctx context.Context, in sdk.ProvisionInp
out.AddEnvVar("CRATEPW", value)
}

for i, arg := range argsToProvision {
if i%2 == 0 {
argName := arg
fieldName := sdk.FieldName(argsToProvision[i+1])
if fieldValue, ok := in.ItemFields[fieldName]; ok {
out.AddArgs(argName, fieldValue)
}
}
var user, host string
if fieldValue, ok := in.ItemFields[fieldname.Username]; ok {
user=fieldValue
}
if fieldValue, ok := in.ItemFields[fieldname.Host]; ok {
host=fieldValue
}
commandLine := []string{out.CommandLine[0], "--username", user, "--hosts", host, }
commandLine = append(commandLine, out.CommandLine[1:]...)
out.CommandLine = commandLine

}


func (p crateArgsProvisioner) Deprovision(ctx context.Context, in sdk.DeprovisionInput, out *sdk.DeprovisionOutput) {
// Nothing to do here: credentials get wiped automatically when the process exits.
}
Expand Down

0 comments on commit 61ff5e1

Please sign in to comment.