Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveFunctions(appliances []openapi.Appliance) map[string]bool
- func AppendUniqueAppliance(appliances []openapi.Appliance, appliance openapi.Appliance) []openapi.Appliance
- func AppendUniqueApplianceStats(stats []openapi.StatsAppliancesListAllOfData, ...) []openapi.StatsAppliancesListAllOfData
- func AutoscalingGateways(appliances []openapi.Appliance) (*openapi.Appliance, []openapi.Appliance)
- func BackupPrompt(appliances []openapi.Appliance, preSelected []openapi.Appliance) ([]openapi.Appliance, error)
- func ChunkApplianceGroup(chunkSize int, applianceGroups map[int][]openapi.Appliance) [][]openapi.Appliance
- func CleanupBackup(opts *BackupOpts, IDs map[string]string) error
- func CompareVersionsAndBuildNumber(x, y *version.Version) (int, error)
- func DownloadDockerBundles(ctx context.Context, p *tui.Progress, client *http.Client, path string, ...) (*os.File, error)
- func FilterApplianceStats(stats []openapi.StatsAppliancesListAllOfData, ...) ([]openapi.StatsAppliancesListAllOfData, []openapi.StatsAppliancesListAllOfData, ...)
- func FilterAppliances(appliances []openapi.Appliance, filter map[string]map[string]string, ...) ([]openapi.Appliance, []openapi.Appliance, error)
- func FilterAvailable(appliances []openapi.Appliance, stats []openapi.StatsAppliancesListAllOfData) ([]openapi.Appliance, []openapi.Appliance, error)
- func FindCurrentController(appliances []openapi.Appliance, hostname string) (*openapi.Appliance, error)
- func FindPrimaryController(appliances []openapi.Appliance, hostname string, validate bool) (*openapi.Appliance, error)
- func GetActiveFunctions(appliance openapi.Appliance) []string
- func GetApplianceVersion(appliance openapi.Appliance, stats openapi.StatsAppliancesList) (*version.Version, error)
- func GroupByFunctions(appliances []openapi.Appliance) map[string][]openapi.Appliance
- func HasDiffVersions(stats []openapi.StatsAppliancesListAllOfData) (bool, map[string]string)
- func HasLowDiskSpace(stats []openapi.StatsAppliancesListAllOfData) []openapi.StatsAppliancesListAllOfData
- func IsMajorUpgrade(current, next *version.Version) bool
- func IsMinorUpgrade(current, next *version.Version) bool
- func IsOnAppliance() bool
- func IsPatchUpgrade(current, next *version.Version) bool
- func NeedsMultiControllerUpgrade(upgradeStatuses map[string]UpgradeStatusResult, ...) (bool, error)
- func ParseVersionFromZip(filename string) (*version.Version, error)
- func ParseVersionString(input string) (*version.Version, error)
- func PerformBackup(cmd *cobra.Command, args []string, opts *BackupOpts) (map[string]string, error)
- func PrepareBackup(opts *BackupOpts) error
- func PrettyBytes(v float64) string
- func PrintDiskSpaceWarningMessage(out io.Writer, stats []openapi.StatsAppliancesListAllOfData, apiVersion int)
- func PromptSelect(ctx context.Context, a *Appliance, filter map[string]map[string]string, ...) (string, error)
- func PromptSelectAll(ctx context.Context, a *Appliance, filter map[string]map[string]string, ...) (string, error)
- func ShouldDisable(from, to *version.Version) bool
- func ShowAutoscalingWarningMessage(templateAppliance *openapi.Appliance, gateways []openapi.Appliance) (string, error)
- func SpecificVersionChecks(current, future *version.Version) error
- func SplitAppliancesByGroup(appliances []openapi.Appliance) map[int][]openapi.Appliance
- func StatsActiveFunctions(s openapi.StatsAppliancesListAllOfData) string
- func StatsIsOnline(s openapi.StatsAppliancesListAllOfData) bool
- func ValidateHostname(controller openapi.Appliance, hostname string) error
- type Appliance
- func (a *Appliance) ApplianceSwitchPartition(ctx context.Context, id string) error
- func (a *Appliance) DeleteFile(ctx context.Context, filename string) error
- func (a *Appliance) DisableController(ctx context.Context, id string, appliance openapi.Appliance) error
- func (a *Appliance) DisableMaintenanceMode(ctx context.Context, id string) (string, error)
- func (a *Appliance) EnableController(ctx context.Context, id string, appliance openapi.Appliance) error
- func (a *Appliance) EnableMaintenanceMode(ctx context.Context, id string) (string, error)
- func (a *Appliance) FileStatus(ctx context.Context, filename string) (*openapi.File, error)
- func (a *Appliance) ForceDisableControllers(ctx context.Context, disable []openapi.Appliance) (*openapi.AppliancesForceDisableControllersPost200Response, string, error)
- func (a *Appliance) Get(ctx context.Context, applianceID string) (*openapi.Appliance, error)
- func (a *Appliance) List(ctx context.Context, filter map[string]map[string]string, orderBy []string, ...) ([]openapi.Appliance, error)
- func (a *Appliance) ListFiles(ctx context.Context, orderBy []string, descending bool) ([]openapi.File, error)
- func (a *Appliance) PrepareFileOn(ctx context.Context, filename, id string, devKeyring bool) (string, error)
- func (a *Appliance) RepartitionIPAllocations(ctx context.Context) (string, error)
- func (a *Appliance) Stats(ctx context.Context, filter map[string]map[string]string, orderBy []string, ...) (*openapi.StatsAppliancesList, *http.Response, error)
- func (a *Appliance) UpdateAppliance(ctx context.Context, id string, appliance openapi.Appliance) error
- func (a *Appliance) UpdateMaintenanceMode(ctx context.Context, id string, value bool) (string, error)
- func (a *Appliance) UpgradeCancel(ctx context.Context, applianceID string) error
- func (a *Appliance) UpgradeComplete(ctx context.Context, id string, SwitchPartition bool) error
- func (a *Appliance) UpgradeStatus(ctx context.Context, applianceID string) (*openapi.AppliancesIdUpgradeDelete200Response, error)
- func (a *Appliance) UpgradeStatusMap(ctx context.Context, appliances []openapi.Appliance) (map[string]UpgradeStatusResult, error)
- func (a *Appliance) UpgradeStatusRetry(ctx context.Context, applianceID string) (*openapi.AppliancesIdUpgradeDelete200Response, error)
- func (a *Appliance) UpgradeSwitchPartition(ctx context.Context, id string) error
- func (a *Appliance) UploadFile(ctx context.Context, r io.Reader, headers map[string]string) error
- func (a *Appliance) UploadToController(ctx context.Context, url, filename string) error
- func (a *Appliance) ZTPStatus(ctx context.Context) (*openapi.ZtpStatus, error)
- func (a *Appliance) ZTPUpdateNotify(ctx context.Context) (*openapi.ZtpVersionStatus, error)
- type ApplianceStatus
- type BackupOpts
- type CalledAs
- type DockerManifest
- type ImageJSON
- type IsPrimaryUpgrade
- type ManifestConfig
- type SkipUpgrade
- type UpgradeStatus
- type UpgradeStatusResult
- type WaitForApplianceStatus
- type WaitForUpgradeStatus
Constants ¶
const ( //lint:file-ignore U1000 All available upgrade statuses UpgradeStatusIdle = "idle" UpgradeStatusStarted = "started" UpgradeStatusDownloading = "downloading" UpgradeStatusVerifying = "verifying" UpgradeStatusReady = "ready" UpgradeStatusInstalling = "installing" UpgradeStatusSuccess = "success" UpgradeStatusFailed = "failed" FileReady = "Ready" FileFailed = "Failed" )
const ( SkipReasonNotPrepared = "appliance is not prepared for upgrade" SkipReasonOffline = "appliance is offline" SkipReasonFiltered = "filtered using the '--include' and/or '--exclude' flag" SkipReasonAlreadyPrepared = "appliance is already prepared for upgrade with a higher or equal version" SkipReasonUnsupportedUpgradePath = "Upgrading from version 6.0.0 to version 6.2.x is unsupported. Version 6.0.1 or later is required." )
const ( IsLower = -1 IsEqual = 0 IsGreater = 1 )
const ( MajorVersion = uint8(4) MinorVersion = uint8(2) PatchVersion = uint8(1) )
const ( FunctionController = "Controller" FunctionGateway = "Gateway" FunctionPortal = "Portal" FunctionConnector = "Connector" FunctionLogServer = "LogServer" FunctionLogForwarder = "LogForwarder" FilterDelimiter = "&" )
const ( PrimaryUpgrade IsPrimaryUpgrade = "IsPrimaryUpgrade" Caller CalledAs = "calledAs" )
Variables ¶
var (
DefaultBackupDestination = filesystem.BackupDir()
)
var DefaultCommandFilter = map[string]map[string]string{
"include": {},
"exclude": {},
}
var StatReady = []string{
statControllerReady,
statSingleControllerReady,
statMultiControllerReady,
statApplianceReady,
}
var StatusNotBusy = []string{
statusHealthy,
statusWarning,
statusError,
statusNotAvailable,
statusOffline,
}
Functions ¶
func ActiveFunctions ¶
ActiveFunctions returns a map of all active functions in the appliances.
func AppendUniqueAppliance ¶
func AppendUniqueApplianceStats ¶
func AppendUniqueApplianceStats(stats []openapi.StatsAppliancesListAllOfData, stat openapi.StatsAppliancesListAllOfData) []openapi.StatsAppliancesListAllOfData
func AutoscalingGateways ¶
AutoscalingGateways return the template appliance and all gateways
func BackupPrompt ¶
func ChunkApplianceGroup ¶
func ChunkApplianceGroup(chunkSize int, applianceGroups map[int][]openapi.Appliance) [][]openapi.Appliance
ChunkApplianceGroup separates the result from SplitAppliancesByGroup into different slices based on the appliance functions and site configuration
func CleanupBackup ¶
func CleanupBackup(opts *BackupOpts, IDs map[string]string) error
func CompareVersionsAndBuildNumber ¶
CompareVersionsAndBuildNumber compares two versions and returns the result with an integer representation -1 if y is lower than x 0 if versions match 1 if y is greater than x
func DownloadDockerBundles ¶
func FilterApplianceStats ¶
func FilterApplianceStats(stats []openapi.StatsAppliancesListAllOfData, filter map[string]map[string]string, orderBy []string, descending bool) ([]openapi.StatsAppliancesListAllOfData, []openapi.StatsAppliancesListAllOfData, error)
func FilterAppliances ¶
func FilterAvailable ¶
func FilterAvailable(appliances []openapi.Appliance, stats []openapi.StatsAppliancesListAllOfData) ([]openapi.Appliance, []openapi.Appliance, error)
FilterAvailable return lists of online, offline, errors that will be used during upgrade
func FindCurrentController ¶
func FindPrimaryController ¶
func FindPrimaryController(appliances []openapi.Appliance, hostname string, validate bool) (*openapi.Appliance, error)
FindPrimaryController The given hostname should match one of the Controller's actual admin hostname. Hostnames should be compared in a case insensitive way.
func GetActiveFunctions ¶
func GetApplianceVersion ¶
func GetApplianceVersion(appliance openapi.Appliance, stats openapi.StatsAppliancesList) (*version.Version, error)
func GroupByFunctions ¶
GroupByFunctions group appliances by function
func HasDiffVersions ¶
func HasDiffVersions(stats []openapi.StatsAppliancesListAllOfData) (bool, map[string]string)
func HasLowDiskSpace ¶
func HasLowDiskSpace(stats []openapi.StatsAppliancesListAllOfData) []openapi.StatsAppliancesListAllOfData
func IsMajorUpgrade ¶
func IsMajorUpgrade(current, next *version.Version) bool
func IsMinorUpgrade ¶
func IsMinorUpgrade(current, next *version.Version) bool
func IsOnAppliance ¶
func IsOnAppliance() bool
func IsPatchUpgrade ¶
func IsPatchUpgrade(current, next *version.Version) bool
func NeedsMultiControllerUpgrade ¶
func NeedsMultiControllerUpgrade(upgradeStatuses map[string]UpgradeStatusResult, initialStatData []openapi.StatsAppliancesListAllOfData, all, preparing []openapi.Appliance, majorOrMinor bool) (bool, error)
func ParseVersionFromZip ¶
func ParseVersionString ¶
ParseVersionString tries to determine appliance version based on the input filename, It assumes the file is has the standard naming convention of appgate-5.4.4-26245-release.img.zip where 5.4.4 is the semver of the appliance.
func PerformBackup ¶
func PrepareBackup ¶
func PrepareBackup(opts *BackupOpts) error
func PrettyBytes ¶
func PrintDiskSpaceWarningMessage ¶
func PrintDiskSpaceWarningMessage(out io.Writer, stats []openapi.StatsAppliancesListAllOfData, apiVersion int)
func PromptSelect ¶
func PromptSelect(ctx context.Context, a *Appliance, filter map[string]map[string]string, orderBy []string, descending bool) (string, error)
PromptSelect from online appliances
func PromptSelectAll ¶
func PromptSelectAll(ctx context.Context, a *Appliance, filter map[string]map[string]string, orderBy []string, descending bool) (string, error)
PromptSelectAll from all appliances, offline and online
func ShouldDisable ¶
func ShouldDisable(from, to *version.Version) bool
func SpecificVersionChecks ¶
func SpecificVersionChecks(current, future *version.Version) error
func SplitAppliancesByGroup ¶
SplitAppliancesByGroup return a map of slices of appliances based on their active function and site. e.g All active gateways in the same site are grouped together.
func StatsActiveFunctions ¶
func StatsActiveFunctions(s openapi.StatsAppliancesListAllOfData) string
func StatsIsOnline ¶
func StatsIsOnline(s openapi.StatsAppliancesListAllOfData) bool
StatsIsOnline will return true if the Controller reports the appliance to be online in a valid status
Types ¶
type Appliance ¶
type Appliance struct { APIClient *openapi.APIClient HTTPClient *http.Client Token string UpgradeStatusWorker WaitForUpgradeStatus ApplianceStats WaitForApplianceStatus }
Appliance is a wrapper around the APIClient for common functions around the appliance API that will be used within several commands.
func (*Appliance) ApplianceSwitchPartition ¶
func (*Appliance) DeleteFile ¶
DeleteFile Delete a File from the current Controller.
func (*Appliance) DisableController ¶
func (*Appliance) DisableMaintenanceMode ¶
func (*Appliance) EnableController ¶
func (*Appliance) EnableMaintenanceMode ¶
func (*Appliance) FileStatus ¶
FileStatus Get the status of a File uploaded to the current Controller.
func (*Appliance) ForceDisableControllers ¶
func (*Appliance) List ¶
func (a *Appliance) List(ctx context.Context, filter map[string]map[string]string, orderBy []string, descending bool) ([]openapi.Appliance, error)
List from the Collective Filter is applied in app after getting all the appliances because the auto generated API screws up the 'filterBy' command
func (*Appliance) PrepareFileOn ¶
func (*Appliance) RepartitionIPAllocations ¶
func (*Appliance) UpdateAppliance ¶
func (*Appliance) UpdateMaintenanceMode ¶
func (*Appliance) UpgradeCancel ¶
func (*Appliance) UpgradeComplete ¶
func (*Appliance) UpgradeStatus ¶
func (*Appliance) UpgradeStatusMap ¶
func (a *Appliance) UpgradeStatusMap(ctx context.Context, appliances []openapi.Appliance) (map[string]UpgradeStatusResult, error)
UpgradeStatusMap return a map with appliance.id, UpgradeStatusResult
func (*Appliance) UpgradeStatusRetry ¶
func (*Appliance) UpgradeSwitchPartition ¶
func (*Appliance) UploadFile ¶
UploadFile directly to the current Controller. Note that the File is stored only on the current Controller, not synced between Controllers.
func (*Appliance) UploadToController ¶
func (*Appliance) ZTPUpdateNotify ¶
type ApplianceStatus ¶
type ApplianceStatus struct {
Appliance *Appliance
}
func (*ApplianceStatus) WaitForApplianceState ¶
type BackupOpts ¶
type BackupOpts struct { Config *configuration.Config Appliance func(*configuration.Config) (*Appliance, error) Out io.Writer SpinnerOut func() io.Writer Destination string With []string AllFlag bool PrimaryFlag bool CurrentFlag bool NoInteractive bool FilterFlag map[string]map[string]string OrderBy []string Descending bool Quiet bool CiMode bool }
type DockerManifest ¶
type DockerManifest struct { SchemaVersion int MediaType string Config ManifestConfig Layers []ManifestConfig }
type IsPrimaryUpgrade ¶
type IsPrimaryUpgrade string
type ManifestConfig ¶
type SkipUpgrade ¶
func CheckVersions ¶
func CheckVersions(ctx context.Context, stats openapi.StatsAppliancesList, appliances []openapi.Appliance, v *version.Version) ([]openapi.Appliance, []SkipUpgrade)
CheckVersions will check if appliance versions are equal to the version being uploaded on all appliances Returns a slice of appliances that are not equal, a slice of appliances that have the same version and an error
func (SkipUpgrade) Error ¶
func (su SkipUpgrade) Error() string
type UpgradeStatus ¶
type UpgradeStatus struct {
Appliance *Appliance
}
type UpgradeStatusResult ¶
type UpgradeStatusResult struct {
Status, Details, Name string
}
type WaitForApplianceStatus ¶
type WaitForApplianceStatus interface { WaitForApplianceState(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error // WaitForStatus tries appliance stats until the appliance has want status or it reaches the timeout WaitForApplianceStatus(ctx context.Context, appliance openapi.Appliance, want []string, tracker *tui.Tracker) error }
type WaitForUpgradeStatus ¶
type WaitForUpgradeStatus interface { // WaitForUpgradeStatus does exponential backoff retries on upgrade status until it reaches a desiredStatuses and reports it to current <- string WaitForUpgradeStatus(ctx context.Context, appliance openapi.Appliance, desiredStatuses []string, undesiredStatuses []string, tracker *tui.Tracker) error }