cli

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SessionFolderFlag = "session-directory"

Variables

View Source
var DefaultSessionFolder string
View Source
var Output io.Writer = os.Stdout

Functions

func DefaultArgsShellComp

func DefaultArgsShellComp(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

func ValidArgsGetCatalogs

func ValidArgsGetCatalogs(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func ValidArgsGetCategory

func ValidArgsGetCategory(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

ValidArgsGetCategory returns autocomplete suggestions for selecting a category. Since a category identified by a composite key of catalog and category name, first a list of catalogs is returned, then a category to select.

func ValidArgsGetCloudServices

func ValidArgsGetCloudServices(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)

func ValidArgsGetControls

func ValidArgsGetControls(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

ValidArgsGetControls returns autocomplete suggestions for selecting a control. Since a control identified by a composite key of catalog, category and control name, first a list of catalogs and categories is returned, then a control to select.

func ValidArgsGetMetrics

func ValidArgsGetMetrics(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)

func ValidArgsGetTools

func ValidArgsGetTools(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)

Types

type Session

type Session struct {
	*grpc.ClientConn
	*oauth2.Config

	// URL is the URL of the gRPC server to connect to
	URL string `json:"url"`

	Folder string `json:"-"`
	// contains filtered or unexported fields
}

func ContinueSession

func ContinueSession() (session *Session, err error)

func NewSession

func NewSession(url string, config *oauth2.Config, token *oauth2.Token) (session *Session, err error)

func (*Session) Authorizer

func (s *Session) Authorizer() api.Authorizer

func (*Session) HandleResponse

func (*Session) HandleResponse(msg proto.Message, err error) error

HandleResponse handles the response and error message of an gRPC call

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

MarshalJSON is custom JSON marshalling implementation that gives us more control over the fields we want to serialize. The core problem is that we want to serialize our token, e.g. to store a session state for our clients, but we do not want to export the token field in our struct. Exporting the field would create problems in multi-threaded environments. Therefore, access is only allowed through the Token() function, which keeps the token synchronized using a mutex.

func (*Session) Save

func (s *Session) Save() (err error)

Save saves the session into the `.clouditor` folder in the home directory

func (*Session) SetAuthorizer

func (s *Session) SetAuthorizer(authorizer api.Authorizer)

func (*Session) UnmarshalJSON

func (s *Session) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON is custom JSON marshalling implementation that gives us more control over the fields we want to deserialize. See MarshalJSON for a detailed explanation, why this is necessary.

Jump to

Keyboard shortcuts

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