policy_client

package module
v0.0.0-...-6af72f5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 12

README

Policy Client

Policy Client allows Cloud Foundry system components to query the policy server for policies. It is currently used by the VXLAN policy agent (in silk-release) and copilot.

Getting Help

For help or questions about this component, you can reach the maintainers on Slack at cloudfoundry.slack.com in the #networking channel.

Documentation

Index

Constants

View Source
const DefaultMaxPolicies = 100

Variables

View Source
var DefaultConfig = Config{
	PerPageSecurityGroups: 5000,
}

Functions

This section is empty.

Types

type Chunker

type Chunker interface {
	Chunk(allPolicies []PolicyV0) [][]PolicyV0
}

type Config

type Config struct {
	PerPageSecurityGroups int
}

type Destination

type Destination struct {
	ID       string `json:"id"`
	Tag      string `json:"tag,omitempty"`
	Protocol string `json:"protocol"`
	Ports    Ports  `json:"ports"`
}

type DestinationV0

type DestinationV0 struct {
	ID       string `json:"id"`
	Tag      string `json:"tag,omitempty"`
	Protocol string `json:"protocol"`
	Port     int    `json:"port"`
}

type ExternalClient

type ExternalClient struct {
	JsonClient json_client.JsonClient
	Chunker    Chunker
}

func NewExternal

func NewExternal(logger lager.Logger, httpClient json_client.HttpClient, baseURL string) *ExternalClient

func (*ExternalClient) AddPolicies

func (c *ExternalClient) AddPolicies(token string, policies []Policy) error

func (*ExternalClient) AddPoliciesV0

func (c *ExternalClient) AddPoliciesV0(token string, policies []PolicyV0) error

func (*ExternalClient) DeletePolicies

func (c *ExternalClient) DeletePolicies(token string, policies []Policy) error

func (*ExternalClient) DeletePoliciesV0

func (c *ExternalClient) DeletePoliciesV0(token string, policies []PolicyV0) error

func (*ExternalClient) GetPolicies

func (c *ExternalClient) GetPolicies(token string) ([]Policy, error)

func (*ExternalClient) GetPoliciesByID

func (c *ExternalClient) GetPoliciesByID(token string, ids ...string) ([]Policy, error)

func (*ExternalClient) GetPoliciesV0

func (c *ExternalClient) GetPoliciesV0(token string) ([]PolicyV0, error)

func (*ExternalClient) GetPoliciesV0ByID

func (c *ExternalClient) GetPoliciesV0ByID(token string, ids ...string) ([]PolicyV0, error)

type ExternalPolicyClient

type ExternalPolicyClient interface {
	GetPolicies(token string) ([]Policy, error)
	GetPoliciesByID(token string, ids ...string) ([]Policy, error)
	GetPoliciesV0(token string) ([]PolicyV0, error)
	GetPoliciesV0ByID(token string, ids ...string) ([]PolicyV0, error)
	DeletePolicies(token string, policies []Policy) error
	DeletePoliciesV0(token string, policies []PolicyV0) error
	AddPolicies(token string, policies []Policy) error
	AddPoliciesV0(token string, policies []PolicyV0) error
}

type IPRange

type IPRange struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

type InternalClient

type InternalClient struct {
	JsonClient json_client.JsonClient
	Config     Config
}

func NewInternal

func NewInternal(logger lager.Logger, httpClient json_client.HttpClient, baseURL string, conf Config) *InternalClient

func (*InternalClient) CreateOrGetTag

func (c *InternalClient) CreateOrGetTag(id, groupType string) (string, error)

func (*InternalClient) GetPolicies

func (c *InternalClient) GetPolicies() ([]*Policy, error)

func (*InternalClient) GetPoliciesByID

func (c *InternalClient) GetPoliciesByID(ids ...string) ([]Policy, error)

func (*InternalClient) GetPoliciesLastUpdated

func (c *InternalClient) GetPoliciesLastUpdated() (int, error)

func (*InternalClient) GetSecurityGroupsForSpace

func (c *InternalClient) GetSecurityGroupsForSpace(spaceGuids ...string) ([]SecurityGroup, error)

func (*InternalClient) HealthCheck

func (c *InternalClient) HealthCheck() (bool, error)

type InternalPolicyClient

type InternalPolicyClient interface {
	GetPolicies() ([]*Policy, error)
	GetSecurityGroupsForSpace(spaceGuids []string) ([]*SecurityGroup, error)
}

type Policies

type Policies struct {
	TotalPolicies int      `json:"total_policies"`
	Policies      []Policy `json:"policies"`
}

type PoliciesV0

type PoliciesV0 struct {
	TotalPolicies int        `json:"total_policies"`
	Policies      []PolicyV0 `json:"policies"`
}

type Policy

type Policy struct {
	Source      Source      `json:"source"`
	Destination Destination `json:"destination"`
}

type PolicySlice

type PolicySlice []Policy

func (PolicySlice) Len

func (s PolicySlice) Len() int

func (PolicySlice) Less

func (s PolicySlice) Less(i, j int) bool

func (PolicySlice) Swap

func (s PolicySlice) Swap(i, j int)

type PolicyV0

type PolicyV0 struct {
	Source      SourceV0      `json:"source"`
	Destination DestinationV0 `json:"destination"`
}

type Ports

type Ports struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

type SecurityGroup

type SecurityGroup struct {
	Guid              string             `json:"guid"`
	Name              string             `json:"name"`
	Rules             SecurityGroupRules `json:"rules"`
	StagingDefault    bool               `json:"staging_default"`
	RunningDefault    bool               `json:"running_default"`
	StagingSpaceGuids []string           `json:"staging_space_guids"`
	RunningSpaceGuids []string           `json:"running_space_guids"`
}

type SecurityGroupRule

type SecurityGroupRule struct {
	Protocol    string `json:"protocol"`
	Destination string `json:"destination"`
	Ports       string `json:"ports,omitempty"`
	Type        int    `json:"type"`
	Code        int    `json:"code"`
	Description string `json:"description,omitempty"`
	Log         bool   `json:"log"`
}

type SecurityGroupRules

type SecurityGroupRules []SecurityGroupRule

func (*SecurityGroupRules) UnmarshalJSON

func (sgr *SecurityGroupRules) UnmarshalJSON(data []byte) error

type SecurityGroupsResponse

type SecurityGroupsResponse struct {
	Next           int             `json:"next"`
	SecurityGroups []SecurityGroup `json:"security_groups"`
}

type SimpleChunker

type SimpleChunker struct {
	ChunkSize int
}

func (*SimpleChunker) Chunk

func (c *SimpleChunker) Chunk(allPolicies []PolicyV0) [][]PolicyV0

type Source

type Source struct {
	ID  string `json:"id"`
	Tag string `json:"tag,omitempty"`
}

type SourceV0

type SourceV0 struct {
	ID  string `json:"id"`
	Tag string `json:"tag,omitempty"`
}

type Space

type Space struct {
	Name    string `json:"name"`
	OrgGUID string `json:"organization_guid"`
}

type SpaceV0

type SpaceV0 struct {
	Name    string `json:"name"`
	OrgGUID string `json:"organization_guid"`
}

type Tag

type Tag struct {
	ID  string `json:"id"`
	Tag string `json:"tag"`
}

type TagRequest

type TagRequest struct {
	ID   string
	Type string
}

type TagV0

type TagV0 struct {
	ID  string `json:"id"`
	Tag string `json:"tag"`
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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