Documentation
¶
Overview ¶
Package util contains common routines used throughout the command base
Package util contains common routines used throughout the command base ¶
Package util contains common routines used throughout the command base ¶
Package util contains common routines used throughout the command base
Index ¶
- Constants
- Variables
- func Bail(err error)
- func BuildAPI()
- func BuildAPIAndVerifyLogin()
- func CleanVersion(version string) semver.Version
- func DDP(v interface{})
- func DisableApiTokenCRUD() bool
- func DisableApiVersionCheck() bool
- func DisplayDevices(devices []conch.Device, fullOutput bool) (err error)
- func FindShortUUID(s string, uuids []uuid.UUID) (uuid.UUID, error)
- func GetMarkdownTable() (table *tablewriter.Table)
- func GithubReleaseCheck()
- func InteractiveForcePasswordChange()
- func IsPasswordSane(password string, profile *config.ConchProfile) error
- func JSONOut(thingy interface{})
- func JSONOutIndent(thingy interface{})
- func MagicDatacenterID(wat string) (uuid.UUID, error)
- func MagicProductID(wat string) (uuid.UUID, error)
- func MagicRackID(wat string) (uuid.UUID, error)
- func MagicRackLayoutSlotID(wat string) (uuid.UUID, error)
- func MagicRackRoleID(wat string) (id uuid.UUID, err error)
- func MagicRoomID(wat string) (uuid.UUID, error)
- func MagicValidationID(s string) (uuid.UUID, error)
- func MagicValidationPlanID(s string) (uuid.UUID, error)
- func MagicWorkspaceID(wat string) (id uuid.UUID, err error)
- func MagicWorkspaceRackID(workspace fmt.Stringer, wat string) (uuid.UUID, error)
- func NoAdmin() bool
- func TimeStr(t time.Time) string
- func UserIsRoot() bool
- func WriteConfig()
- func WriteConfigForce()
- type GithubAsset
- type GithubRelease
- type GithubReleases
- Bugs
Constants ¶
const DateFormat = "2006-01-02 15:04:05 -0700 MST"
DateFormat should be used in date formatting calls to ensure uniformity of output
const GhOrg = "joyent"
const GhRepo = "conch-shell"
const RefreshTokenTime = 86400
RefreshTokenTime represent when a JWT token will be refreshed, based on this many seconds left on the expiry time
Variables ¶
var ( // UserAgent will be used as the http user agent when making API calls UserAgent string // JSON tells us if we should output JSON JSON bool IgnoreConfig bool Token string BaseURL string // Config is a global Config object Config *config.ConchConfig ConfigPath string // ActiveProfile represents, well, the active profile ActiveProfile *config.ConchProfile // API is a global Conch API object API *conch.Conch // Debug decides if we should put the API in debug mode // Yes, this is a bit of a kludge Debug bool // Trace decides if we should trace the HTTP transactions // Yes, this is a bit of a kludge Trace bool )
var ( Version string GitRev string SemVersion semver.Version FlagsDisableApiVersionCheck string // Used in shell development FlagsDisableApiTokenCRUD string // Useful for preventing automations from creating and deleting tokens FlagsNoAdmin string // Useful for preventing automations from accessing admin commands )
These variables are provided by the build environment
var ErrNoGithubRelease = errors.New("no appropriate github release found")
Functions ¶
func BuildAPIAndVerifyLogin ¶
func BuildAPIAndVerifyLogin()
BuildAPIAndVerifyLogin builds a Conch object using the Config data and calls VerifyLogin
func CleanVersion ¶ added in v1.11.0
CleanVersion removes a "v" prefix, and anything after a dash For example, pass in v2.99.10-abcde-dirty and get back a semver containing 2.29.10 Why? Git and Semver differ in their notions of what those extra bits mean. In Git, they mean "v2.99.10, plus some other stuff that happend". In semver, they indicate that this is a prerelease of v2.99.10. Obviously this screws up comparisions. This function lets us clean that stuff out so we can get a clean comparison
func DDP ¶ added in v1.11.0
func DDP(v interface{})
DDP pretty prints a structure to stderr. "Deep Data Printer"
func DisableApiTokenCRUD ¶ added in v1.12.0
func DisableApiTokenCRUD() bool
func DisableApiVersionCheck ¶ added in v1.11.0
func DisableApiVersionCheck() bool
func DisplayDevices ¶
DisplayDevices is an abstraction to make sure that the output of Devices is uniform, be it tables, json, or full json
func FindShortUUID ¶ added in v0.3.0
FindShortUUID takes a string and tries to find a UUID in a list of UUIDs that match by prefix (first 4 bytes)
func GetMarkdownTable ¶
func GetMarkdownTable() (table *tablewriter.Table)
GetMarkdownTable returns a tablewriter configured to output markdown compatible text
func GithubReleaseCheck ¶ added in v1.12.0
func GithubReleaseCheck()
func InteractiveForcePasswordChange ¶ added in v1.4.0
func InteractiveForcePasswordChange()
InteractiveForcePasswordChange is an abstraction for the process of prompting a user for a new password, validating it, and issuing the API calls to execute the change
func IsPasswordSane ¶ added in v1.4.0
func IsPasswordSane(password string, profile *config.ConchProfile) error
IsPasswordSane verifies that the given password follows the current rules and restrictions
func JSONOutIndent ¶ added in v1.2.0
func JSONOutIndent(thingy interface{})
JSONOutIndent marshals an interface to indented JSON
func MagicDatacenterID ¶ added in v1.11.0
MagicDatacenterID takes a string and tries to find a valid global datacenter UUID. If the string is a UUID, it doesn't get checked further. If it's not a UUID, we dig through GetDatacenters() looking for UUIDs that match up to the first hyphen. *NOTE*: This will fail if the user is not a global admin
func MagicProductID ¶
MagicProductID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. If not, we dig through GetHardwareProducts() looking for UUIDs that match up to the first hyphen or where the product name or SKU matches the string
func MagicRackID ¶
MagicRackID takes a string and tries to find a valid global rack UUID. If the string is a UUID, it doesn't get checked further. If it's not a UUID, we dig through GetRacks() looking for UUIDs that match up to the first hyphen.
func MagicRackLayoutSlotID ¶ added in v1.12.0
MagicRackLayoutSlotID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. If it's not a UUID, we dig through GetRackLayoutSlots�() looking for UUIDs that match up to the first hyphen.
func MagicRackRoleID ¶ added in v1.12.0
MagicRackRoleID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. If not, we dig through GetRackRoles() looking for UUIDs that match up to the first hyphen or where the role name matches the string
func MagicRoomID ¶ added in v1.12.0
MagicRoomID takes a string and tries to find a valid global UUID. If the string is a UUID, it doesn't get checked further. If it's not a UUID, we dig through GetRooms() looking for UUIDs that match up to the first hyphen.
func MagicValidationID ¶ added in v0.3.0
MagicValidationID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. Otherwise, we use FindShortUUID to see if the string matches an existing Validation ID
func MagicValidationPlanID ¶ added in v0.3.0
MagicValidationPlanID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. Otherwise, we use FindShortUUID to see if the string matches an existing Validation Plan ID
func MagicWorkspaceID ¶
MagicWorkspaceID takes a string and tries to find a valid UUID. If the string is a UUID, it doesn't get checked further. If not, we dig through GetWorkspaces() looking for UUIDs that match up to the first hyphen or where the workspace name matches the string
func MagicWorkspaceRackID ¶ added in v1.12.0
MagicWorkspaceRackID takes a workspace UUID and a string and tries to find a valid rack UUID. If the string is a UUID, it doesn't get checked further. If it's not a UUID, we dig through GetWorkspaceRacks() looking for UUIDs that match up to the first hyphen or where the name matches the string.
func UserIsRoot ¶ added in v1.11.0
func UserIsRoot() bool
func WriteConfig ¶ added in v0.2.0
func WriteConfig()
WriteConfig serializes the Config struct to disk
func WriteConfigForce ¶ added in v1.12.0
func WriteConfigForce()
Types ¶
type GithubAsset ¶ added in v1.1.0
type GithubAsset struct { URL string `json:"url"` Name string `json:"name"` State string `json:"state"` BrowserDownloadURL string `json:"browser_download_url"` }
GithubAsset represents a file inside of a github release
type GithubRelease ¶
type GithubRelease struct { URL string `json:"html_url"` TagName string `json:"tag_name"` SemVer semver.Version `json:"-"` // Will be set to 0.0.0 if no releases are found Body string `json:"body"` Name string `json:"name"` Assets []GithubAsset `json:"assets"` PreRelease bool `json:"prerelease"` Upgrade bool `json:"-"` }
GithubRelease represents a 'release' for a Github project
func LatestGithubRelease ¶
func LatestGithubRelease() (gh GithubRelease, err error)
LatestGithubRelease returns some fields from the latest Github Release that matches our major version
type GithubReleases ¶ added in v1.11.0
type GithubReleases []GithubRelease
func GithubReleasesSince ¶ added in v1.11.0
func GithubReleasesSince(start semver.Version) GithubReleases
func (GithubReleases) Len ¶ added in v1.11.0
func (g GithubReleases) Len() int
func (GithubReleases) Less ¶ added in v1.11.0
func (g GithubReleases) Less(i, j int) bool
func (GithubReleases) Swap ¶ added in v1.11.0
func (g GithubReleases) Swap(i, j int)
Notes ¶
Bugs ¶
for back compat AZ and Rack were not ported over since they are always zero-value without fullOutput