Documentation ¶
Index ¶
- Constants
- func ApiTokenEnv(prefix string) string
- func BearerTokenEnv(prefix string) string
- func UsernameEnv(prefix string) string
- type AuthConfig
- func (c *AuthConfig) AddServer(server *AuthServer)
- func (c *AuthConfig) CurrentAuthServer() *AuthServer
- func (c *AuthConfig) CurrentUser(server *AuthServer, inCluster bool) *UserAuth
- func (c *AuthConfig) DeleteServer(url string)
- func (c *AuthConfig) EditUserAuth(serverLabel string, auth *UserAuth, defaultUserName string, ...) error
- func (c *AuthConfig) FindUserAuth(serverURL string, username string) *UserAuth
- func (c *AuthConfig) FindUserAuths(serverURL string) []*UserAuth
- func (c *AuthConfig) GetOrCreateServer(url string) *AuthServer
- func (c *AuthConfig) GetOrCreateServerName(url string, name string, kind string) *AuthServer
- func (c *AuthConfig) GetOrCreateUserAuth(url string, username string) *UserAuth
- func (c *AuthConfig) GetPipelineAuth() (*AuthServer, *UserAuth)
- func (c *AuthConfig) GetServer(url string) *AuthServer
- func (c *AuthConfig) GetServerByKind(kind string) *AuthServer
- func (c *AuthConfig) GetServerByName(name string) *AuthServer
- func (c *AuthConfig) GetServerNames() []string
- func (c *AuthConfig) GetServerURLs() []string
- func (c *AuthConfig) IndexOfServerName(name string) int
- func (c *AuthConfig) PickOrCreateServer(fallbackServerURL string, serverURL string, message string, batchMode bool, ...) (*AuthServer, error)
- func (c *AuthConfig) PickServer(message string, batchMode bool, in terminal.FileReader, ...) (*AuthServer, error)
- func (c *AuthConfig) PickServerUserAuth(server *AuthServer, message string, batchMode bool, org string, ...) (*UserAuth, error)
- func (c *AuthConfig) SetUserAuth(url string, auth *UserAuth)
- func (c *AuthConfig) UpdatePipelineServer(server *AuthServer, user *UserAuth)
- type AuthConfigService
- func (s *AuthConfigService) Config() *AuthConfig
- func (s *AuthConfigService) DeleteServer(url string) error
- func (s *AuthConfigService) LoadConfig() (*AuthConfig, error)
- func (s *AuthConfigService) SaveConfig() error
- func (s *AuthConfigService) SaveUserAuth(url string, userAuth *UserAuth) error
- func (s *AuthConfigService) SetConfig(c *AuthConfig)
- type AuthServer
- func (s *AuthServer) CurrentAuth() *UserAuth
- func (s *AuthServer) DeleteUser(username string) error
- func (s *AuthServer) Description() string
- func (s *AuthServer) GetUserAuth(username string) *UserAuth
- func (s *AuthServer) GetUsernames() []string
- func (s *AuthServer) HasUserAuths() bool
- func (s *AuthServer) Label() string
- type Checker
- type Config
- type ConfigSaver
- type ConfigService
- type FileAuthConfigSaver
- type PrintUserFn
- type Server
- type ServerKind
- type ServiceKind
- type User
- type UserAuth
- type UserKind
- type VaultAuthConfigSaver
Constants ¶
const (
DefaultUsername = "dummy"
)
const (
DefaultWritePermissions = 0760
)
Variables ¶
This section is empty.
Functions ¶
func ApiTokenEnv ¶
ApiTokenEnv builds the api token environment variable name
func BearerTokenEnv ¶
BearerTokenEnv builds the bearer token environment variable name
func UsernameEnv ¶
UsernameEnv builds the username environment variable name
Types ¶
type AuthConfig ¶
type AuthConfig struct { Servers []*AuthServer DefaultUsername string CurrentServer string PipeLineUsername string PipeLineServer string }
func (*AuthConfig) AddServer ¶
func (c *AuthConfig) AddServer(server *AuthServer)
func (*AuthConfig) CurrentAuthServer ¶
func (c *AuthConfig) CurrentAuthServer() *AuthServer
CurrentAuthServer returns the current AuthServer configured in the configuration
func (*AuthConfig) CurrentUser ¶
func (c *AuthConfig) CurrentUser(server *AuthServer, inCluster bool) *UserAuth
func (*AuthConfig) DeleteServer ¶
func (c *AuthConfig) DeleteServer(url string)
DeleteServer deletes the server for the given URL and updates the current server if is the same with the deleted server
func (*AuthConfig) EditUserAuth ¶
func (c *AuthConfig) EditUserAuth(serverLabel string, auth *UserAuth, defaultUserName string, editUser, batchMode bool, fn PrintUserFn, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) error
EditUserAuth Lets the user input/edit the user auth
func (*AuthConfig) FindUserAuth ¶
func (c *AuthConfig) FindUserAuth(serverURL string, username string) *UserAuth
FindUserAuth finds the auth for the given user name if no username is specified and there is only one auth then return that else nil
func (*AuthConfig) FindUserAuths ¶
func (c *AuthConfig) FindUserAuths(serverURL string) []*UserAuth
func (*AuthConfig) GetOrCreateServer ¶
func (c *AuthConfig) GetOrCreateServer(url string) *AuthServer
func (*AuthConfig) GetOrCreateServerName ¶
func (c *AuthConfig) GetOrCreateServerName(url string, name string, kind string) *AuthServer
func (*AuthConfig) GetOrCreateUserAuth ¶
func (c *AuthConfig) GetOrCreateUserAuth(url string, username string) *UserAuth
func (*AuthConfig) GetPipelineAuth ¶
func (c *AuthConfig) GetPipelineAuth() (*AuthServer, *UserAuth)
GetPipelineAuth returns the current pipline server and user authentication
func (*AuthConfig) GetServer ¶
func (c *AuthConfig) GetServer(url string) *AuthServer
GetServerByName returns the server for the given URL or null if its not found
func (*AuthConfig) GetServerByKind ¶
func (c *AuthConfig) GetServerByKind(kind string) *AuthServer
GetServerByKind returns the server for the given kind or null if its not found
func (*AuthConfig) GetServerByName ¶
func (c *AuthConfig) GetServerByName(name string) *AuthServer
GetServerByName returns the server for the given name or null if its not found
func (*AuthConfig) GetServerNames ¶
func (c *AuthConfig) GetServerNames() []string
GetServerNames returns the name of the server currently in the configuration
func (*AuthConfig) GetServerURLs ¶
func (c *AuthConfig) GetServerURLs() []string
GetServerURLs returns the server URLs currently in the configuration
func (*AuthConfig) IndexOfServerName ¶
func (c *AuthConfig) IndexOfServerName(name string) int
func (*AuthConfig) PickOrCreateServer ¶
func (c *AuthConfig) PickOrCreateServer(fallbackServerURL string, serverURL string, message string, batchMode bool, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) (*AuthServer, error)
PickOrCreateServer picks the server to use defaulting to the current server
func (*AuthConfig) PickServer ¶
func (c *AuthConfig) PickServer(message string, batchMode bool, in terminal.FileReader, out terminal.FileWriter, outErr io.Writer) (*AuthServer, error)
func (*AuthConfig) PickServerUserAuth ¶
func (c *AuthConfig) PickServerUserAuth(server *AuthServer, message string, batchMode bool, org string, in terminal.FileReader, out terminal.FileWriter, errOut io.Writer) (*UserAuth, error)
PickServerAuth Pick the servers auth
func (*AuthConfig) SetUserAuth ¶
func (c *AuthConfig) SetUserAuth(url string, auth *UserAuth)
func (*AuthConfig) UpdatePipelineServer ¶
func (c *AuthConfig) UpdatePipelineServer(server *AuthServer, user *UserAuth)
UpdatePipelineServer updates the pipeline server in the configuration
type AuthConfigService ¶
type AuthConfigService struct {
// contains filtered or unexported fields
}
AuthConfigService implements the generic features of the ConfigService because we don't have superclasses
func NewAuthConfigService ¶
func NewAuthConfigService(saver ConfigSaver) *AuthConfigService
NewAuthConfigService generates a AuthConfigService with a custom saver. This should not be used directly
func (*AuthConfigService) Config ¶
func (s *AuthConfigService) Config() *AuthConfig
Config gets the AuthConfig from the service
func (*AuthConfigService) DeleteServer ¶
func (s *AuthConfigService) DeleteServer(url string) error
DeleteServer removes the given server from the configuration
func (*AuthConfigService) LoadConfig ¶
func (s *AuthConfigService) LoadConfig() (*AuthConfig, error)
LoadConfig loads the configuration from the users JX config directory
func (*AuthConfigService) SaveConfig ¶
func (s *AuthConfigService) SaveConfig() error
SaveConfig saves the configuration to disk
func (*AuthConfigService) SaveUserAuth ¶
func (s *AuthConfigService) SaveUserAuth(url string, userAuth *UserAuth) error
SaveUserAuth saves the given user auth for the server url
func (*AuthConfigService) SetConfig ¶
func (s *AuthConfigService) SetConfig(c *AuthConfig)
SetConfig sets the AuthConfig object
type AuthServer ¶
func (*AuthServer) CurrentAuth ¶
func (s *AuthServer) CurrentAuth() *UserAuth
CurrentAuth returns the current user auth, otherwise the first one
func (*AuthServer) DeleteUser ¶
func (s *AuthServer) DeleteUser(username string) error
func (*AuthServer) Description ¶
func (s *AuthServer) Description() string
func (*AuthServer) GetUserAuth ¶
func (s *AuthServer) GetUserAuth(username string) *UserAuth
func (*AuthServer) GetUsernames ¶
func (s *AuthServer) GetUsernames() []string
func (*AuthServer) HasUserAuths ¶
func (s *AuthServer) HasUserAuths() bool
HasUserAuths checks if a server has any user auth configured
func (*AuthServer) Label ¶
func (s *AuthServer) Label() string
type Checker ¶
type Checker interface {
Valid() error
}
Checker verifies if the configuration is valid
type Config ¶
type Config struct {
Servers []*Server `yaml:"servers"`
}
Config stores the entire auth configuration for a number of sservers
type ConfigSaver ¶
type ConfigSaver interface { // LoadConfig loads the configuration from the users JX config directory LoadConfig() (*AuthConfig, error) //HasConfigFile() (bool, error) // SaveConfig saves the configuration SaveConfig(config *AuthConfig) error }
ConfigSaver is an interface that saves an AuthConfig
type ConfigService ¶
type ConfigService interface { Config() *AuthConfig SetConfig(c *AuthConfig) // LoadConfig loads the configuration from the users JX config directory LoadConfig() (*AuthConfig, error) //HasConfigFile() (bool, error) // SaveConfig saves the configuration SaveConfig() error // SaveUserAuth saves the given user auth for the server url SaveUserAuth(url string, userAuth *UserAuth) error // DeleteServer removes the given server from the configuration DeleteServer(url string) error }
ConfigService is a service for handing the config of auth tokens
func NewFileAuthConfigService ¶
func NewFileAuthConfigService(filename string) (ConfigService, error)
NewFileAuthConfigService
func NewVaultAuthConfigService ¶
func NewVaultAuthConfigService(secretName string, vaultClient vault.Client) ConfigService
NewVaultAuthConfigService creates a new ConfigService that saves it config to a Vault
type FileAuthConfigSaver ¶
type FileAuthConfigSaver struct {
FileName string
}
FileAuthConfigSaver is a ConfigSaver that saves its config to the local filesystem
func (*FileAuthConfigSaver) LoadConfig ¶
func (s *FileAuthConfigSaver) LoadConfig() (*AuthConfig, error)
LoadConfig loads the configuration from the users JX config directory
func (*FileAuthConfigSaver) SaveConfig ¶
func (s *FileAuthConfigSaver) SaveConfig(config *AuthConfig) error
SaveConfig saves the configuration to disk
type Server ¶
type Server struct { URL string `yaml:"url"` Name string `yaml:"name"` Kind ServerKind `yaml:"kind"` ServiceKind ServiceKind `yaml:"servicekind"` Users []*User `yaml:"users"` }
Server stores the server configuration for a server
func (*Server) PipelineUser ¶
PipelineUser returns the pipeline user, if there is not pipeline user available returns the first user
type ServerKind ¶
type ServerKind string
ServerKind type of the server
const ( // ServerKindGit idicates a server configuration for git ServerKindGit ServerKind = "git" // ServerKindIssue indicates a server configuration for issue ServerKindIssue ServerKind = "issue" // ServerKindChat idicates a server configuration for chat ServerKindChat ServerKind = "chat" )
type ServiceKind ¶
type ServiceKind string
ServiceKind type for service used by the server
const ( // ServiceKindGithub indicates that the git server is using as service GitHub ServiceKindGithub ServiceKind = "github" // ServiceKindGitlab indicates that the git server is using as service Gitlab ServiceKindGitlab ServiceKind = "gitlab" // ServiceKindGitea indicates that the git server is using as service Gitea ServiceKindGitea ServiceKind = "gitea" // ServiceKindBitbucketCloud indicates that the git server is using as service Bitbucket Cloud ServiceKindBitbucketCloud ServiceKind = "bitbucketcloud" // ServiceKindBitbucketServer indicates that the git server is using as service Bitbuckst Server ServiceKindBitbucketServer ServiceKind = "bitbucketserver" )
type User ¶
type User struct { Username string `yaml:"username"` ApiToken string `yaml:"apitoken"` BearerToken string `yaml:"bearertoken"` Password string `yaml:"password,omitempty" json:"password"` Kind UserKind `yaml:"kind"` }
User store the auth infomation for a user
type UserAuth ¶
type UserAuth struct { Username string ApiToken string BearerToken string Password string `yaml:"password,omitempty"` }
func CreateAuthUserFromEnvironment ¶
CreateAuthUserFromEnvironment creates a user auth from environment variables
type VaultAuthConfigSaver ¶
type VaultAuthConfigSaver struct {
// contains filtered or unexported fields
}
VaultAuthConfigSaver is a ConfigSaver that saves configs to Vault
func (*VaultAuthConfigSaver) LoadConfig ¶
func (v *VaultAuthConfigSaver) LoadConfig() (*AuthConfig, error)
LoadConfig loads the config from the vault
func (*VaultAuthConfigSaver) SaveConfig ¶
func (v *VaultAuthConfigSaver) SaveConfig(config *AuthConfig) error
SaveConfig saves the config to the vault