Documentation ¶
Index ¶
- Constants
- func CheckStandardStatus(status int, response []byte) error
- func Contains(s []string, x string) bool
- func ConvertFlagParamsJsonFromFileOrStdin(c *cli.Context, dataIn string) (map[string]interface{}, error)
- func ConvertFlagParamsJsonStringFromFileOrStdin(c *cli.Context, dataIn string) (string, error)
- func ExecCode(code string, path string, filename string) (output string, exitCode int, startedAt time.Time, finishedAt time.Time)
- func FileExists(name string) bool
- func FlagConvertParams(c *cli.Context) *map[string]interface{}
- func FlagConvertParamsJSON(c *cli.Context, jsonFlags []string) (*map[string]interface{}, error)
- func GetDefaultCaCertFilePath() string
- func GetDefaultCertFilePath() string
- func GetDefaultKeyFilePath() string
- func GetDefaultLogFilePath() string
- func GetProcessIdFromFile(pidFileName string) (int, error)
- func ItemConvertParams(item interface{}) (*map[string]interface{}, error)
- func RandomString(strlen int) string
- func RemoveDuplicates(elements []string) []string
- func Retry(attempts int, sleep time.Duration, fn func() error) error
- func RunCmd(command string) (output string, exitCode int, startedAt time.Time, finishedAt time.Time)
- func RunContinuousCmd(report func(chunk string) error, command string, thresholdTime int, ...) (int, error)
- func RunFile(command string) (output string, exitCode int, startedAt time.Time, finishedAt time.Time)
- func RunTracedCmd(command string) (exitCode int, stdOut string, stdErr string, startedAt time.Time, ...)
- func SetProcessIdToFile(pidFileName string) error
- func StopProcess(pidFileName string) error
- func StopProcessId(pid int) error
- func Untar(ctx context.Context, source, target string) error
- type BootstrapConfig
- type Cert
- type ConcertoService
- type Config
- func (config *Config) BrownfieldTokenDefined() bool
- func (config *Config) IsAgentMode() bool
- func (config *Config) IsConfigReady() bool
- func (config *Config) IsConfigReadyBrownfield() bool
- func (config *Config) IsConfigReadyCommandPolling() bool
- func (config *Config) IsConfigReadySetup() bool
- func (config *Config) PollingTokenAndServerIdDefined() bool
- type HTTPConcertoservice
- func (hcs *HTTPConcertoservice) Delete(path string) ([]byte, int, error)
- func (hcs *HTTPConcertoservice) Get(path string) ([]byte, int, error)
- func (hcs *HTTPConcertoservice) GetFile(url string, filePath string, discoveryFileName bool) (string, int, error)
- func (hcs *HTTPConcertoservice) Post(path string, payload *map[string]interface{}) ([]byte, int, error)
- func (hcs *HTTPConcertoservice) Put(path string, payload *map[string]interface{}) ([]byte, int, error)
- func (hcs *HTTPConcertoservice) PutFile(sourceFilePath string, targetURL string) ([]byte, int, error)
- type MockConcertoService
- func (m *MockConcertoService) Delete(path string) ([]byte, int, error)
- func (m *MockConcertoService) Get(path string) ([]byte, int, error)
- func (m *MockConcertoService) GetFile(url string, filePath string, discoveryFileName bool) (string, int, error)
- func (m *MockConcertoService) Post(path string, payload *map[string]interface{}) ([]byte, int, error)
- func (m *MockConcertoService) Put(path string, payload *map[string]interface{}) ([]byte, int, error)
- func (m *MockConcertoService) PutFile(sourceFilePath string, targetURL string) ([]byte, int, error)
Constants ¶
const ( TimeStampLayout = "2006-01-02T15:04:05.000000-07:00" TimeLayoutYYYYMMDDHHMMSS = "20060102150405" RetriesFactor = 3 )
const ConfigurationIsIncomplete = "configuration is incomplete"
const ContentTypeApplicationJson = "application/json"
const HttpTimeOut = 30
const VERSION = "0.15.0"
VERSION sets the current CLI version
const VERSION_API_USER_MODE = "v3"
VERSION_API_USER_MODE sets the current IMCO API version for user mode
const WebServiceConfigurationFailed = "web service configuration failed. No data in configuration"
Variables ¶
This section is empty.
Functions ¶
func CheckStandardStatus ¶
CheckStandardStatus return error if status is not OK
func ConvertFlagParamsJsonFromFileOrStdin ¶ added in v0.12.0
func ConvertFlagParamsJsonFromFileOrStdin(c *cli.Context, dataIn string) (map[string]interface{}, error)
ConvertFlagParamsJsonFromFileOrStdin returns the json representation of parameters taken from the input file or STDIN
func ConvertFlagParamsJsonStringFromFileOrStdin ¶ added in v0.12.0
ConvertFlagParamsJsonStringFromFileOrStdin returns the json string representation of parameters taken from the input file or STDIN
func FlagConvertParams ¶
FlagConvertParams converts cli parameters in API callable params
func FlagConvertParamsJSON ¶
FlagConvertParamsJSON converts cli parameters in API callable params, and encodes JSON parameters
func GetDefaultCaCertFilePath ¶
func GetDefaultCaCertFilePath() string
GetDefaultCaCertFilePath returns default concerto configuration path file
func GetDefaultCertFilePath ¶
func GetDefaultCertFilePath() string
GetDefaultCertFilePath returns default concerto configuration path file
func GetDefaultKeyFilePath ¶
func GetDefaultKeyFilePath() string
GetDefaultKeyFilePath returns default concerto configuration path file
func GetDefaultLogFilePath ¶
func GetDefaultLogFilePath() string
GetDefaultLogFilePath returns default concerto configuration path file
func GetProcessIdFromFile ¶
GetProcessIdFromFile reads the process id previously stored in the file
func ItemConvertParams ¶
ItemConvertParams converts API items into map of interface
func RandomString ¶
RandomString generates a random string from lowercase letters and numbers
func RemoveDuplicates ¶ added in v0.8.0
RemoveDuplicates returns the slice removing duplicates if exist
func RunContinuousCmd ¶
func RunContinuousCmd( report func(chunk string) error, command string, thresholdTime int, thresholdLines int) (int, error)
thresholdTime > 0 continuous report thresholdLines > 0 bootstrapping
func RunTracedCmd ¶
func RunTracedCmd( command string, ) (exitCode int, stdOut string, stdErr string, startedAt time.Time, finishedAt time.Time)
RunTracedCmd executes the received command and manages two output pipes (output and error) It shouldn't throw any exception/error or stop the process.
func SetProcessIdToFile ¶
SetProcessIdToFile obtains the process id and save it inside a file
func StopProcess ¶
StopProcess reads the process id from given file and stops the process
func StopProcessId ¶
StopProcessId stops the process by the given id
Types ¶
type BootstrapConfig ¶ added in v0.9.0
type BootstrapConfig struct { IntervalSeconds int `xml:"interval,attr"` SplaySeconds int `xml:"splay,attr"` ApplyAfterIterations int `xml:"apply_after_iterations,attr"` RunOnce bool `xml:"run_once,attr"` }
BootstrapConfig stores configuration specific to the bootstrap command
type Cert ¶
type Cert struct { Cert string `xml:"cert,attr"` Key string `xml:"key,attr"` Ca string `xml:"server_ca,attr"` }
Cert stores cert files location
type ConcertoService ¶
type ConcertoService interface { Post(path string, payload *map[string]interface{}) ([]byte, int, error) Put(path string, payload *map[string]interface{}) ([]byte, int, error) Delete(path string) ([]byte, int, error) Get(path string) ([]byte, int, error) GetFile(url string, filePath string, discoveryFileName bool) (string, int, error) PutFile(sourceFilePath string, targetURL string) ([]byte, int, error) }
ConcertoService defines actions to be performed by web service manager
type Config ¶
type Config struct { XMLName xml.Name `xml:"concerto"` APIEndpoint string `xml:"server,attr"` LogFile string `xml:"log_file,attr"` LogLevel string `xml:"log_level,attr"` Certificate Cert `xml:"ssl"` BootstrapConfig BootstrapConfig `xml:"bootstrap"` ConfLocation string ConfFile string IsHost bool ConcertoURL string BrownfieldToken string CommandPollingToken string ServerID string CurrentUserName string CurrentUserIsAdmin bool // contains filtered or unexported fields }
Config stores configuration file contents
func GetConcertoConfig ¶
GetConcertoConfig returns concerto configuration
func InitializeConcertoConfig ¶
InitializeConcertoConfig creates the concerto configuration structure
func ReloadConcertoConfig ¶ added in v0.10.0
ReloadConcertoConfig checks if the config file was modified and if so, attempts to reload it. It returns the resulting config (updated or not), whether an modification of the file happened, and any errors
func (*Config) BrownfieldTokenDefined ¶ added in v0.13.0
BrownfieldTokenDefined returns whether brownfield token is defined
func (*Config) IsAgentMode ¶ added in v0.7.0
IsAgentMode returns whether CLI is acting as Server Or Client mode
func (*Config) IsConfigReady ¶
IsConfigReady returns whether configurations items are filled
func (*Config) IsConfigReadyBrownfield ¶
IsConfigReadyBrownfield returns whether config is ready for brownfield token authentication
func (*Config) IsConfigReadyCommandPolling ¶
IsConfigReadyCommandPolling returns whether config is ready for polling token authentication
func (*Config) IsConfigReadySetup ¶
IsConfigReadySetup returns whether we can use setup command
func (*Config) PollingTokenAndServerIdDefined ¶ added in v0.13.0
PollingTokenAndServerIdDefined returns whether polling token and server are defined
type HTTPConcertoservice ¶
type HTTPConcertoservice struct {
// contains filtered or unexported fields
}
HTTPConcertoservice web service manager.
func NewHTTPConcertoService ¶
func NewHTTPConcertoService(config *Config) (hcs *HTTPConcertoservice, err error)
NewHTTPConcertoService creates new http Concerto client based on config
func NewHTTPConcertoServiceWithBrownfieldToken ¶
func NewHTTPConcertoServiceWithBrownfieldToken(config *Config) (hcs *HTTPConcertoservice, err error)
NewHTTPConcertoServiceWithBrownfieldToken creates new http Concerto client based on config
func NewHTTPConcertoServiceWithCommandPolling ¶
func NewHTTPConcertoServiceWithCommandPolling(config *Config) (hcs *HTTPConcertoservice, err error)
NewHTTPConcertoServiceWithCommandPolling creates new http Concerto client based on config
func (*HTTPConcertoservice) Delete ¶
func (hcs *HTTPConcertoservice) Delete(path string) ([]byte, int, error)
Delete sends DELETE request to Concerto API
func (*HTTPConcertoservice) Get ¶
func (hcs *HTTPConcertoservice) Get(path string) ([]byte, int, error)
Get sends GET request to Concerto API
func (*HTTPConcertoservice) GetFile ¶
func (hcs *HTTPConcertoservice) GetFile(url string, filePath string, discoveryFileName bool) (string, int, error)
GetFile sends GET request to Concerto API and receives a file
func (*HTTPConcertoservice) Post ¶
func (hcs *HTTPConcertoservice) Post(path string, payload *map[string]interface{}) ([]byte, int, error)
Post sends POST request to Concerto API
type MockConcertoService ¶
MockConcertoService service manager.
func (*MockConcertoService) Delete ¶
func (m *MockConcertoService) Delete(path string) ([]byte, int, error)
Delete mocks DELETE request to Concerto API
func (*MockConcertoService) Get ¶
func (m *MockConcertoService) Get(path string) ([]byte, int, error)
Get mocks GET request to Concerto API
func (*MockConcertoService) GetFile ¶
func (m *MockConcertoService) GetFile(url string, filePath string, discoveryFileName bool) (string, int, error)
GetFile sends GET request to Concerto API and receives a file
func (*MockConcertoService) Post ¶
func (m *MockConcertoService) Post(path string, payload *map[string]interface{}) ([]byte, int, error)
Post mocks POST request to Concerto API