Documentation ¶
Index ¶
- Variables
- func SaveClientProfile(profile Profile) error
- type Error
- type GortClient
- func (c *GortClient) Authenticate() (rest.Token, error)
- func (c *GortClient) Authenticated() (bool, error)
- func (c *GortClient) Bootstrap(overwrite bool) (rest.User, error)
- func (c *GortClient) BundleDisable(bundlename string) error
- func (c *GortClient) BundleEnable(bundlename string, version string) error
- func (c *GortClient) BundleExists(bundlename string, version string) (bool, error)
- func (c *GortClient) BundleGet(bundlename string, version string) (data.Bundle, error)
- func (c *GortClient) BundleInstall(bundle data.Bundle) error
- func (c *GortClient) BundleList() ([]data.Bundle, error)
- func (c *GortClient) BundleListVersions(bundlename string) ([]data.Bundle, error)
- func (c *GortClient) BundleUninstall(bundlename string, version string) error
- func (c *GortClient) GroupDelete(groupname string) error
- func (c *GortClient) GroupExists(groupname string) (bool, error)
- func (c *GortClient) GroupGet(groupname string) (rest.Group, error)
- func (c *GortClient) GroupList() ([]rest.Group, error)
- func (c *GortClient) GroupMemberAdd(groupname string, username string) error
- func (c *GortClient) GroupMemberDelete(groupname string, username string) error
- func (c *GortClient) GroupMemberList(groupname string) ([]rest.User, error)
- func (c *GortClient) GroupRoleAdd(groupname string, rolename string) error
- func (c *GortClient) GroupRoleDelete(groupname string, rolename string) error
- func (c *GortClient) GroupRoleList(groupname string) ([]rest.Role, error)
- func (c *GortClient) GroupSave(group rest.Group) error
- func (c *GortClient) RoleCreate(rolename string) error
- func (c *GortClient) RoleDelete(rolename string) error
- func (c *GortClient) RoleExists(rolename string) (bool, error)
- func (c *GortClient) RoleGet(rolename string) (rest.Role, error)
- func (c *GortClient) RoleList() ([]rest.Group, error)
- func (c *GortClient) RolePermissionGrant(rolename string, bundlename string, permissionname string) error
- func (c *GortClient) RolePermissionList(username string) (rest.RolePermissionList, error)
- func (c *GortClient) RolePermissionRevoke(rolename string, bundlename string, permissionname string) error
- func (c *GortClient) Token() (rest.Token, error)
- func (c *GortClient) UserDelete(username string) error
- func (c *GortClient) UserExists(username string) (bool, error)
- func (c *GortClient) UserGet(username string) (rest.User, error)
- func (c *GortClient) UserGroupList(username string) ([]rest.Group, error)
- func (c *GortClient) UserList() ([]rest.User, error)
- func (c *GortClient) UserPermissionList(username string) (rest.RolePermissionList, error)
- func (c *GortClient) UserSave(user rest.User) error
- type Profile
- type ProfileDefaults
- type ProfileEntry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadProfile indicates an invalid or missing client profile. ErrBadProfile = errors.New("invalid or missing client profile") // ErrBadRequest indicates that a request could not be constructed. ErrBadRequest = errors.New("request could not be constructed") // ErrConnectionFailed is a failure for a client to connect to the Gort controller. ErrConnectionFailed = errors.New("failure to connect to the Gort controller") // ErrResourceExists is returned if a client tries to put a resource that // already exists. ErrResourceExists = errors.New("resource already exists") // ErrResourceNotFound is returned if a client tries to get or update a // resource that doesn't exist. ErrResourceNotFound = errors.New("resource doesn't exist") // ErrResponseReadFailure indicates an error in reading a server response. ErrResponseReadFailure = errors.New("error reading a server response") // ErrURLFormat indicates badly formatted URL. ErrURLFormat = errors.New("invalid URL format") ErrInsecureURL = errors.New("insecure URL provided, please use https or set the allow insecure flag in the config or clients") )
Functions ¶
func SaveClientProfile ¶
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error implementation that represents either a a non-2XX response from the server, or a failure to connect to the server (in which case Status() will return 0).
func (Error) Profile ¶
func (c Error) Profile() ProfileEntry
Profile returns the active profile entry for the client that returned this error.
type GortClient ¶
type GortClient struct {
// contains filtered or unexported fields
}
GortClient comments to be written...
func Connect ¶
func Connect(profileName string) (*GortClient, error)
Connect creates and returns a configured instance of the client for the specified host. An empty string will use the default profile. If the requested profile doesn't exist, an empty ProfileEntry is returned.
func ConnectWithNewProfile ¶
func ConnectWithNewProfile(entry ProfileEntry) (*GortClient, error)
ConnectWithNewProfile generates a connection using the supplied profile entry data.
func NewClient ¶
func NewClient(entry ProfileEntry) (*GortClient, error)
NewClient creates a GortClient for the provided ProfileEntry. An error is returned if the profile is invalid.
func (*GortClient) Authenticate ¶
func (c *GortClient) Authenticate() (rest.Token, error)
Authenticate requests a new authentication token from the Gort controller. If a valid token already exists it will be automatically invalidated if this call is successful.
func (*GortClient) Authenticated ¶
func (c *GortClient) Authenticated() (bool, error)
Authenticated looks for any cached tokens associated with the current server. Returns false if no tokens exist or tokens are expired.
func (*GortClient) Bootstrap ¶
func (c *GortClient) Bootstrap(overwrite bool) (rest.User, error)
Bootstrap calls the POST /v2/bootstrap endpoint.
func (*GortClient) BundleDisable ¶
func (c *GortClient) BundleDisable(bundlename string) error
BundleDisable comments to be written...
func (*GortClient) BundleEnable ¶
func (c *GortClient) BundleEnable(bundlename string, version string) error
BundleEnable comments to be written...
func (*GortClient) BundleExists ¶
func (c *GortClient) BundleExists(bundlename string, version string) (bool, error)
BundleExists simply returns true if a bundle exists with the specified bundlename; false otherwise.
func (*GortClient) BundleInstall ¶
func (c *GortClient) BundleInstall(bundle data.Bundle) error
BundleInstall comments to be written...
func (*GortClient) BundleList ¶
func (c *GortClient) BundleList() ([]data.Bundle, error)
BundleList comments to be written...
func (*GortClient) BundleListVersions ¶
func (c *GortClient) BundleListVersions(bundlename string) ([]data.Bundle, error)
BundleListVersions comments to be written...
func (*GortClient) BundleUninstall ¶
func (c *GortClient) BundleUninstall(bundlename string, version string) error
BundleUninstall comments to be written...
func (*GortClient) GroupDelete ¶
func (c *GortClient) GroupDelete(groupname string) error
GroupDelete comments to be written...
func (*GortClient) GroupExists ¶
func (c *GortClient) GroupExists(groupname string) (bool, error)
GroupExists simply returns true if a group exists with the specified groupname; false otherwise.
func (*GortClient) GroupGet ¶
func (c *GortClient) GroupGet(groupname string) (rest.Group, error)
GroupGet comments to be written...
func (*GortClient) GroupList ¶
func (c *GortClient) GroupList() ([]rest.Group, error)
GroupList comments to be written...
func (*GortClient) GroupMemberAdd ¶
func (c *GortClient) GroupMemberAdd(groupname string, username string) error
GroupMemberAdd comments to be written...
func (*GortClient) GroupMemberDelete ¶
func (c *GortClient) GroupMemberDelete(groupname string, username string) error
GroupMemberDelete comments to be written...
func (*GortClient) GroupMemberList ¶
func (c *GortClient) GroupMemberList(groupname string) ([]rest.User, error)
GroupMemberList comments to be written...
func (*GortClient) GroupRoleAdd ¶
func (c *GortClient) GroupRoleAdd(groupname string, rolename string) error
GroupRoleAdd adds a role to a group.
func (*GortClient) GroupRoleDelete ¶
func (c *GortClient) GroupRoleDelete(groupname string, rolename string) error
GroupMemberDelete deletes a role from a group.
func (*GortClient) GroupRoleList ¶
func (c *GortClient) GroupRoleList(groupname string) ([]rest.Role, error)
GroupRoleList retrieves all roles added to a group.
func (*GortClient) GroupSave ¶
func (c *GortClient) GroupSave(group rest.Group) error
GroupSave comments to be written...
func (*GortClient) RoleCreate ¶
func (c *GortClient) RoleCreate(rolename string) error
RoleCreate creates a new role.
func (*GortClient) RoleDelete ¶
func (c *GortClient) RoleDelete(rolename string) error
RoleDelete deletes an existing role.
func (*GortClient) RoleExists ¶
func (c *GortClient) RoleExists(rolename string) (bool, error)
RoleExists simply returns true if a role exists with the specified rolename; false otherwise.
func (*GortClient) RoleGet ¶
func (c *GortClient) RoleGet(rolename string) (rest.Role, error)
RoleGet gets an existing role.
func (*GortClient) RoleList ¶
func (c *GortClient) RoleList() ([]rest.Group, error)
RoleList comments to be written...
func (*GortClient) RolePermissionGrant ¶
func (c *GortClient) RolePermissionGrant(rolename string, bundlename string, permissionname string) error
RolePermissionGrant grants a permission to an existing role
func (*GortClient) RolePermissionList ¶
func (c *GortClient) RolePermissionList(username string) (rest.RolePermissionList, error)
RolePermissionList comments to be written...
func (*GortClient) RolePermissionRevoke ¶
func (c *GortClient) RolePermissionRevoke(rolename string, bundlename string, permissionname string) error
RolePermissionRevoke revokes an existing permission from a role
func (*GortClient) Token ¶
func (c *GortClient) Token() (rest.Token, error)
Token is just a wrapper around a call to Authenticated() followed by a call to Authenticate() if false.
func (*GortClient) UserDelete ¶
func (c *GortClient) UserDelete(username string) error
UserDelete comments to be written...
func (*GortClient) UserExists ¶
func (c *GortClient) UserExists(username string) (bool, error)
UserExists simply returns true if a user exists with the specified username; false otherwise.
func (*GortClient) UserGet ¶
func (c *GortClient) UserGet(username string) (rest.User, error)
UserGet comments to be written...
func (*GortClient) UserGroupList ¶
func (c *GortClient) UserGroupList(username string) ([]rest.Group, error)
UserGroupList comments to be written...
func (*GortClient) UserList ¶
func (c *GortClient) UserList() ([]rest.User, error)
UserList comments to be written...
func (*GortClient) UserPermissionList ¶
func (c *GortClient) UserPermissionList(username string) (rest.RolePermissionList, error)
UserPermissionList comments to be written...
func (*GortClient) UserSave ¶
func (c *GortClient) UserSave(user rest.User) error
UserSave will create or update a user. Note the the key is the username: if this is called with a user whose username exists that user is updated (empty fields will not be overwritten); otherwise a new user is created.
type Profile ¶
type Profile struct { Defaults ProfileDefaults Profiles map[string]ProfileEntry `yaml:",inline"` }
Profile represents a set of user profiles from a $HOME/.gort/profiles file
func LoadClientProfile ¶
loadClientProfile loads and returns the complete client profile. If there's no profile file, an empty Profile is returned. An error is returned if there's an underlying IO error.
func (Profile) Default ¶
func (p Profile) Default() ProfileEntry
Default returns this Profile's default entry. If there's no default, or if the default doesn't exist, an empty ProfileEntry is returned.
type ProfileDefaults ¶
type ProfileDefaults struct {
Profile string
}
ProfileDefaults is used to store default values for a gort client profile.
type ProfileEntry ¶
type ProfileEntry struct { Name string `yaml:"-"` URLString string `yaml:"url,omitempty"` Password string `yaml:"password,omitempty"` URL *url.URL `yaml:"-"` Username string `yaml:"user,omitempty"` AllowInsecure bool `yaml:"allow_insecure,omitempty"` TLSCertFile string `yaml:"tls_cert_file,omitempty"` }
ProfileEntry represents a single profile entry.
func (ProfileEntry) User ¶
func (pe ProfileEntry) User() rest.User
User is a convenience method that returns a rest.User pre-set with the entry's username and password.