apis

package
v1.0.85 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebsocketScanCommandVersion string = "v1"
	WebsocketScanCommandPath    string = "scanImage"
)

WebsocketScanCommand api

View Source
const (
	UPDATE            string = "update"
	ATTACH            string = "Attach"
	REMOVE            string = "remove"
	DETACH            string = "Detach"
	INCOMPATIBLE      string = "Incompatible"
	REPLACE_HEADERS   string = "ReplaceHeaders"
	IMAGE_UNREACHABLE string = "ImageUnreachable"
	SIGN              string = "sign"
	UNREGISTERED      string = "unregistered"
	INJECT            string = "inject"
	RESTART           string = "restart"
	ENCRYPT           string = "encryptSecret"
	DECRYPT           string = "decryptSecret"
	SCAN              string = "scan"
)

commands send via websocket

Variables

This section is empty.

Functions

func BEHttpRequest

func BEHttpRequest(loginobj *LoginObject, beURL,
	httpverb string,
	endpoint string,
	payload []byte,
	f HTTPReqFunc,
	qryData interface{}) ([]byte, error)

func BasicBEQuery

func BasicBEQuery(req *http.Request, qryData interface{})

func EmptyQuery

func EmptyQuery(req *http.Request, qryData interface{})

func GetBEInfo

func GetBEInfo(cfgFile string) string

func GetOauth2TokenURL

func GetOauth2TokenURL() string

func LoginWithKeycloak

func LoginWithKeycloak(loginDetails CustomerLoginDetails) ([]uuid.UUID, *oidc.IDToken, error)

func MapQuery

func MapQuery(req *http.Request, qryData interface{})

func SIDFallback

func SIDFallback(c *Command)

func ValidateBEConnectorMakerInput

func ValidateBEConnectorMakerInput(client *http.Client, baseURL string, loginDetails *CustomerLoginDetails) error

Types

type AuthenticationCookie

type AuthenticationCookie struct {
	Oauth2Claims  `json:",inline"`
	CustomerGUID  uuid.UUID `json:"customerGuid"`
	Expires       time.Time `json:"expires"`
	Version       int       `json:"version"`
	Authorization string    `json:"authorization,omitempty"`
}

AuthenticationCookie is what it is

type BELoginResponse

type BELoginResponse struct {
	Name              string `json:"name"`
	PreferredUsername string `json:"preferred_username"`
	Email             string `json:"email"`
	CustomerGuid      string `json:"customerGuid"`
	Expires           string `json:"expires"`
	Authorization     string `json:"authorization"`
	Cookies           []*http.Cookie
}

func BELogin

func BELogin(loginDetails *CustomerLoginDetails, login string, cfg string) (*BELoginResponse, error)

func (*BELoginResponse) ToLoginObject

func (r *BELoginResponse) ToLoginObject() *LoginObject

type BackendConnector

type BackendConnector struct {
	BaseURL         string
	BELoginResponse *BELoginResponse
	Credentials     *CustomerLoginDetails
	HTTPClient      *http.Client
}

func MakeBackendConnector

func MakeBackendConnector(client *http.Client, baseURL string, loginDetails *CustomerLoginDetails) (*BackendConnector, error)

func (*BackendConnector) GetBaseURL

func (r *BackendConnector) GetBaseURL() string

func (*BackendConnector) GetClient

func (r *BackendConnector) GetClient() *http.Client

func (*BackendConnector) GetLoginObj

func (r *BackendConnector) GetLoginObj() *LoginObject

func (*BackendConnector) HTTPSend

func (r *BackendConnector) HTTPSend(httpverb string,
	endpoint string,
	payload []byte,
	f HTTPReqFunc,
	qryData interface{}) ([]byte, error)

func (*BackendConnector) IsExpired

func (r *BackendConnector) IsExpired() bool

func (*BackendConnector) Login

func (r *BackendConnector) Login() error

type Command

type Command struct {
	CommandName string                 `json:"commandName"`
	ResponseID  string                 `json:"responseID"`
	Wlid        string                 `json:"wlid,omitempty"`
	WildWlid    string                 `json:"wildWlid,omitempty"`
	Sid         string                 `json:"sid,omitempty"`
	WildSid     string                 `json:"wildSid,omitempty"`
	JobTracking JobTracking            `json:"jobTracking"`
	Args        map[string]interface{} `json:"args,omitempty"`
}

Command structure of command received from websocket

func (*Command) DeepCopy

func (c *Command) DeepCopy() *Command

func (*Command) GetFieldSelector

func (c *Command) GetFieldSelector() map[string]string

func (*Command) GetID

func (c *Command) GetID() string

func (*Command) GetLabels

func (c *Command) GetLabels() map[string]string

func (*Command) Json

func (c *Command) Json() string

func (*Command) SetFieldSelector

