types

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Constraint_CAI   = "container-allowed-images"
	Constraint_CEP   = "container-enforce-probes"
	Constraint_CRL   = "container-resource-limits"
	Constraint_CRIP  = "container-restricted-image-pulls"
	Constraint_DBPDB = "disallowed-bad-pod-disruption-budgets"
	Constraint_PEA   = "pod-enforce-antiaffinity"
	Constraint_RT    = "restricted-taints"
	Constraint_USS   = "unique-service-selectors"
	Constraint_all   = "all"

	KustomizationPath       = "../tests/kustomize/overlays/production"
	DirectPath_ToValidChart = "../tests/testmanifests/validchart/Chart.yaml"
	ChartPath               = "../tests/testmanifests/validchart"
	InvalidChartPath        = "../tests/testmanifests/invalidchart"
	InvalidValuesChart      = "../tests/testmanifests/invalidvalues"
	InvalidDeploymentSyntax = "../tests/testmanifests/invaliddeployment-syntax"
	InvalidDeploymentValues = "../tests/testmanifests/invaliddeployment-values"
	FolderwithHelpersTmpl   = "../tests/testmanifests/different-structure"
	MultipleTemplateDirs    = "../tests/testmanifests/multiple-templates"
	MultipleValuesFile      = "../tests/testmanifests/multiple-values-files"

	Subcharts                  = "../tests/testmanifests/multiple-charts"
	SubchartDir                = "../tests/testmanifests/multiple-charts/charts/subchart2"
	DirectPath_ToSubchartYaml  = "../tests/testmanifests/multiple-charts/charts/subchart1/Chart.yaml"
	DirectPath_ToMainChartYaml = "../tests/testmanifests/multiple-charts/Chart.yaml"
	DirectPath_ToInvalidChart  = "../tests/testmanifests/invalidchart/Chart.yaml"

	TemplateFileName   = "template.yaml"
	ConstraintFileName = "constraint.yaml"
)

Variables

View Source
var Safeguard_CRIP = Safeguard{
	Name:           Constraint_CRIP,
	TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CRIP, TemplateFileName),
	ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CRIP, ConstraintFileName),
}
View Source
var Safeguards = []Safeguard{
	{
		Name:           Constraint_CAI,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CAI, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CAI, ConstraintFileName),
	},
	{
		Name:           Constraint_CEP,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CEP, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CEP, ConstraintFileName),
	},
	{
		Name:           Constraint_CRL,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CRL, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_CRL, ConstraintFileName),
	},
	{
		Name:           Constraint_DBPDB,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_DBPDB, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_DBPDB, ConstraintFileName),
	},
	{
		Name:           Constraint_PEA,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_PEA, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_PEA, ConstraintFileName),
	},
	{
		Name:           Constraint_RT,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_RT, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_RT, ConstraintFileName),
	},
	{
		Name:           Constraint_USS,
		TemplatePath:   fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_USS, TemplateFileName),
		ConstraintPath: fmt.Sprintf("lib/%s/%s/%s", SelectedVersion, Constraint_USS, ConstraintFileName),
	},
}
View Source
var SafeguardsTesting = append(Safeguards, Safeguard_CRIP)
View Source
var SelectedVersion = "v1.0.0"
View Source
var SupportedVersions = []string{SelectedVersion}
View Source
var TestError_CAI_Standard = fmt.Sprintf("%s/%s/%s", testManifestDirectory, Constraint_CAI, "CAI-error-manifest.yaml")
View Source
var TestManifest_CAI = TestManifest{
	Name:         Constraint_CAI,
	SuccessPaths: []string{TestSuccess_CAI_Standard},
	ErrorPaths:   []string{TestError_CAI_Standard},
}
View Source
var TestManifest_CEP = TestManifest{
	Name:         Constraint_CEP,
	SuccessPaths: []string{testSuccess_CEP_Standard},
	ErrorPaths:   []string{testError_CEP_Standard},
}
View Source
var TestManifest_CL = TestManifest{
	Name:         Constraint_CRL,
	SuccessPaths: []string{testSuccess_CRL_Standard},
	ErrorPaths:   []string{testError_CRL_Standard},
}
View Source
var TestManifest_CRIP = TestManifest{
	Name:         Constraint_CRIP,
	SuccessPaths: []string{testSuccess_CRIP_Standard},
	ErrorPaths:   []string{testError_CRIP_Standard},
}
View Source
var TestManifest_DBPDB = TestManifest{
	Name:         Constraint_DBPDB,
	SuccessPaths: []string{testSuccess_DBPDB_Standard},
	ErrorPaths:   []string{testError_DBPDB_Standard},
}
View Source
var TestManifest_PEA = TestManifest{
	Name:         Constraint_PEA,
	SuccessPaths: []string{testSuccess_PEA_Standard},
	ErrorPaths:   []string{testError_PEA_Standard},
}
View Source
var TestManifest_RT = TestManifest{
	Name:         Constraint_RT,
	SuccessPaths: []string{testSuccess_RT_Standard},
	ErrorPaths:   []string{testError_RT_Standard},
}
View Source
var TestManifest_USS = TestManifest{
	Name:         Constraint_USS,
	SuccessPaths: []string{testSuccess_USS_Standard},
	ErrorPaths:   []string{testError_USS_Standard},
}
View Source
var TestManifest_all = TestManifest{
	Name:         "all",
	SuccessPaths: []string{testSuccess_all_Standard_1, testSuccess_all_Standard_2},
	ErrorPaths:   []string{testError_all_Standard_1, testError_all_Standard_2},
}
View Source
var TestSuccess_CAI_Standard = fmt.Sprintf("%s/%s/%s", testManifestDirectory, Constraint_CAI, "CAI-success-manifest.yaml")

Functions

func GetScheme

func GetScheme() *runtime.Scheme

Types

type FileCrawler

type FileCrawler struct {
	Safeguards   []Safeguard
	ConstraintFS fs.FS
}

func (FileCrawler) ReadConstraint

func (fc FileCrawler) ReadConstraint(name string) (*unstructured.Unstructured, error)

func (FileCrawler) ReadConstraintTemplate

func (fc FileCrawler) ReadConstraintTemplate(name string) (*templates.ConstraintTemplate, error)

func (FileCrawler) ReadConstraintTemplates

func (fc FileCrawler) ReadConstraintTemplates() ([]*templates.ConstraintTemplate, error)

func (FileCrawler) ReadConstraints

func (fc FileCrawler) ReadConstraints() ([]*unstructured.Unstructured, error)

func (FileCrawler) ReadManifests

func (fc FileCrawler) ReadManifests(manifestBytes []byte) ([]*unstructured.Unstructured, error)

methods for retrieval of manifest, constraint templates, and constraints

type ManifestFile

type ManifestFile struct {
	Name            string
	ManifestContent []byte
}

type ManifestResult

type ManifestResult struct {
	Name             string              // the name of the manifest
	ObjectViolations map[string][]string // a map of string object names to slice of string objectViolations
	ViolationsCount  int                 // a count of how many violations are associated with this manifest
}

type Safeguard

type Safeguard struct {
	Name           string
	TemplatePath   string
	ConstraintPath string
}

type TestManifest

type TestManifest struct {
	Name         string
	SuccessPaths []string
	ErrorPaths   []string
}

Jump to

Keyboard shortcuts

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