util

package
v1.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 40 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760
)

Variables

This section is empty.

Functions

func AreCertsSame added in v0.27.0

func AreCertsSame(p common.Printer, server, local []byte) bool

func AreCertsTrusted added in v0.27.0

func AreCertsTrusted(host string, certs []byte) (bool, error)

func ConfigDir

func ConfigDir() (string, error)

func ControllerCreate added in v0.27.0

func ControllerCreate(api API, entityType string, body string, out io.Writer, logRequestJson, logResponseJson bool, timeout int, verbose bool) (*gabs.Container, error)

ControllerCreate will create entities of the given type in the given Edge Controller

func ControllerDelete added in v0.27.0

func ControllerDelete(api API, entityType string, id string, body string, out io.Writer, logRequestJson bool, logResponseJson bool, timeout int, verbose bool) (error, *int)

ControllerDelete will delete entities of the given type in the given Controller

func ControllerDetailEntity added in v0.27.0

func ControllerDetailEntity(api API, entityType, entityId string, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

func ControllerList added in v0.27.0

func ControllerList(api API, path string, params url.Values, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

ControllerList will list entities of the given type in the given Edge Controller

func ControllerUpdate added in v0.27.0

func ControllerUpdate(api API, entityType string, body string, out io.Writer, method string, logRequestJson, logResponseJSON bool, timeout int, verbose bool) (*gabs.Container, error)

ControllerUpdate will update entities of the given type in the given Edge Controller

func CopyFile added in v0.27.0

func CopyFile(src, dst string) (err error)

credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func EdgeControllerGetManagementApiBasePath added in v0.27.0

func EdgeControllerGetManagementApiBasePath(host string, cert string) string

EdgeControllerGetManagementApiBasePath accepts host as `http://domain:port` and attempts to determine the proper path that should be used to access the Edge Management API. Depending on the version of the Edge Controller the API may be monolith on `/edge/<version>` and `/` or split into `/edge/management/<version>` and `/edge/client/<version>`.

func EdgeControllerList added in v0.27.0

func EdgeControllerList(path string, params url.Values, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerList will list entities of the given type in the given Edge Controller

func EdgeControllerListSubEntities added in v0.27.0

func EdgeControllerListSubEntities(entityType, subType, entityId string, filter string, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerListSubEntities will list entities of the given type in the given Edge Controller

func EdgeControllerRequest added in v0.27.0

func EdgeControllerRequest(entityType string, out io.Writer, logJSON bool, timeout int, verbose bool, doRequest func(*resty.Request, string) (*resty.Response, error)) (*gabs.Container, error)

func EdgeControllerVerify added in v0.27.0

func EdgeControllerVerify(entityType, id, body string, out io.Writer, logJSON bool, timeout int, verbose bool) error

EdgeControllerVerify will verify entities of the given type in the given Edge Controller

func EnvironmentsDir added in v0.27.0

func EnvironmentsDir() (string, error)

func GetWellKnownCerts added in v0.27.0

func GetWellKnownCerts(host string) ([]byte, []*x509.Certificate, error)

func HomeDir added in v0.27.0

func HomeDir() string

func IsServerTrusted added in v0.27.0

func IsServerTrusted(host string) (bool, error)

func LogReleaseVersionCheck added in v0.27.0

func LogReleaseVersionCheck(zitiComponent string)

func NewClient added in v0.28.0

func NewClient() *resty.Client

Use a 2-second timeout with a retry count of 5

func NewEdgeManagementClient added in v0.27.0

func NewEdgeManagementClient(clientOpts ClientOpts) (*rest_management_api_client.ZitiEdgeManagement, error)

func NewEmptyParentCmd added in v0.27.0

func NewEmptyParentCmd(name string, description string) *cobra.Command

NewEmptyParentCmd creates a new cobra command with no parent

func NewFabricManagementClient added in v0.27.0

func NewFabricManagementClient(clientOpts ClientOpts) (*fabric_rest_client.ZitiFabric, error)

func NewRequest added in v0.27.0

func NewRequest(restClientIdentity RestClientIdentity, timeoutInSeconds int, verbose bool) (*resty.Request, error)

func OutputJson added in v0.28.0

func OutputJson(out io.Writer, data []byte)

func PKIRootDir added in v0.27.0

func PKIRootDir() (string, error)

func PersistRestClientConfig added in v0.27.0

func PersistRestClientConfig(config *RestClientConfig) error

func PickName added in v0.27.0

func PickName(names []string, message string) (string, error)

func PickNameWithDefault added in v0.27.0

func PickNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickValue added in v0.27.0

func PickValue(message string, defaultValue string, required bool) (string, error)

func PrettyPrintResponse added in v0.28.0

func PrettyPrintResponse(resp *resty.Response) string

func ReadCert added in v0.27.0

func ReadCert(id string) ([]byte, string, error)

func ReloadConfig added in v1.1.3

func ReloadConfig()

func WrapIfApiError added in v0.27.0

func WrapIfApiError(err error) error

func WriteCert added in v0.27.0

func WriteCert(p common.Printer, id string, cert []byte) (string, error)

Types

type API added in v0.27.0

type API string
const (
	FabricAPI API = "fabric"
	EdgeAPI   API = "edge"
)

type ApiErrorPayload added in v0.27.0

type ApiErrorPayload interface {
	Error() string
	GetPayload() *rest_model.APIErrorEnvelope
}

type ClientOpts added in v0.27.0

type ClientOpts interface {
	OutputRequestJson() bool
	OutputResponseJson() bool
	OutputWriter() io.Writer
	ErrOutputWriter() io.Writer
}

type EdgeManagementAuth added in v0.27.0

type EdgeManagementAuth struct {
	Token string
}

func (EdgeManagementAuth) AuthenticateRequest added in v0.27.0

func (e EdgeManagementAuth) AuthenticateRequest(request openApiRuntime.ClientRequest, registry strfmt.Registry) error

type RestApiError added in v0.27.0

type RestApiError struct {
	ApiErrorPayload
}

func (RestApiError) Error added in v0.27.0

func (a RestApiError) Error() string

type RestClientConfig added in v0.27.0

type RestClientConfig struct {
	EdgeIdentities map[string]*RestClientEdgeIdentity `json:"edgeIdentities"`
	Default        string                             `json:"default"`
}

func LoadRestClientConfig added in v0.27.0

func LoadRestClientConfig() (*RestClientConfig, string, error)

func (*RestClientConfig) GetIdentity added in v0.27.0

func (self *RestClientConfig) GetIdentity() string

type RestClientEdgeIdentity added in v0.27.0

type RestClientEdgeIdentity struct {
	Url       string `json:"url"`
	Username  string `json:"username"`
	Token     string `json:"token"`
	LoginTime string `json:"loginTime"`
	CaCert    string `json:"caCert,omitempty"`
	ReadOnly  bool   `json:"readOnly"`
}

func (*RestClientEdgeIdentity) GetBaseUrlForApi added in v0.27.0

func (self *RestClientEdgeIdentity) GetBaseUrlForApi(api API) (string, error)

func (*RestClientEdgeIdentity) IsReadOnly added in v0.27.0

func (self *RestClientEdgeIdentity) IsReadOnly() bool

func (*RestClientEdgeIdentity) NewClient added in v0.27.0

func (self *RestClientEdgeIdentity) NewClient(timeout time.Duration, verbose bool) (*resty.Client, error)

func (*RestClientEdgeIdentity) NewEdgeManagementClient added in v0.27.0

func (self *RestClientEdgeIdentity) NewEdgeManagementClient(clientOpts ClientOpts) (*rest_management_api_client.ZitiEdgeManagement, error)

func (*RestClientEdgeIdentity) NewFabricManagementClient added in v0.27.0

func (self *RestClientEdgeIdentity) NewFabricManagementClient(clientOpts ClientOpts) (*fabric_rest_client.ZitiFabric, error)

func (*RestClientEdgeIdentity) NewRequest added in v0.27.0

func (self *RestClientEdgeIdentity) NewRequest(client *resty.Client) *resty.Request

func (*RestClientEdgeIdentity) NewTlsClientConfig added in v0.27.0

func (self *RestClientEdgeIdentity) NewTlsClientConfig() (*tls.Config, error)

func (*RestClientEdgeIdentity) NewWsHeader added in v0.27.0

func (self *RestClientEdgeIdentity) NewWsHeader() http.Header

type RestClientIdentity added in v0.27.0

type RestClientIdentity interface {
	NewTlsClientConfig() (*tls.Config, error)
	NewClient(timeout time.Duration, verbose bool) (*resty.Client, error)
	NewRequest(client *resty.Client) *resty.Request
	IsReadOnly() bool
	GetBaseUrlForApi(api API) (string, error)
	NewEdgeManagementClient(clientOpts ClientOpts) (*rest_management_api_client.ZitiEdgeManagement, error)
	NewFabricManagementClient(clientOpts ClientOpts) (*fabric_rest_client.ZitiFabric, error)
	NewWsHeader() http.Header
}

func LoadSelectedIdentity added in v0.27.0

func LoadSelectedIdentity() (RestClientIdentity, error)

func LoadSelectedRWIdentity added in v0.27.0

func LoadSelectedRWIdentity() (RestClientIdentity, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL