cliClient

package
v1.6.10-rc Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 9 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)

func (*CliClient) SendValidateYamlResult

func (c *CliClient) SendValidateYamlResult(request *ValidatedYamlResult)

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"`
}

type CreateTokenResponse

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

type CustomRule

type CustomRule struct {
	Identifier              string      `json:"identifier"`
	Name                    string      `json:"name"`
	DefaultMessageOnFailure string      `json:"defaultMessageOnFailure"`
	Schema                  interface{} `json:"schema"`
	JsonSchema              string      `json:"jsonSchema"`
}

type EvaluationPrerunDataResponse

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

type EvaluationPrerunPolicies

type EvaluationPrerunPolicies struct {
	ApiVersion  string        `json:"apiVersion"`
	CustomRules []*CustomRule `json:"customRules"`
	Policies    []*Policy     `json:"policies"`
}

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 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 Policy

type Policy struct {
	Name      string `json:"name"`
	IsDefault bool   `json:"isDefault,omitempty"`
	Rules     []Rule `json:"rules"`
}

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 Rule

type Rule struct {
	Identifier       string `json:"identifier"`
	MessageOnFailure string `json:"messageOnFailure"`
}

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 ValidatedFile

type ValidatedFile struct {
	Path    string `json:"path"`
	IsValid bool   `json:"isValid"`
}

type ValidatedYamlResult

type ValidatedYamlResult struct {
	Token    string           `json:"token"`
	ClientId string           `json:"clientId"`
	Metadata *Metadata        `json:"metadata"`
	Files    []*ValidatedFile `json:"files"`
	Status   string           `json:"status"`
}

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