cliClient

package
v1.8.63-rc Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CliClient

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

func NewCliClient

func NewCliClient(url string, networkValidator NetworkValidator) *CliClient

func (*CliClient) AddFlags

func (c *CliClient) AddFlags(flags map[string]interface{})

func (*CliClient) CreateToken

func (c *CliClient) CreateToken() (*CreateTokenResponse, error)

func (*CliClient) GetVersionMessage

func (c *CliClient) GetVersionMessage(cliVersion string, timeout int) (*VersionMessage, error)

func (*CliClient) PublishPolicies

func (c *CliClient) PublishPolicies(policiesConfiguration files.UnknownStruct, token string) (*PublishFailedResponse, error)

func (*CliClient) ReportCliError

func (c *CliClient) ReportCliError(reportCliErrorRequest ReportCliErrorRequest, uri string) (StatusCode int, Error error)

func (*CliClient) RequestEvaluationPrerunData

func (c *CliClient) RequestEvaluationPrerunData(tokenId string, isCi bool) (*EvaluationPrerunDataResponse, error)

func (*CliClient) SendEvaluationResult

func (c *CliClient) SendEvaluationResult(request *EvaluationResultRequest) (*SendEvaluationResultsResponse, error)

type Configuration

type Configuration struct {
	Name             string            `json:"metadataName"`
	Kind             string            `json:"kind"`
	Occurrences      int               `json:"occurrences"`
	IsSkipped        bool              `json:"isSkipped"`
	SkipMessage      string            `json:"skipMessage"`
	FailureLocations []FailureLocation `json:"failureLocation"`
}

type CreateTokenResponse

type CreateTokenResponse struct {
	Token string `json:"token"`
}

type EvaluationPrerunDataResponse

type EvaluationPrerunDataResponse struct {
	PoliciesJson          *defaultPolicies.EvaluationPrerunPolicies `json:"policiesJson"`
	DefaultK8sVersion     string                                    `json:"defaultK8sVersion"`
	RegistrationURL       string                                    `json:"registrationURL"`
	PromptRegistrationURL string                                    `json:"promptRegistrationURL"`
	IsPolicyAsCodeMode    bool                                      `json:"isPolicyAsCodeMode"`
	DefaultRulesYaml      string                                    `json:"defaultRulesYaml"`
	IsAnonymous           bool                                      `json:"isAnonymous"`
}

type EvaluationRequest

type EvaluationRequest struct {
	EvaluationId int                             `json:"evaluationId"`
	Files        []*extractor.FileConfigurations `json:"files"`
}

type EvaluationResponse

type EvaluationResponse struct {
	Results []*EvaluationResult `json:"results"`
	Status  string              `json:"status"`
}

type EvaluationResult

type EvaluationResult struct {
	Passed  bool `json:"passed"`
	Results struct {
		Matches    []*Match `json:"matches"`
		Mismatches []*Match `json:"mismatches"`
	} `json:"results"`
	Rule struct {
		Identifier     string     `json:"identifier"`
		Name           string     `json:"name"`
		FailSuggestion string     `json:"failSuggestion"`
		Origin         RuleOrigin `json:"origin"`
	} `json:"rule"`
}

type EvaluationResultRequest

type EvaluationResultRequest struct {
	ClientId           string                            `json:"clientId"`
	Token              string                            `json:"token"`
	Metadata           *Metadata                         `json:"metadata"`
	K8sVersion         string                            `json:"k8sVersion"`
	PolicyName         string                            `json:"policyName"`
	FailedYamlFiles    []string                          `json:"failedYamlFiles"`
	FailedK8sFiles     []string                          `json:"failedK8sFiles"`
	AllExecutedRules   []RuleData                        `json:"allExecutedRules"`
	AllEvaluatedFiles  []FileData                        `json:"allEvaluatedFiles"`
	PolicyCheckResults map[string]map[string]*FailedRule `json:"policyCheckResults"`
}

type FailedRule

type FailedRule struct {
	Name             string          `json:"ruleName"`
	DocumentationUrl string          `json:"DocumentationUrl"`
	MessageOnFailure string          `json:"messageOnFailure"`
	Configurations   []Configuration `json:"configurations"`
}

type FailureLocation added in v1.6.14

type FailureLocation struct {
	SchemaPath        string `json:"schemaPath"`
	FailedErrorLine   int    `json:"failedErrorLine"`
	FailedErrorColumn int    `json:"failedErrorColumn"`
}

type FileData

type FileData struct {
	FilePath            string `json:"filepath"`
	ConfigurationsCount int    `json:"configurationsCount"`
}

type HTTPClient

type HTTPClient interface {
	Request(method string, resourceURI string, body interface{}, headers map[string]string) (httpClient.Response, error)
}

type Match

type Match struct {
	FileName     string `json:"fileName"`
	Path         string `json:"path"`
	Value        string `json:"value"`
	MetadataName string `json:"metadataName"`
	Kind         string `json:"kind"`
}

type Metadata

type Metadata struct {
	CliVersion                string               `json:"cliVersion"`
	Os                        string               `json:"os"`
	PlatformVersion           string               `json:"platformVersion"`
	KernelVersion             string               `json:"kernelVersion"`
	CIContext                 *ciContext.CIContext `json:"ciContext"`
	EvaluationDurationSeconds float64              `json:"evaluationDurationSeconds"`
}

type NetworkValidator

type NetworkValidator interface {
	IdentifyNetworkError(err error) error
	IsLocalMode() bool
}

type PublishFailedResponse

type PublishFailedResponse struct {
	Code    string   `json:"code"`
	Message string   `json:"message"`
	Payload []string `json:"payload"`
}

type ReportCliErrorRequest

type ReportCliErrorRequest struct {
	ClientId     string `json:"clientId"`
	Token        string `json:"token"`
	CliVersion   string `json:"cliVersion"`
	ErrorMessage string `json:"errorMessage"`
	StackTrace   string `json:"stackTrace"`
}

type RuleData

type RuleData struct {
	Identifier string `json:"ruleIdentifier"`
	Name       string `json:"ruleName"`
}

type RuleOrigin

type RuleOrigin struct {
	DefaultRuleId *int     `json:"defaultRuleId,omitempty"`
	CustomRuleId  *int     `json:"customRuleId,omitempty"`
	Type          RuleType `json:"type"`
}

type RuleType

type RuleType string
const (
	Default RuleType = "default"
	Custom           = "custom"
)

type SendEvaluationResultsResponse

type SendEvaluationResultsResponse struct {
	EvaluationId  int    `json:"evaluationId"`
	PromptMessage string `json:"promptMessage,omitempty"`
}

type TestCommandFlags

type TestCommandFlags struct {
	Output               string
	K8sVersion           string
	IgnoreMissingSchemas bool
	OnlyK8sFiles         bool
	Verbose              bool
	PolicyName           string
	SchemaLocations      []string
	PolicyConfig         string
	NoRecord             bool
}

type VersionMessage

type VersionMessage struct {
	CliVersion   string `json:"cliVersion"`
	MessageText  string `json:"messageText"`
	MessageColor string `json:"messageColor"`
}

Jump to

Keyboard shortcuts

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