func (c *Command) SetFieldSelector(labels map[string]string)

func (*Command) SetLabels

func (c *Command) SetLabels(labels map[string]string)

type Commands

type Commands struct {
	Commands []Command `json:"commands"`
}

Commands list of commands received from websocket

type Connector

type Connector interface {

	//may used for a more generic httpsend interface based method
	GetBaseURL() string
	GetLoginObj() *LoginObject
	GetClient() *http.Client

	Login() error
	IsExpired() bool

	HTTPSend(httpverb string,
		endpoint string,
		payload []byte,
		f HTTPReqFunc,
		qryData interface{}) ([]byte, error)
}

Connector - interface for any connector (BE/Portal and so on)

type CustomerLoginDetails

type CustomerLoginDetails struct {
	Email        string    `json:"email"`
	Password     string    `json:"password"`
	CustomerName string    `json:"customer,omitempty"`
	CustomerGUID uuid.UUID `json:"customerGuid,omitempty"`
}

CustomerLoginDetails is what it is

type ElasticRespTotal

type ElasticRespTotal struct {
	Value    int    `json:"value"`
	Relation string `json:"relation"`
}

taken from BE ElasticRespTotal holds the total struct in Elastic array response

type HTTPReqFunc

type HTTPReqFunc func(req *http.Request, qryData interface{})

HTTPReqFunc allows you to insert query params and more to aggregation message while using update aggregator

type JobTracking

type JobTracking struct {
	JobID            string `json:"jobID,omitempty"`
	ParentID         string `json:"parentAction,omitempty"`
	LastActionNumber int    `json:"numSeq,omitempty"`
}

type LoginAux

type LoginAux struct {
	Referer string
	Url     string
}

func GetLoginStruct

func GetLoginStruct() (LoginAux, error)

type LoginObject

type LoginObject struct {
	Authorization string `json:"authorization"`
	GUID          string
	Cookies       []*http.Cookie
	Expires       string
}

func Login

func Login(loginDetails CustomerLoginDetails) (*LoginObject, error)

func (*LoginObject) IsExpired

func (r *LoginObject) IsExpired() bool

type Oauth2Claims

type Oauth2Claims struct {
	Sub               string   `json:"sub"`
	Name              string   `json:"name"`
	PreferredUserName string   `json:"preferred_username"`
	CAGroups          []string `json:"ca_groups"`
	Email             string   `json:"email"`
}

Oauth2Claims returns in claims section of Oauth2 verification process

type Oauth2Customer

type Oauth2Customer struct {
	CustomerName string `json:"customerName"`
	CustomerGUID string `json:"customerGUID"`
}

Oauth2Customer returns inside the "ca_groups" field in claims section of Oauth2 verification process

type SafeMode

type SafeMode struct {
	Reporter        string `json:"reporter"`                // "Agent"
	Action          string `json:"action,omitempty"`        // "action"
	Wlid            string `json:"wlid"`                    // CAA_WLID
	PodName         string `json:"podName"`                 // CAA_POD_NAME
	InstanceID      string `json:"instanceID"`              // CAA_POD_NAME
	ContainerName   string `json:"containerName,omitempty"` // CAA_CONTAINER_NAME
	ProcessName     string `json:"processName,omitempty"`
	ProcessID       int    `json:"processID,omitempty"`
	ProcessCMD      string `json:"processCMD,omitempty"`
	ComponentGUID   string `json:"componentGUID,omitempty"` // CAA_GUID
	StatusCode      int    `json:"statusCode"`              // 0/1/2
	ProcessExitCode int    `json:"processExitCode"`         // 0 +
	Timestamp       int64  `json:"timestamp"`
	Message         string `json:"message,omitempty"` // any string
	JobID           string `json:"jobID,omitempty"`   // any string
	Compatible      *bool  `json:"compatible,omitempty"`
}

func (*SafeMode) Json

func (safeMode *SafeMode) Json() string

type V2ListResponse

type V2ListResponse struct {
	Total    ElasticRespTotal `json:"total"`
	Response interface{}      `json:"response"`
	// Cursor for quick access to the next page. Not supported yet
	Cursor string `json:"cursor"`
}

V2ListResponse holds the response of some list request with some metadata

type WebsocketScanCommand

type WebsocketScanCommand struct {
	// CustomerGUID string `json:"customerGUID"`
	ImageTag      string `json:"imageTag"`
	Wlid          string `json:"wlid"`
	IsScanned     bool   `json:"isScanned"`
	ContainerName string `json:"containerName"`
	JobID         string `json:"jobID,omitempty"`
	LastAction    int    `json:"actionIDN"`
	// ImageHash     string `json:"imageHash"`
	Credentials *types.AuthConfig `json:"credentials,omitempty"`
}

WebsocketScanCommand trigger scan thru the websocket

Jump to

Keyboard shortcuts

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