Back to godoc.org

Package utils

v0.0.0-...-bd98d2d
Latest Go to latest

The highest tagged major version is .

Published: Sep 19, 2020 | License: BSD-3-Clause | Module: chromium.googlesource.com/infra/infra.git

Index

Constants

const (
	InputDetails              string = "Please enter the details: "
	RequiredField             string = "is a required field. It cannot be blank/empty."
	WrongInput                string = "\n  WRONG INPUT!!\n"
	ChooseOption              string = "\n Choose an option\n"
	ChooseChromePlatform      string = "\n Choose a ChromePlatform\n"
	ChooseMachineLSEPrototype string = "\n Choose a MachineLSE Prototype\n"
	ChooseChameleonType       string = "\n Choose a ChameleonType \n"
	ChooseCameraType          string = "\n Choose a CameraType \n"
	ChooseAntennaConnection   string = "\n Choose an AntennaConnection \n"
	ChooseRouter              string = "\n Choose a Router \n"
	ChooseCableType           string = "\n Choose a Cable \n"
	ChooseCameraboxFacing     string = "\n Choose a Facing for CameraBox \n"
	ChoosePheripheralType     string = "\n Choose a PheripheralType \n"
	ChooseVirtualType         string = "\n Choose a VirtualType \n"
	OptionToEnter             string = "\nDo you want to enter a "
	OptionToEnterMore         string = "\nDo you want to enter one more "
	ChooseLab                 string = "\n Choose a Lab\n"
	BroswerOrOSLab            string = "1=\"Browser Lab\"\n2=\"OS Lab\"\n"
	BrowserOrATLOrACSLab      string = "1=\"Browser Lab\"\n2=\"ATL Lab\"\n3=\"ACS Lab\"\n"
	DutOrLabstationOrServer   string = "1=\"DUT\"\n2=\"Labstation\"\n3=\"Server\"\n"
	DoesNotExist              string = " doesnt not exist in the system. Please check and enter again."
	AlreadyExists             string = " already exists in the system. Please check and enter again."
	ATL                       string = "ATL"
	ACS                       string = "ACS"
	Browser                   string = "Browser"
	Unknown                   string = "Unknown"

	YesNo       string = " (y/n)"
	ATLLab      string = "atl:"
	ACSLab      string = "acs:"
	BrowserLab  string = "browser:"
	MinMaxError string = "Maximum value must be greater than or equal to Minimum value."
)

Interactive mode messages for user input

const ClientVersion string = "clientversion"

ClientVersion used as a key in metadata within context

Variables

var (
	SwitchTitle              = []string{"Switch Name", "CapacityPort", "Zone", "Rack", "State", "UpdateTime"}
	KvmTitle                 = []string{"KVM Name", "MAC Address", "ChromePlatform", "CapacityPort", "Zone", "Rack", "State", "UpdateTime"}
	KvmFullTitle             = []string{"KVM Name", "MAC Address", "ChromePlatform", "CapacityPort", "IP", "Vlan", "State", "Zone", "Rack", "UpdateTime"}
	RpmTitle                 = []string{"RPM Name", "MAC Address", "CapacityPort", "UpdateTime"}
	DracTitle                = []string{"Drac Name", "Display name", "MAC Address", "Switch", "Switch Port", "Password", "Zone", "Rack", "Machine", "UpdateTime"}
	DracFullTitle            = []string{"Drac Name", "MAC Address", "Switch", "Switch Port", "Attached Host", "IP", "Vlan", "Zone", "Rack", "Machine", "UpdateTime"}
	NicTitle                 = []string{"Nic Name", "MAC Address", "Switch", "Switch Port", "Zone", "Rack", "Machine", "UpdateTime"}
	BrowserMachineTitle      = []string{"Machine Name", "Serial Number", "Zone", "Rack", "ChromePlatform", "DeploymentTicket", "Description", "State", "Realm", "UpdateTime"}
	OSMachineTitle           = []string{"Machine Name", "Zone", "Rack", "Barcode", "UpdateTime"}
	MachinelseprototypeTitle = []string{"Machine Prototype Name", "Occupied Capacity", "PeripheralTypes", "VirtualTypes", "Tags", "UpdateTime"}
	RacklseprototypeTitle    = []string{"Rack Prototype Name", "PeripheralTypes", "Tags", "UpdateTime"}
	ChromePlatformTitle      = []string{"Platform Name", "Manufacturer", "Description", "UpdateTime"}
	VlanTitle                = []string{"Vlan Name", "CIDR Block", "IP Capacity", "Description", "State", "UpdateTime"}
	VMTitle                  = []string{"VM Name", "OS Version", "MAC Address", "Zone", "Host", "Vlan", "IP", "State", "DeploymentTicket", "Description", "UpdateTime"}
	RackTitle                = []string{"Rack Name", "Zone", "Capacity", "State", "Realm", "UpdateTime"}
	MachineLSETitle          = []string{"Host", "OS Version", "Zone", "Virtual Datacenter", "Rack", "Machine(s)", "Nic", "Vlan", "IP", "State", "VM capacity", "DeploymentTicket", "Description", "UpdateTime"}
	MachineLSETFullitle      = []string{"Host", "OS Version", "Manufacturer", "Machine", "Zone", "Virtual Datacenter", "Rack", "Nic", "IP", "Vlan", "MAC Address", "State", "VM capacity", "Description", "UpdateTime"}
	ZoneTitle                = []string{"Name", "EnumName", "Department"}
	StateTitle               = []string{"Name", "EnumName", "Description"}
)

