Documentation
¶
Overview ¶
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 DisplayDevices(devices []conch.Device, fullOutput bool) (err error)
- func FindShortUUID(s string, uuids []uuid.UUID) (uuid.UUID, error)
- func GenerateDeviceFlags(d conch.Device) (flags string)
- func GetMarkdownTable() (table *tablewriter.Table)
- func InteractiveForcePasswordChange()
- func IsPasswordSane(password string, profile *config.ConchProfile) error
- func JSONOut(thingy interface{})
- func JSONOutIndent(thingy interface{})
- func MagicDBProductID(wat string) (uuid.UUID, error)
- func MagicDeviceRoleID(wat string) (id uuid.UUID, err error)
- func MagicDeviceServiceID(wat string) (id uuid.UUID, err error)
- func MagicGlobalDatacenterID(wat string) (uuid.UUID, error)
- func MagicGlobalRackID(wat string) (uuid.UUID, error)
- func MagicGlobalRackLayoutSlotID(wat string) (uuid.UUID, error)
- func MagicGlobalRackRoleID(wat string) (id uuid.UUID, err error)
- func MagicGlobalRoomID(wat string) (uuid.UUID, error)
- func MagicProductID(wat string) (uuid.UUID, error)
- func MagicRackID(workspace fmt.Stringer, 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 TableizeMinimalDevices(devices []MinimalDevice, fullOutput bool, table *tablewriter.Table) *tablewriter.Table
- func TimeStr(t time.Time) string
- func WriteConfig()
- type GithubAsset
- type GithubRelease
- type MinimalDevice
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 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 // Config is a global Config object Config *config.ConchConfig // ActiveProfile represents, well, the active profile ActiveProfile *config.ConchProfile // API is a global Conch API object API *conch.Conch )
var ( Version string BuildTime string GitRev string BuildHost string )
These variables are provided by the build environment
Functions ¶
func BuildAPIAndVerifyLogin ¶
func BuildAPIAndVerifyLogin()
BuildAPIAndVerifyLogin builds a Conch object using the Config data and calls VerifyLogin
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 GenerateDeviceFlags ¶
GenerateDeviceFlags is an abstraction to make sure that the 'flags' field for Devices remains uniform
func GetMarkdownTable ¶
func GetMarkdownTable() (table *tablewriter.Table)
GetMarkdownTable returns a tablewriter configured to output markdown compatible text
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 MagicDBProductID ¶ added in v1.3.0
MagicDBProductID 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 MagicDeviceRoleID ¶ added in v0.3.0
MagicDeviceRoleID 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 GetDeviceRoles() looking for UUIDs that match up to the first hyphen
func MagicDeviceServiceID ¶ added in v0.3.0
MagicDeviceServiceID 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 GetDeviceServices() looking for UUIDs that match up to the first hyphen or where the device service name matches the string
func MagicGlobalDatacenterID ¶ added in v1.2.0
MagicGlobalDatacenterID 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 GetGlobalDatacenters() looking for UUIDs that match up to the first hyphen. *NOTE*: This will fail if the user is not a global admin
func MagicGlobalRackID ¶ added in v1.2.0
MagicGlobalRackID 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 GetGlobalRacks() looking for UUIDs that match up to the first hyphen. *NOTE*: This will fail if the user is not a global admin
func MagicGlobalRackLayoutSlotID ¶ added in v1.2.0
MagicGlobalRackLayoutSlotID 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 GetGlobalRackLayoutSlots�() looking for UUIDs that match up to the first hyphen. *NOTE*: This will fail if the user is not a global admin
func MagicGlobalRackRoleID ¶ added in v1.2.0
MagicGlobalRackRoleID 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 GetGlobalRackRoles() looking for UUIDs that match up to the first hyphen or where the role name matches the string *NOTE*: This will fail if the user is not a global admin
func MagicGlobalRoomID ¶ added in v1.2.0
MagicGlobalRoomID 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 GetGlobalRooms() 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 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 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 TableizeMinimalDevices ¶
func TableizeMinimalDevices(devices []MinimalDevice, fullOutput bool, table *tablewriter.Table) *tablewriter.Table
TableizeMinimalDevices is an abstraction to make sure that tables of Devices-turned-MinimalDevices are uniform
func WriteConfig ¶ added in v0.2.0
func WriteConfig()
WriteConfig serializes the Config struct to disk
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"` }
GithubRelease represents a 'release' for a Github project
func LatestGithubRelease ¶
func LatestGithubRelease(owner string, repo string) (*GithubRelease, error)
LatestGithubRelease returns some fields from the latest Github Release object for the given owner and repo via "https://api.github.com/repos/:owner/:repo/releases/latest"
type MinimalDevice ¶
type MinimalDevice struct { ID string `json:"id"` AssetTag string `json:"asset_tag"` Created pgtime.PgTime `json:"created"` LastSeen pgtime.PgTime `json:"last_seen"` Health string `json:"health"` Flags string `json:"flags"` AZ string `json:"az"` Rack string `json:"rack"` }
MinimalDevice represents a limited subset of Device data, that which we are going to present to the user