policy

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceSelectorKey = "namespace_selector"
	MatchExpressionsKey  = "match_expressions"
	KeyKey               = "key"
	OperatorKey          = "operator"
	ValuesKey            = "values"
	ScopeKey             = "scope"

	SpecKey                   = "spec"
	NameKey                   = "name"
	InputKey                  = "input"
	RecipeVersionDefaultValue = "v1"
	UnknownRecipe             = ""
)

Variables

View Source
var (
	ScopeSchema = &schema.Schema{
		Type:        schema.TypeList,
		Description: "Scope for the security and custom policy, having one of the valid scopes: cluster, cluster_group or organization.",
		Required:    true,
		ForceNew:    true,
		MaxItems:    1,
		MinItems:    1,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				clusterKey:      scoperesource.ClusterPolicyFullname,
				clusterGroupKey: scoperesource.ClusterGroupPolicyFullname,
				organizationKey: scoperesource.OrganizationPolicyFullname,
			},
		},
	}
	ScopesAllowed = [...]string{clusterKey, clusterGroupKey, organizationKey}
)
View Source
var NamespaceSelector = &schema.Schema{
	Type:        schema.TypeList,
	Description: "Label based Namespace Selector for the policy",
	Optional:    true,
	MaxItems:    1,
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			MatchExpressionsKey: {
				Type:        schema.TypeList,
				Description: "Match expressions is a list of label selector requirements, the requirements are ANDed",
				Required:    true,
				Elem:        labelSelectorRequirement,
			},
		},
	},
}

Functions

func ConstructNamespaceSelector

func ConstructNamespaceSelector(data []interface{}) (namespaceSelector *policymodel.VmwareTanzuManageV1alpha1CommonPolicyLabelSelector)

func FlattenNamespaceSelector

func FlattenNamespaceSelector(namespaceSelector *policymodel.VmwareTanzuManageV1alpha1CommonPolicyLabelSelector) (data []interface{})

func FlattenScope added in v1.1.3

func FlattenScope(scopedFullname *ScopedFullname) (data []interface{}, name string)

func MetaResourceAttributeCheck

func MetaResourceAttributeCheck(resourceName string) []resource.TestCheckFunc

func ValidateScope added in v1.1.3

func ValidateScope(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error

func ValidateSpecLabelSelectorRequirement added in v1.1.3

func ValidateSpecLabelSelectorRequirement(ctx context.Context, diff *schema.ResourceDiff, i interface{}) error

Types

type Cluster added in v1.1.3

type Cluster struct {
	Resource              string
	ResourceVar           string
	ResourceName          string
	KubeConfigPath        string
	Name                  string
	ClusterGroupName      string
	ManagementClusterName string
	ProvisionerName       string
}

type ClusterGroup added in v1.1.3

type ClusterGroup struct {
	ResourceName string
	Resource     string
	ResourceVar  string
	Name         string
}

type Scope added in v1.1.3

type Scope int64
const (
	UnknownScope Scope = iota
	ClusterScope
	ClusterGroupScope
	OrganizationScope
)

Allowed scopes.

type ScopeHelperResources added in v1.1.3

type ScopeHelperResources struct {
	Meta         string
	Cluster      *Cluster
	ClusterGroup *ClusterGroup
	OrgID        string
}

func NewScopeHelperResources added in v1.1.3

func NewScopeHelperResources() *ScopeHelperResources

func (*ScopeHelperResources) GetTestPolicyResourceHelperAndScope added in v1.1.3

func (shr *ScopeHelperResources) GetTestPolicyResourceHelperAndScope(scope Scope) (string, string)

GetTestPolicyResourceHelperAndScope builds the helper resource and scope blocks for policy resource based on a scope type.

type ScopedFullname added in v1.1.3

ScopedFullname is a struct for all types of policy full names.

func ConstructScope added in v1.1.3

func ConstructScope(d *schema.ResourceData, name string) (scopedFullnameData *ScopedFullname)

Directories

Path Synopsis
kind
custom/recipe
Package recipe contains schema and helper functions for different input recipes.
Package recipe contains schema and helper functions for different input recipes.
security/recipe
Package recipe contains schema and helper functions for different input recipes.
Package recipe contains schema and helper functions for different input recipes.
Package scope contains schema and helper functions for different policy scopes.
Package scope contains schema and helper functions for different policy scopes.

Jump to

Keyboard shortcuts

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