Titles for printing table format list

var ClearFieldValue string = "-"

ClearFieldValue specifying this value in update command will send empty value while doing partial updates using update field mask.

func BatchList

func BatchList(ctx context.Context, ic ufsAPI.FleetClient, listFunc listAll, filters []string, pageSize int, keysOnly bool) ([]proto.Message, error)

BatchList returns the all listed entities by filters

func CheckExistsVM

func CheckExistsVM(existingVMs []*ufspb.VM, vmName string) bool

CheckExistsVM checks if the given vm already exists in the slice

func ChromePlatformExists

func ChromePlatformExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

ChromePlatformExists checks if the given ChromePlatform exists in the system

func ConcurrentGet

func ConcurrentGet(ctx context.Context, ic ufsAPI.FleetClient, names []string, getSingle getSingleFunc) []proto.Message

ConcurrentGet runs multiple goroutines making Get calls to UFS

func DoList

func DoList(ctx context.Context, ic ufsAPI.FleetClient, listFunc listAll, pageSize int32, filter string, keysOnly bool) ([]proto.Message, error)

DoList lists the outputs

func DracExists

func DracExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

DracExists checks if the given Drac exists in the system

func EntityExists

func EntityExists(ctx context.Context, ic UfleetAPI.FleetClient, resource, name string) bool

EntityExists checks if the given resource exists in the system

func FullMode

func FullMode(full bool) bool

FullMode checks if full mode is enabled

func GetAssetsInOrder

func GetAssetsInOrder(logFile string) ([]*fleet.ChopsAsset, error)

GetAssetsInOrder reads a group of assets from log file.

func GetChromePlatformInteractiveInput

func GetChromePlatformInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, cp *fleet.ChromePlatform, update bool)

GetChromePlatformInteractiveInput gets ChromePlatform input in interactive mode

Name(string) -> Manufacturer(string) -> Description(string)

func GetDracInteractiveInput

func GetDracInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, drac *fleet.Drac, update bool) string

GetDracInteractiveInput get drac input in interactive mode

Name(string) -> Display name(string) -> MAC Address(string) -> -> SwitchInterface[Switch(string, resource) -> Switch Port(int)] -> -> Password(string)

func GetInteractiveInput

func GetInteractiveInput() []string

GetInteractiveInput collects the scanned string list.

func GetKVMInteractiveInput

func GetKVMInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, kvm *fleet.KVM, update bool) string

GetKVMInteractiveInput get kvm input in interactive mode

Name(string) -> MAC Address(string) -> ChromePlatform(string, resource) -> -> CapacityPort(int) -> Rack name(string)

func GetMachineInteractiveInput

func GetMachineInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, machine *fleet.Machine, update bool)

GetMachineInteractiveInput get Machine input in interactive mode

Name(string) -> Lab(enum) -> Browser/OS LAB(choice to branch) -> -> getBrowserMachine()/getOSMachine() -> Realm(string)

func GetMachinelseInteractiveInput

func GetMachinelseInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, machinelse *fleet.MachineLSE, update bool)

GetMachinelseInteractiveInput get MachineLSE input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice to branch) -> -> getBrowserMachineLse()/getOSMachineLse() -> -> Machine(repeated string, resource)

