Documentation ¶
Index ¶
- func Execute(oper Operation) error
- type ApiOperation
- type ApiOperationApiClient
- type AppOperation
- type AppOperationApiClient
- type LoginInfo
- type LoginInfoOperation
- type LoginOperation
- type LoginOperationClient
- type LoginOperationExternals
- type Operation
- type OperationType
- type ProxyLoginOperationClient
- func (p ProxyLoginOperationClient) LoginWithGithub(endpoint string, token string) (*api.User, error)
- func (p ProxyLoginOperationClient) LoginWithVault(vault_url string, token string) (*api.User, error)
- func (p ProxyLoginOperationClient) Patch(path string, body io.Reader) ([]byte, error)
- func (p ProxyLoginOperationClient) ReloadDefaultClient() (LoginOperationClient, error)
Examples ¶
- ApiOperation (Run_output)
- ApiOperation (Run_with_error_output)
- AppOperation (Run_delete_confirm_n_output)
- AppOperation (Run_delete_confirm_y_output)
- AppOperation (Run_delete_no_confirm_output)
- AppOperation (Run_show_output_when_no_heritage)
- LoginInfoOperation (Run_output)
- LoginOperation (Run_output)
- LoginOperation (Run_with_github)
- LoginOperation (Run_with_github_already_has_ssh)
- LoginOperation (Run_with_github_token)
- LoginOperation (Run_with_github_token_already_has_ssh)
- LoginOperation (Run_with_vault)
- LoginOperation (Run_with_vault_already_has_ssh)
- LoginOperation (Run_with_vault_already_has_ssh_given_url)
- LoginOperation (Run_with_vault_given_url)
- LoginOperation (Run_with_vault_token)
- LoginOperation (Run_with_vault_token_already_has_ssh)
- LoginOperation (Run_with_vault_token_already_has_ssh_given_url)
- LoginOperation (Run_with_vault_token_given_url)
- LoginOperation (Run_with_vault_token_given_url_but_fails)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiOperation ¶
type ApiOperation struct {
// contains filtered or unexported fields
}
Example (Run_output) ¶
client := &MockNormalApiOperationApiClient{} oper := NewApiOperation("GET", "https://somewhere", bytes.NewBufferString(""), client) oper.run()
Output: { "say": "hello" }
Example (Run_with_error_output) ¶
client := &MockErrorApiOperationApiClient{} oper := NewApiOperation("GET", "https://somewhere", bytes.NewBufferString(""), client) oper.run()
Output:
func NewApiOperation ¶
func NewApiOperation(method string, path string, body *bytes.Buffer, client ApiOperationApiClient) *ApiOperation
type ApiOperationApiClient ¶
type AppOperation ¶
type AppOperation struct {
// contains filtered or unexported fields
}
Example (Run_delete_confirm_n_output) ¶
client := &MockAppOperationApiClient{} oper := NewAppOperation("asd", Delete, false, client, &MockAppOperationInputReaderNo{}) oper.run()
Output: You are attempting to delete asd This operation cannot be undone. Are you sure? [y/n]:
Example (Run_delete_confirm_y_output) ¶
client := &MockAppOperationApiClient{} oper := NewAppOperation("asd", Delete, false, client, &MockAppOperationInputReaderYes{}) oper.run()
Output: You are attempting to delete asd This operation cannot be undone. Are you sure? [y/n]: Deleted asd
Example (Run_delete_no_confirm_output) ¶
client := &MockAppOperationApiClient{} oper := NewAppOperation("asd", Delete, true, client, nil /* because it doesnt matter */) oper.run()
Output: You are attempting to delete asd Deleted asd
Example (Run_show_output_when_no_heritage) ¶
client := &MockAppOperationApiClient{} oper := NewAppOperation("asd", Show, true, client, &MockAppOperationInputReaderYes{}) oper.run()
Output:
func NewAppOperation ¶
func NewAppOperation(name string, op_type OperationType, no_confirm bool, client AppOperationApiClient, input_reader utils.UserInputReader) *AppOperation
type AppOperationApiClient ¶
type LoginInfoOperation ¶
type LoginInfoOperation struct {
// contains filtered or unexported fields
}
Example (Run_output) ¶
package main import () type mockLogin struct{} func (m mockLogin) GetAuth() string { return "fooauth" } func (m mockLogin) GetEndpoint() string { return "https://example.com" } func main() { op := NewLoginInfoOperation(&mockLogin{}) op.run() }
Output: Endpoint: https://example.com Auth: fooauth
func NewLoginInfoOperation ¶
func NewLoginInfoOperation(info LoginInfo) *LoginInfoOperation
type LoginOperation ¶
type LoginOperation struct {
// contains filtered or unexported fields
}
Example (Run_output) ¶
op := NewLoginOperation("https://endpoint", "somethingrando", "gh_token", "vault_token", "https://vault_url", &mockLoginOperationExternals{}) op.run()
Output:
Example (Run_with_github) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithGithubUser: &api.User{}, loginWithGithubError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "github", "", "", "", ext) op.run()
Output: Logging in with Github Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: Generating your SSH key pair... Registering your public key...
Example (Run_with_github_already_has_ssh) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithGithubUser: &api.User{}, loginWithGithubError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "github", "", "", "", ext) op.run()
Output: Logging in with Github Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: Registering your public key...
Example (Run_with_github_token) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithGithubUser: &api.User{}, loginWithGithubError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "github", "gh_token", "", "", ext) op.run()
Output: Logging in with Github Generating your SSH key pair... Registering your public key...
Example (Run_with_github_token_already_has_ssh) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithGithubUser: &api.User{}, loginWithGithubError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "github", "gh_token", "", "", ext) op.run()
Output: Logging in with Github Registering your public key...
Example (Run_with_vault) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "vault", "", "", "", ext) op.run()
Output: Logging in with Vault Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: URL of vault server (e.g. https://vault.degica.com) Vault server URL: Generating your SSH key pair... Registering your public key...
Example (Run_with_vault_already_has_ssh) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "vault", "", "", "", ext) op.run()
Output: Logging in with Vault Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: URL of vault server (e.g. https://vault.degica.com) Vault server URL: Registering your public key...
Example (Run_with_vault_already_has_ssh_given_url) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "vault", "", "", "https://vaultserv", ext) op.run()
Output: Logging in with Vault Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: Registering your public key...
Example (Run_with_vault_given_url) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "vault", "", "", "https://vaultserv", ext) op.run()
Output: Logging in with Vault Create new GitHub access token with read:org permission here https://github.com/settings/tokens/new GitHub Token: Generating your SSH key pair... Registering your public key...
Example (Run_with_vault_token) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "vault", "", "gh_token", "", ext) op.run()
Output: Logging in with Vault URL of vault server (e.g. https://vault.degica.com) Vault server URL: Generating your SSH key pair... Registering your public key...
Example (Run_with_vault_token_already_has_ssh) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "vault", "", "gh_token", "", ext) op.run()
Output: Logging in with Vault URL of vault server (e.g. https://vault.degica.com) Vault server URL: Registering your public key...
Example (Run_with_vault_token_already_has_ssh_given_url) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), fileExistsBool: true, } op := NewLoginOperation("https://endpoint", "vault", "", "gh_token", "https://vaultserv", ext) op.run()
Output: Logging in with Vault Registering your public key...
Example (Run_with_vault_token_given_url) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: &api.User{}, loginWithVaultError: nil, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "vault", "", "gh_token", "https://vaultserv", ext) op.run()
Output: Logging in with Vault Generating your SSH key pair... Registering your public key...
Example (Run_with_vault_token_given_url_but_fails) ¶
ext := &mockLoginOperationExternals{ readString: "aw\n", readError: nil, loginWithVaultUser: nil, loginWithVaultError: &mockLoginVaultError{}, readFileBytes: []byte("stuff"), } op := NewLoginOperation("https://endpoint", "vault", "", "gh_token", "https://vaultserv", ext) op.run()
Output: Logging in with Vault
func NewLoginOperation ¶
func NewLoginOperation(endpoint string, backend string, ghToken string, vaultToken string, vaultUrl string, ext LoginOperationExternals) *LoginOperation
type LoginOperationClient ¶
type LoginOperationExternals ¶
type LoginOperationExternals interface { // User Input Reader Read(secret bool) (string, error) // CommandRunner RunCommand(name string, arg ...string) error // FileOps FileExists(path string) bool ReadFile(path string) ([]byte, error) // Client stuff LoginOperationClient ReloadDefaultClient() (LoginOperationClient, error) // Config stuff WriteLogin(auth string, token string, endpoint string) error GetPublicKeyPath() string GetPrivateKeyPath() string }
type OperationType ¶
type OperationType string
const ( Delete OperationType = "Delete" Show = "Show" )
type ProxyLoginOperationClient ¶
A proxy class to satisfy the interfaces
func (ProxyLoginOperationClient) LoginWithGithub ¶
func (ProxyLoginOperationClient) LoginWithVault ¶
func (ProxyLoginOperationClient) ReloadDefaultClient ¶
func (p ProxyLoginOperationClient) ReloadDefaultClient() (LoginOperationClient, error)
Click to show internal directories.
Click to hide internal directories.