Documentation
¶
Index ¶
- Variables
- func ApplyDynamicConfigUsingAPI(client PolicyClient, dynamicConfigYAML map[string]interface{}, ...) error
- func BackupFile(file string) error
- func CheckForUpdate(name string, force bool) (bool, error)
- func CompilePolicy(name string, policyBytes []byte) (*circuitfactory.Circuit, *languagev1.Policy, error)
- func DecisionsPreRun(all bool, decisionType string) (string, error)
- func DeletePolicyUsingAPI(client CloudPolicyClient, policyName string) error
- func FetchPolicyFromCR(crPath string) (string, error)
- func GenerateDotFile(circuit *circuitfactory.Circuit, dotFilePath string, depth int) error
- func GenerateMermaidFile(circuit *circuitfactory.Circuit, mermaidFile string, depth int) error
- func GetControllerDeployment(kubeRestConfig *rest.Config, namespace string) (*appsv1.Deployment, error)
- func GetControllerNs() string
- func GetDynamicConfigBytes(policyName, dynamicConfigFile string) ([]byte, error)
- func GetKubeConfig(kubeConfig string) (*rest.Config, error)
- func GetPolicies(policyDir string) ([]string, error)
- func GetPolicy(policyFile string) (*languagev1.Policy, string, error)
- func GetPolicyCR(policyBytes []byte) (*policyv1alpha1.Policy, error)
- func GetPolicyTUIModel(policyDir string, selectAll bool) ([]string, *tui.CheckBoxModel, error)
- func GetRelPath(dir string) string
- func GetSource(dir string) string
- func GetVersion(dir string) string
- func IsBlueprintDeprecated(policyDir string) (bool, string)
- func IsNoMatchError(err error) bool
- func ListAgents(client IntrospectionClient) error
- func ListPolicies(client PolicyClient) error
- func ParseAutoScaleControlPoints(client IntrospectionClient) error
- func ParseControlPoints(client IntrospectionClient) error
- func ParseDecisions(cmd *cobra.Command, client PolicyClient, all bool, decisionType string) error
- func ParseEntities(client IntrospectionClient, findBy string) error
- func ParsePreview(client IntrospectionClient, input PreviewInput) error
- func ParseStatus(client StatusClient) error
- func PullSource(dir, uri string) error
- func RestoreFile(file string)
- func UpdatePolicyUsingAPI(client CloudPolicyClient, name string, policy *languagev1.Policy, force bool) (bool, error)
- func ValidateWithJSONSchema(rootSchema string, schemas []string, documentFile string) error
- type CloudPolicyClient
- type ControllerConn
- func (c *ControllerConn) GetKubeRestConfig() *rest.Config
- func (c *ControllerConn) InitFlags(flags *flag.FlagSet)
- func (c *ControllerConn) IntrospectionClient() (IntrospectionClient, error)
- func (c *ControllerConn) IsKube() bool
- func (c *ControllerConn) PolicyClient() (PolicyClient, error)
- func (c *ControllerConn) PostRun(_ *cobra.Command, _ []string)
- func (c *ControllerConn) PreRunE(_ *cobra.Command, _ []string) error
- func (c *ControllerConn) StatusClient() (StatusClient, error)
- type IntrospectionClient
- type PolicyClient
- type PreviewInput
- type StatusClient
Constants ¶
This section is empty.
Variables ¶
var AllowDeprecated = false
Functions ¶
func ApplyDynamicConfigUsingAPI ¶ added in v2.18.0
func ApplyDynamicConfigUsingAPI(client PolicyClient, dynamicConfigYAML map[string]interface{}, policyName string) error
ApplyDynamicConfig applies the dynamic config.
func BackupFile ¶
BackupFile backs up a file. If backup exists, it will be restored first.
func CheckForUpdate ¶ added in v2.18.0
CheckForUpdate checks if the user wants to update the policy.
func CompilePolicy ¶
func CompilePolicy(name string, policyBytes []byte) (*circuitfactory.Circuit, *languagev1.Policy, error)
CompilePolicy compiles the policy and returns the circuit.
func DecisionsPreRun ¶ added in v2.18.0
DecisionsPreRun validates the decisions command.
func DeletePolicyUsingAPI ¶ added in v2.18.0
func DeletePolicyUsingAPI(client CloudPolicyClient, policyName string) error
DeletePolicyUsingAPI deletes the policy using the API.
func FetchPolicyFromCR ¶
FetchPolicyFromCR extracts the spec key from a CR and saves it to a temp file.
func GenerateDotFile ¶
func GenerateDotFile(circuit *circuitfactory.Circuit, dotFilePath string, depth int) error
GenerateDotFile generates a DOT file from the given circuit with the specified depth. The depth determines how many levels of components in the tree should be expanded in the graph. If maxDepth is set to -1, the function will expand components up to the maximum possible depth.
Parameters:
- circuit: A pointer to the circuitfactory.Circuit object to be used for generating the DOT file.
- dotFilePath: The file path where the generated DOT file should be saved.
- maxDepth: The maximum depth the graph should be expanded to. If set to -1, the function will expand components up to the maximum possible depth.
Returns:
- An error if any issues occur during the file creation or writing process, otherwise nil.
Example usage:
err := GenerateDotFile(circuit, "output.dot", 3) // This will generate a DOT file with components expanded up to a depth of 3. err := GenerateDotFile(circuit, "output.dot", -1) // This will generate a DOT file with components expanded up to the maximum possible depth.
func GenerateMermaidFile ¶
func GenerateMermaidFile(circuit *circuitfactory.Circuit, mermaidFile string, depth int) error
GenerateMermaidFile generates a Mermaid file from the given circuit with the specified depth. The depth determines how many levels of components in the tree should be expanded in the graph. If maxDepth is set to -1, the function will expand components up to the maximum possible depth.
Parameters:
- circuit: A pointer to the circuitfactory.Circuit object to be used for generating the Mermaid file.
- mermaidFile: The file path where the generated Mermaid file should be saved.
- maxDepth: The maximum depth the graph should be expanded to. If set to -1, the function will expand components up to the maximum possible depth.
Returns:
- An error if any issues occur during the file creation or writing process, otherwise nil.
Example usage:
err := GenerateMermaidFile(circuit, "output.mmd", 3) // This will generate a Mermaid file with components expanded up to a depth of 3. err := GenerateMermaidFile(circuit, "output.mmd", -1) // This will generate a Mermaid file with components expanded up to the maximum possible depth.
func GetControllerDeployment ¶
func GetControllerDeployment(kubeRestConfig *rest.Config, namespace string) (*appsv1.Deployment, error)
GetControllerDeployment returns the deployment of the Aperture Controller.
func GetControllerNs ¶ added in v2.1.1
func GetControllerNs() string
GetControllerNs returns namespace in which the Aperture Controller is running.
func GetDynamicConfigBytes ¶ added in v2.18.0
GetDynamicConfigBytes returns the bytes of the dynamic config file.
func GetKubeConfig ¶
GetKubeConfig prepares Kubernetes config to connect with the cluster using provided or default kube config file location.
func GetPolicies ¶ added in v2.16.0
GetPolicies returns path of valid files having a valid Aperture Policy .
func GetPolicy ¶ added in v2.16.0
func GetPolicy(policyFile string) (*languagev1.Policy, string, error)
func GetPolicyCR ¶ added in v2.16.0
func GetPolicyCR(policyBytes []byte) (*policyv1alpha1.Policy, error)
func GetPolicyTUIModel ¶ added in v2.16.0
GetPolicyTUIModel prepares the TUI model for selecting policies to apply from the given directory path.
func GetRelPath ¶
GetRelPath returns the relative path to the dependency.
func GetVersion ¶
GetVersion returns the version of the dependency.
func IsBlueprintDeprecated ¶
IsBlueprintDeprecated whether the policyDir is deprecated it reads metadata.yaml and checks for deprecated key the value of that key is the deprecation message.
func IsNoMatchError ¶ added in v2.18.0
func ListAgents ¶ added in v2.18.0
func ListAgents(client IntrospectionClient) error
func ListPolicies ¶ added in v2.18.0
func ListPolicies(client PolicyClient) error
ListPolicies lists the policies using the API.
func ParseAutoScaleControlPoints ¶ added in v2.18.0
func ParseAutoScaleControlPoints(client IntrospectionClient) error
ParseAutoScaleControlPoints parses the control points.
func ParseControlPoints ¶ added in v2.18.0
func ParseControlPoints(client IntrospectionClient) error
ParseControlPoints parses the control points.
func ParseDecisions ¶ added in v2.18.0
ParseDecisions parses the decisions.
func ParseEntities ¶ added in v2.18.0
func ParseEntities(client IntrospectionClient, findBy string) error
ParseEntities parses the entities from the cluster.
func ParsePreview ¶ added in v2.18.0
func ParsePreview(client IntrospectionClient, input PreviewInput) error
ParsePreview parses the preview.
func ParseStatus ¶ added in v2.18.0
func ParseStatus(client StatusClient) error
ParseStatus parses the status.
func PullSource ¶
func UpdatePolicyUsingAPI ¶ added in v2.18.0
func UpdatePolicyUsingAPI(client CloudPolicyClient, name string, policy *languagev1.Policy, force bool) (bool, error)
UpdatePolicyUsingAPI updates the policy using the API.
Types ¶
type CloudPolicyClient ¶ added in v2.18.0
type CloudPolicyClient interface { UpsertPolicy(ctx context.Context, in *v1.UpsertPolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) DeletePolicy(ctx context.Context, in *v1.DeletePolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) }
CloudPolicyClient is a subset of cloudv1.CloudControllerClient that covers APIs related to policies.
type ControllerConn ¶
type ControllerConn struct {
// contains filtered or unexported fields
}
ControllerConn manages flags for connecting to controller – either via address or kubeconfig.
func (*ControllerConn) GetKubeRestConfig ¶ added in v2.1.1
func (c *ControllerConn) GetKubeRestConfig() *rest.Config
GetKubeRestConfig returns kubeRestConfig.
func (*ControllerConn) InitFlags ¶
func (c *ControllerConn) InitFlags(flags *flag.FlagSet)
InitFlags sets up flags for kubeRestConfig.
func (*ControllerConn) IntrospectionClient ¶ added in v2.16.0
func (c *ControllerConn) IntrospectionClient() (IntrospectionClient, error)
client returns Controller IntrospectionClient, connecting to controller if not yet connected.
func (*ControllerConn) IsKube ¶ added in v2.1.1
func (c *ControllerConn) IsKube() bool
IsKube returns true if controller should be found in Kubernetes cluster.
func (*ControllerConn) PolicyClient ¶ added in v2.16.0
func (c *ControllerConn) PolicyClient() (PolicyClient, error)
client returns Controller PolicyClient, connecting to controller if not yet connected.
func (*ControllerConn) PostRun ¶
func (c *ControllerConn) PostRun(_ *cobra.Command, _ []string)
PostRun cleans up ControllerConn's resources, and should be run at PostRun stage.
func (*ControllerConn) PreRunE ¶
func (c *ControllerConn) PreRunE(_ *cobra.Command, _ []string) error
PreRunE verifies flags (optionally loading kubeconfig) and should be run at PreRunE stage.
func (*ControllerConn) StatusClient ¶ added in v2.16.0
func (c *ControllerConn) StatusClient() (StatusClient, error)
client returns Controller StatusClient, connecting to controller if not yet connected.
type IntrospectionClient ¶ added in v2.16.0
type IntrospectionClient interface { ListAgents(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*cmdv1.ListAgentsResponse, error) // Seems to be unimplemented on the controller at all?! ListServices(ctx context.Context, in *cmdv1.ListServicesRequest, opts ...grpc.CallOption) (*cmdv1.ListServicesControllerResponse, error) ListFlowControlPoints(ctx context.Context, in *cmdv1.ListFlowControlPointsRequest, opts ...grpc.CallOption) (*cmdv1.ListFlowControlPointsControllerResponse, error) ListAutoScaleControlPoints(ctx context.Context, in *cmdv1.ListAutoScaleControlPointsRequest, opts ...grpc.CallOption) (*cmdv1.ListAutoScaleControlPointsControllerResponse, error) ListDiscoveryEntities(ctx context.Context, in *cmdv1.ListDiscoveryEntitiesRequest, opts ...grpc.CallOption) (*cmdv1.ListDiscoveryEntitiesControllerResponse, error) ListDiscoveryEntity(ctx context.Context, in *cmdv1.ListDiscoveryEntityRequest, opts ...grpc.CallOption) (*cmdv1.ListDiscoveryEntityAgentResponse, error) PreviewFlowLabels(ctx context.Context, in *cmdv1.PreviewFlowLabelsRequest, opts ...grpc.CallOption) (*cmdv1.PreviewFlowLabelsControllerResponse, error) PreviewHTTPRequests(ctx context.Context, in *cmdv1.PreviewHTTPRequestsRequest, opts ...grpc.CallOption) (*cmdv1.PreviewHTTPRequestsControllerResponse, error) }
IntrospectionClient is a subset of cmdv1.ControllerClient that covers APIs that need controller to grab information from agents via reverse rpc.
These are currently not supported for the cloud controller.
FIXME: Perhaps it'd be better to split the service on proto level (keep backcompat in mind).
type PolicyClient ¶ added in v2.16.0
type PolicyClient interface { ListPolicies(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*v1.GetPoliciesResponse, error) UpsertPolicy(ctx context.Context, in *v1.UpsertPolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) PostDynamicConfig(ctx context.Context, in *v1.PostDynamicConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) DeletePolicy(ctx context.Context, in *v1.DeletePolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetDecisions(ctx context.Context, in *v1.GetDecisionsRequest, opts ...grpc.CallOption) (*v1.GetDecisionsResponse, error) }
PolicyClient is a subset of cmdv1.ControllerClient that covers APIs related to policies.
FIXME: Perhaps it'd be better to split the service on proto level (keep backcompat in mind).
type PreviewInput ¶ added in v2.18.0
type StatusClient ¶ added in v2.16.0
type StatusClient interface {
GetStatus(ctx context.Context, in *v11.GroupStatusRequest, opts ...grpc.CallOption) (*v11.GroupStatus, error)
}
StatusClient is a subset of cmdv1.ControllerClient that covers APIs related to status.
FIXME: Perhaps it'd be better to split the service on proto level (keep backcompat in mind).