func GetMachinelsePrototypeInteractiveInput

func GetMachinelsePrototypeInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, mlsep *fleet.MachineLSEPrototype, update bool)

GetMachinelsePrototypeInteractiveInput gets MachineLSEPrototype input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice) -> Occupied Capacity(int) -> -> getPeripheralRequirements() -> getVirtualRequirements()

func GetNextPage

func GetNextPage(pageToken string) (bool, error)

GetNextPage gets user input for to get next page of items

func GetNicInteractiveInput

func GetNicInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, nic *fleet.Nic, update bool) string

GetNicInteractiveInput get nic input in interactive mode

Name(string) -> MAC Address(string) -> -> SwitchInterface[Switch(string, resource) -> Switch Port(int)] -> -> Machine name(string)

func GetRacklsePrototypeInteractiveInput

func GetRacklsePrototypeInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, rlsep *fleet.RackLSEPrototype, update bool)

GetRacklsePrototypeInteractiveInput gets RackLSEPrototype input in interactive mode

Name(string) -> Broswer/ATL/ACS LAB(choice) -> getPeripheralRequirements()

func GetStringSlice

func GetStringSlice(msg string) []string

GetStringSlice converts the comma separated string to a slice of strings

func GetSwitchInteractiveInput

func GetSwitchInteractiveInput(ctx context.Context, ic UfleetAPI.FleetClient, s *fleet.Switch, update bool) string

GetSwitchInteractiveInput get switch input in interactive mode

Name(string) -> CapacityPort(int) -> Rack name(string)

func GetUpdateMask

func GetUpdateMask(set *flag.FlagSet, paths map[string]string) *field_mask.FieldMask

GetUpdateMask returns a *field_mask.FieldMask containing paths based on which flags have been set.

paths is a map of cmd line option flags to field names of the object.

func IsLocation

func IsLocation(iput string) bool

IsLocation determines if a string describes a ChromeOS lab location

func JoinFilters

func JoinFilters(old []string, filters ...string) []string

JoinFilters joins several filters together

func KVMExists

func KVMExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

KVMExists checks if the given KVM exists in the system

func MachineExists

func MachineExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineExists checks if the given Machine exists in the system

func MachineLSEExists

func MachineLSEExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineLSEExists checks if the given MachineLSE exists in the system

func MachineLSEPrototypeExists

func MachineLSEPrototypeExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

MachineLSEPrototypeExists checks if the given MachineLSEPrototype exists in the system

func NicExists

func NicExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

NicExists checks if the given Nic exists in the system

func NoEmitMode

func NoEmitMode(noemit bool) bool

NoEmitMode checks if emit mode is enabled for json output

func ParseJSONFile

func ParseJSONFile(jsonFile string, pm proto.Message) error

ParseJSONFile parses json input from the user provided file.

func PrefixFilters

func PrefixFilters(prefix string, filters []string) []string

PrefixFilters returns a group of filter strings with prefix

func PrintAllNormal

func PrintAllNormal(title []string, res [][]string, keysOnly bool)

PrintAllNormal prints a 2D slice with tabwriter

func PrintAllTSVs

func PrintAllTSVs(res [][]string)

PrintAllTSVs prints all in tsv format of the input

func PrintChromePlatforms

func PrintChromePlatforms(res []proto.Message, keysOnly bool)

PrintChromePlatforms prints the all msleps in table form.

func PrintChromePlatformsJSON

func PrintChromePlatformsJSON(res []proto.Message, emit bool)

PrintChromePlatformsJSON prints the mslep details in json format.

func PrintDracFull

func PrintDracFull(entities []*ufspb.Drac, dhcps map[string]*ufspb.DHCPConfig)

PrintDracFull prints the full related msg for drac

func PrintDracs

func PrintDracs(res []proto.Message, keysOnly bool)

PrintDracs prints the all dracs in table form.

func PrintDracsJSON

func PrintDracsJSON(res []proto.Message, emit bool)

PrintDracsJSON prints the drac details in json format.

func PrintEntities

func PrintEntities(ctx context.Context, ic ufsAPI.FleetClient, res []proto.Message, printJSON printJSONFunc, printFull printFullFunc, printNormal printNormalFunc, json, emit, full, tsv, keysOnly bool) error

PrintEntities a batch of entities based on user parameters

