-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package vertica | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/1Password/shell-plugins/sdk" | ||
"github.com/1Password/shell-plugins/sdk/importer" | ||
"github.com/1Password/shell-plugins/sdk/provision" | ||
"github.com/1Password/shell-plugins/sdk/schema" | ||
"github.com/1Password/shell-plugins/sdk/schema/credname" | ||
"github.com/1Password/shell-plugins/sdk/schema/fieldname" | ||
) | ||
|
||
func DatabaseCredentials() schema.CredentialType { | ||
return schema.CredentialType{ | ||
Name: credname.DatabaseCredentials, | ||
DocsURL: sdk.URL("https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ConnectingToVertica/vsql/Install/InstallingTheVsqlClient.htm"), | ||
ManagementURL: sdk.URL("https://www.vertica.com/try/"), | ||
Fields: []schema.CredentialField{ | ||
{ | ||
Name: fieldname.Host, | ||
MarkdownDescription: "Vertica host to connect to.", | ||
Optional: true, | ||
}, | ||
{ | ||
Name: fieldname.Port, | ||
MarkdownDescription: "Port used to connect to Vertica.", | ||
Optional: true, | ||
}, | ||
{ | ||
Name: fieldname.Username, | ||
MarkdownDescription: "Vertica user to authenticate as.", | ||
Optional: true, | ||
}, | ||
{ | ||
Name: fieldname.Password, | ||
MarkdownDescription: "Password used to authenticate to Vertica.", | ||
Secret: true, | ||
}, | ||
{ | ||
Name: fieldname.Database, | ||
MarkdownDescription: "Database name to connect to.", | ||
Optional: true, | ||
}, | ||
}, | ||
DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), | ||
Importer: importer.TryAllimporter.TryEnvVarPair(defaultEnvVarMapping)} | ||
} | ||
|
||
var defaultEnvVarMapping = map[string]sdk.FieldName{ | ||
"VSQL_USER": fieldname.Username, | ||
"VSQL_PASSWORD": fieldname.Password, | ||
"VSQL_HOST": fieldname.Host, | ||
"VSQL_PORT": fieldname.Port, | ||
"VSQL_DATABASE": fieldname.Database, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package vertica | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/1Password/shell-plugins/sdk" | ||
"github.com/1Password/shell-plugins/sdk/plugintest" | ||
"github.com/1Password/shell-plugins/sdk/schema/fieldname" | ||
) | ||
|
||
func TestDatabaseCredentialsProvisioner(t *testing.T) { | ||
plugintest.TestProvisioner(t, DatabaseCredentials().DefaultProvisioner, map[string]plugintest.ProvisionCase{ | ||
"default": { | ||
ItemFields: map[sdk.FieldName]string{ | ||
fieldname.User: "vertica", | ||
fieldname.Password: "", | ||
fieldname.Host: "localhost", | ||
fieldname.Port: "5433", | ||
fieldname.Database: "VMart", | ||
}, | ||
ExpectedOutput: sdk.ProvisionOutput{ | ||
Environment: map[string]string{ | ||
"VSQL_USER": "vertica", | ||
"VSQL_PASSWORD": "", | ||
"VSQL_HOST": "localhost", | ||
"VSQL_PORT": "5433", | ||
"VSQL_DATABASE": "VMart", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package vertica | ||
|
||
import ( | ||
"github.com/1Password/shell-plugins/sdk" | ||
"github.com/1Password/shell-plugins/sdk/schema" | ||
) | ||
|
||
func New() schema.Plugin { | ||
return schema.Plugin{ | ||
Name: "vertica", | ||
Platform: schema.PlatformInfo{ | ||
Name: "Vertica", | ||
Homepage: sdk.URL("https://www.vertica.com/"), | ||
}, | ||
Credentials: []schema.CredentialType{ | ||
DatabaseCredentials(), | ||
}, | ||
Executables: []schema.Executable{ | ||
VerticaCLI(), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package vertica | ||
|
||
import ( | ||
"github.com/1Password/shell-plugins/sdk" | ||
"github.com/1Password/shell-plugins/sdk/needsauth" | ||
"github.com/1Password/shell-plugins/sdk/schema" | ||
"github.com/1Password/shell-plugins/sdk/schema/credname" | ||
) | ||
|
||
func VerticaCLI() schema.Executable { | ||
return schema.Executable{ | ||
Name: "Vertica CLI", | ||
Runs: []string{"vsql"}, | ||
DocsURL: sdk.URL("https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/ConnectingToVertica/vsql/UsingVsql.htm"), | ||
NeedsAuth: needsauth.IfAll( | ||
needsauth.NotForHelpOrVersion(), | ||
needsauth.NotWithoutArgs(), | ||
), | ||
Uses: []schema.CredentialUsage{ | ||
{ | ||
Name: credname.DatabaseCredentials, | ||
}, | ||
}, | ||
} | ||
} |