func PrintExistingDrac

func PrintExistingDrac(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingDrac prints the old drac in update/delete operations

func PrintExistingHost

func PrintExistingHost(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingHost prints the old host in update/delete operations

func PrintExistingKVM

func PrintExistingKVM(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingKVM prints the old kvm in update/delete operations

func PrintExistingMachine

func PrintExistingMachine(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingMachine prints the old machine in update/delete operations.

func PrintExistingMachinePrototype

func PrintExistingMachinePrototype(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingMachinePrototype prints the old machine prototype in update/delete operations

func PrintExistingNic

func PrintExistingNic(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingNic prints the old nic in update/delete operations

func PrintExistingPlatform

func PrintExistingPlatform(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingPlatform prints the old platform in update/delete operations

func PrintExistingRack

func PrintExistingRack(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingRack prints the old rack in update/delete operations

func PrintExistingRackPrototype

func PrintExistingRackPrototype(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingRackPrototype prints the old rack prototype in update/delete operations

func PrintExistingSwitch

func PrintExistingSwitch(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingSwitch prints the old switch in update/delete operations

func PrintExistingVM

func PrintExistingVM(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingVM prints the old vm in update/delete operations

func PrintExistingVlan

func PrintExistingVlan(ctx context.Context, ic ufsAPI.FleetClient, name string) error

PrintExistingVlan prints the old vlan update/delete operations

func PrintFreeVMs

func PrintFreeVMs(entities []*ufspb.MachineLSE, dhcps map[string]*ufspb.DHCPConfig)

PrintFreeVMs prints the all free slots in table form.

func PrintJSON

func PrintJSON(t interface{}) error

PrintJSON prints the interface output as json

func PrintKVMFull

func PrintKVMFull(kvms []*ufspb.KVM, dhcps map[string]*ufspb.DHCPConfig)

PrintKVMFull prints the full info for kvm

func PrintKVMs

func PrintKVMs(res []proto.Message, keysOnly bool)

PrintKVMs prints the all kvms in table form.

func PrintKVMsJSON

func PrintKVMsJSON(res []proto.Message, emit bool)

PrintKVMsJSON prints the kvm details in json format.

func PrintListJSONFormat

func PrintListJSONFormat(ctx context.Context, ic ufsAPI.FleetClient, f printAll, json bool, pageSize int32, filter string, keysOnly, emit bool) error

PrintListJSONFormat prints the list output in JSON format

func PrintListTableFormat

func PrintListTableFormat(ctx context.Context, ic ufsAPI.FleetClient, f printAll, json bool, pageSize int32, filter string, keysOnly bool, title []string, tsv bool) error

PrintListTableFormat prints list output in Table format

func PrintLogStats

func PrintLogStats(l LogStatsList, limit int, reverse bool)

PrintLogStats prints infos for a batch of audit scan runs.

func PrintLogStatsAndResult

func PrintLogStatsAndResult(l *LogStats, index int)

PrintLogStatsAndResult prints the stats and results for a specified audit scan run.

func PrintMachineLSEFull

func PrintMachineLSEFull(entities []*ufspb.MachineLSE, dhcps map[string]*ufspb.DHCPConfig)

PrintMachineLSEFull prints the full info for a host

func PrintMachineLSEPrototypes

func PrintMachineLSEPrototypes(res []proto.Message, keysOnly bool)

PrintMachineLSEPrototypes prints the all msleps in table form.

func PrintMachineLSEPrototypesJSON

func PrintMachineLSEPrototypesJSON(res []proto.Message, emit bool)

PrintMachineLSEPrototypesJSON prints the mslep details in json format.

func PrintMachineLSEs

func PrintMachineLSEs(res []proto.Message, keysOnly bool)

PrintMachineLSEs prints the all machinelses in table form.

func PrintMachineLSEsJSON

func PrintMachineLSEsJSON(res []proto.Message, emit bool)

PrintMachineLSEsJSON prints the machinelse details in json format.

func PrintMachines

func PrintMachines(res []proto.Message, keysOnly bool)

PrintMachines prints the all machines in table form.

func PrintMachinesJSON

func PrintMachinesJSON(res []proto.Message, emit bool)

PrintMachinesJSON prints the machine details in json format.

func PrintNics

func PrintNics(res []proto.Message, keysOnly bool)

PrintNics prints the all nics in table form.

func PrintNicsJSON

func PrintNicsJSON(res []proto.Message, emit bool)

PrintNicsJSON prints the nic details in json format.

func PrintProtoJSON

func PrintProtoJSON(pm proto.Message, emit bool)

PrintProtoJSON prints the output as json

func PrintRPMs

func PrintRPMs(res []proto.Message, keysOnly bool)

PrintRPMs prints the all rpms in table form.

func PrintRPMsJSON

func PrintRPMsJSON(res []proto.Message, emit bool)

PrintRPMsJSON prints the rpm details in json format.

func PrintRackLSEPrototypes

func PrintRackLSEPrototypes(res []proto.Message, keysOnly bool)

PrintRackLSEPrototypes prints the all msleps in table form.

func PrintRackLSEPrototypesJSON

func PrintRackLSEPrototypesJSON(res []proto.Message, emit bool)

PrintRackLSEPrototypesJSON prints the mslep details in json format.

func PrintRacks

func PrintRacks(res []proto.Message, keysOnly bool)

PrintRacks prints the all racks in table form.

func PrintRacksJSON

func PrintRacksJSON(res []proto.Message, emit bool)

PrintRacksJSON prints the rack details in json format.

func PrintSwitches

func PrintSwitches(res []proto.Message, keysOnly bool)

PrintSwitches prints the all switches in table form.

func PrintSwitchesJSON

func PrintSwitchesJSON(res []proto.Message, emit bool)

PrintSwitchesJSON prints the switch details in json format.

func PrintTSVDracFull

func PrintTSVDracFull(drac *ufspb.Drac, dhcp *ufspb.DHCPConfig)

PrintTSVDracFull prints the full related msg for drac in tsv mode

func PrintTSVDracs

func PrintTSVDracs(msgs []proto.Message, keysOnly bool)

PrintTSVDracs prints the tsv format of dracs

func PrintTSVHostFull

func PrintTSVHostFull(lse *ufspb.MachineLSE, dhcp *ufspb.DHCPConfig)

PrintTSVHostFull prints the full related msg for host in tsv mode

func PrintTSVKVMFull

func PrintTSVKVMFull(kvm *ufspb.KVM, dhcp *ufspb.DHCPConfig)

PrintTSVKVMFull prints the full related msg for kvm in tsv mode

func PrintTSVKVMs

func PrintTSVKVMs(res []proto.Message, keysOnly bool)

PrintTSVKVMs prints the tsv format of kvms

func PrintTSVMachineLSEPrototypes

func PrintTSVMachineLSEPrototypes(msgs []proto.Message, keysOnly bool)

PrintTSVMachineLSEPrototypes prints the tsv format of machine lse prototypes

func PrintTSVMachineLSEs

func PrintTSVMachineLSEs(msgs []proto.Message, keysOnly bool)

PrintTSVMachineLSEs prints the tsv format of machine lses

func PrintTSVMachines

func PrintTSVMachines(msgs []proto.Message, keysOnly bool)

PrintTSVMachines prints the tsv format of machines

func PrintTSVNics

func PrintTSVNics(msgs []proto.Message, keysOnly bool)

PrintTSVNics prints the tsv format of nics

func PrintTSVPlatforms

func PrintTSVPlatforms(msgs []proto.Message, keysOnly bool)

PrintTSVPlatforms prints the tsv format of chrome platforms

func PrintTSVRPMs

func PrintTSVRPMs(msgs []proto.Message, keysOnly bool)

PrintTSVRPMs prints the tsv format of rpms

func PrintTSVRackLSEPrototypes

func PrintTSVRackLSEPrototypes(msgs []proto.Message, keysOnly bool)

PrintTSVRackLSEPrototypes prints the tsv format of rack lse prototypes

func PrintTSVRacks

func PrintTSVRacks(msgs []proto.Message, keysOnly bool)

PrintTSVRacks prints the tsv format of racks

func PrintTSVSwitches

func PrintTSVSwitches(msgs []proto.Message, keysOnly bool)

PrintTSVSwitches prints the tsv format of switches

func PrintTSVVMs

func PrintTSVVMs(msgs []proto.Message, keysOnly bool)

PrintTSVVMs prints the tsv format of vms

func PrintTSVVlans

func PrintTSVVlans(msgs []proto.Message, keysOnly bool)

PrintTSVVlans prints the tsv format of vlans

func PrintTableTitle

func PrintTableTitle(title []string, tsv, keysOnly bool)

PrintTableTitle prints the table title with parameters

func PrintTitle

func PrintTitle(title []string)

PrintTitle prints the title fields in table form.

func PrintVMs

func PrintVMs(res []proto.Message, keysOnly bool)

PrintVMs prints the all vms in table form.

func PrintVMsJSON

func PrintVMsJSON(res []proto.Message, emit bool)

PrintVMsJSON prints the vm details in json format.

func PrintVlans

func PrintVlans(res []proto.Message, keysOnly bool)

PrintVlans prints the all vlans in table form.

func PrintVlansJSON

func PrintVlansJSON(res []proto.Message, emit bool)

PrintVlansJSON prints the vlan details in json format.

func RPMExists

func RPMExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RPMExists checks if the given RPM exists in the system

func RackExists

func RackExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RackExists checks if the given Rack exists in the system

func RackLSEPrototypeExists

func RackLSEPrototypeExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

RackLSEPrototypeExists checks if the given RackLSEPrototype exists in the system

func RemoveVM

func RemoveVM(existingVMs []*ufspb.VM, vmName string) []*ufspb.VM

RemoveVM removes the given vm from the slice

func SetupContext

func SetupContext(ctx context.Context) context.Context

SetupContext sets up context with client major version number

func SwitchExists

func SwitchExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

SwitchExists checks if the given Switch exists in the system

func VlanExists

func VlanExists(ctx context.Context, ic UfleetAPI.FleetClient, name string) bool

VlanExists checks if the given Vlan exists in the system

type AssetStats

type AssetStats struct {
	Asset    *fleet.ChopsAsset
	Action   string
	ErrorMsg string
}

AssetStats to store the statistics of a chops asset

type CSVWriter

type CSVWriter struct {
	*csv.Writer
}

CSVWriter refers to a customized csv writer

func NewCSVWriter

func NewCSVWriter() *CSVWriter

NewCSVWriter creates a new csv writer

type Input

type Input struct {
	Key      string
	Desc     string
	Required bool
}

Input deatils for the input variable

Key - input variable name Desc - description of the variable Required - if the variable is a required field

type LogStats

type LogStats struct {
	LogPath string
	ResPath string
	Tstamp  time.Time
	// The times that we scan an asset in the run
	ScannedAssetCount int
	// The times that we scan a location in the run
	ScannedLocationCount int
	SuccessfulAssetScan  int
	FailedAssetScan      int

	ScannedAssets    map[string]*AssetStats
	ScannedLocations map[string]bool
	MismatchedAssets map[string]*AssetStats
	// The failure when generating the stats
	FailureMsg []string
}

LogStats to store the statistics of any given run

type LogStatsList

type LogStatsList []*LogStats

LogStatsList refers to a list of log stats.

func ListLogs

func ListLogs(dir string) (LogStatsList, error)

ListLogs lists the logs and return the stats for each of the audit runs.

func (LogStatsList) Len

func (l LogStatsList) Len() int

func (LogStatsList) Less

func (l LogStatsList) Less(i, j int) bool

LogStats sort functions

func (LogStatsList) Swap

func (l LogStatsList) Swap(i, j int)

type PromptFunc

type PromptFunc func(string) bool

PromptFunc obtains consent from the user for the given request string.

This function is used to provide the user some context through the provided string and then obtain a yes/no answer from the user.

func CLIPrompt

func CLIPrompt(w io.Writer, r io.Reader, defaultResponse bool) PromptFunc

CLIPrompt returns a PromptFunc to prompt user on CLI.

If user set environment NO_PROMPT=true, it will returns a nil PromptFunc In case of erroneous input from user, the returned PromptFunc prompts the user again. defaultResponse is returned on empty response from the user. In case of other system errors, the returned promptFunc returns false.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater is used to asynchronously update to datastore and write logs while doing so. This helps to save work and restart the application in case an update fails

func NewUpdater

func NewUpdater(ctx context.Context, c fleetAPI.InventoryClient, gsc gs.Client, logDir, username string) (u *Updater, err error)

NewUpdater create a new updater

func (*Updater) AddAsset

func (u *Updater) AddAsset(assetList []*fleet.ChopsAsset)

AddAsset asynchronously adds asset

func (*Updater) Close

func (u *Updater) Close()

Close terminates the Updater object

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier