Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyDynamicConfigUsingAPI(client SelfHostedPolicyClient, 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 PolicyClient, policyName string) error
- func FetchPolicyFromCR(crPath string) (string, error)
- func GenerateDotFile(circuit *circuitfactory.Circuit, dotFilePath string, depth int) error
- func GenerateGraphFile(circuit *circuitfactory.Circuit, graphFilePath string, depth int) error
- func GenerateMermaidFile(circuit *circuitfactory.Circuit, mermaidFile string, depth int) error
- func GenerateTreeGraph(circuit *circuitfactory.Circuit, treeFilePath string) error
- func GetBlueprints(blueprintsDir string) ([]string, error)
- func GetBlueprintsTUIModel(blueprintsDir string, selectAll bool) ([]string, *tui.CheckBoxModel, error)
- func GetControllerDeployment(kubeRestConfig *rest.Config, namespace string) (*appsv1.Deployment, error)
- func GetControllerNs() string
- func GetDynamicConfigBytes(policyName, dynamicConfigFile string) ([]byte, error)
- func GetDynamicConfigUsingAPI(client SelfHostedPolicyClient, policyName string) error
- func GetKubeConfig(kubeConfig string) (*rest.Config, error)
- func GetPolicies(policyDir string) ([]string, error)
- func GetPoliciesTUIModel(policyDir string, selectAll bool) ([]string, *tui.CheckBoxModel, error)
- func GetPolicy(policyFile string) ([]byte, string, error)
- func GetPolicyCR(policyBytes []byte) (*policyv1alpha1.Policy, error)
- func GetRelPath(dir string) string
- func GetSource(dir string) string
- func GetVersion(dir string) string
- func GetYAMLString(bytes []byte) (string, error)
- func IsBlueprintDeprecated(policyDir string) (bool, string)
- func IsCurrentVersionNewer(version string) (bool, error)
- func IsNoMatchError(err error) bool
- func ListAgents(client IntrospectionClient, agentGroup string) error
- func ListPolicies(client SelfHostedPolicyClient) error
- func ParseAutoScaleControlPoints(client IntrospectionClient) error
- func ParseControlPoints(client IntrospectionClient) error
- func ParseDecisions(cmd *cobra.Command, client SelfHostedPolicyClient, all bool, ...) error
- func ParseEntities(client IntrospectionClient, findBy, agentGroup string) error
- func ParseGlobalCacheDelete(client IntrospectionClient, input CacheDeleteInput) error
- func ParseGlobalCacheLookup(client IntrospectionClient, input CacheLookupInput) error
- func ParseGlobalCacheUpsert(client IntrospectionClient, input CacheUpsertInput) error
- func ParsePreview(client IntrospectionClient, input PreviewInput) error
- func ParseResultCacheDelete(client IntrospectionClient, input CacheDeleteInput) error
- func ParseResultCacheLookup(client IntrospectionClient, input CacheLookupInput) error
- func ParseResultCacheUpsert(client IntrospectionClient, input CacheUpsertInput) error
- func ParseStatus(client StatusClient) error
- func ProcessPolicy(policyPath string) (*circuitfactory.Circuit, string, string, []byte, error)
- func Pull(uri, version, cacheDirName, defaultRepo string, skipPull, localAllowed bool) (string, string, string, error)
- func PullSource(dir, uri string) error
- func RestoreFile(file string)
- func URIToRawContentURL(uri string) string
- func UpdatePolicyUsingAPI(client PolicyClient, listClient SelfHostedPolicyClient, name string, ...) error
- func UpdateVersionFile(version string) error
- func ValidateWithJSONSchema(rootSchema string, schemas []string, documentFile string) error
- type CacheDeleteInput
- type CacheLookupInput
- type CacheUpsertInput
- type CloudBlueprintsClient
- 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() (SelfHostedPolicyClient, 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 SelfHostedPolicyClient
- type StatusClient
Constants ¶
const ( // DefaultBlueprintsRepo is the default repository for blueprints. DefaultBlueprintsRepo = "github.com/fluxninja/aperture/blueprints" // DefaultDashboardsRepo is the default repository for dashboards. DefaultDashboardsRepo = "github.com/fluxninja/aperture/dashboards" // LatestTag is the tag for the latest version of blueprints. LatestTag = "latest" )
Variables ¶
var ( // AllowDeprecated is a flag to allow deprecated blueprints to be listed. AllowDeprecated = false // AperturectlRootDir is the root directory for aperturectl. AperturectlRootDir = ".aperturectl" // BlueprintsCacheRoot is the root directory for blueprints cache. BlueprintsCacheRoot = filepath.Join(AperturectlRootDir, "blueprints") // BuilderCacheRoot is the root directory for builder cache. BuilderCacheRoot = filepath.Join(AperturectlRootDir, "build") )
Functions ¶
func ApplyDynamicConfigUsingAPI ¶ added in v2.18.0
func ApplyDynamicConfigUsingAPI(client SelfHostedPolicyClient, 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 PolicyClient, 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 GenerateGraphFile ¶ added in v2.22.0
func GenerateGraphFile(circuit *circuitfactory.Circuit, graphFilePath string, depth int) error
GenerateGraphFile generates a graph 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 graph.
- graphFilePath: The file path where the generated graph 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 := GenerateGraphFile(circuit, "output.json", 3) // This will generate a graph with components expanded up to a depth of 3. err := GenerateGraphFile(circuit, "output.json", -1) // This will generate a graph 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 GenerateTreeGraph ¶ added in v2.22.0
func GenerateTreeGraph(circuit *circuitfactory.Circuit, treeFilePath string) error
GenerateTreeGraph generates a tree graph from the given circuit.
func GetBlueprints ¶ added in v2.18.1
GetBlueprints returns a list of files that look like blueprints.
func GetBlueprintsTUIModel ¶ added in v2.18.1
func GetBlueprintsTUIModel(blueprintsDir string, selectAll bool) ([]string, *tui.CheckBoxModel, error)
GetBlueprintsTUIModel prepares the TUI model for the blueprints command.
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 GetDynamicConfigUsingAPI ¶ added in v2.20.1
func GetDynamicConfigUsingAPI(client SelfHostedPolicyClient, policyName string) error
GetDynamicConfigUsingAPI gets the dynamic config.
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 GetPoliciesTUIModel ¶ added in v2.18.1
GetPoliciesTUIModel prepares the TUI model for selecting policies to apply from the given directory path.
func GetPolicyCR ¶ added in v2.16.0
func GetPolicyCR(policyBytes []byte) (*policyv1alpha1.Policy, error)
GetPolicyCR returns the policy CR from the policy bytes.
func GetRelPath ¶
GetRelPath returns the relative path to the dependency.
func GetVersion ¶
GetVersion returns the version of the dependency.
func GetYAMLString ¶ added in v2.20.0
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 IsCurrentVersionNewer ¶ added in v2.19.0
IsCurrentVersionNewer checks if the version of aperturectl is newer than on disk.
func IsNoMatchError ¶ added in v2.18.0
func ListAgents ¶ added in v2.18.0
func ListAgents(client IntrospectionClient, agentGroup string) error
func ListPolicies ¶ added in v2.18.0
func ListPolicies(client SelfHostedPolicyClient) 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
func ParseDecisions(cmd *cobra.Command, client SelfHostedPolicyClient, all bool, decisionType string) error
ParseDecisions parses the decisions.
func ParseEntities ¶ added in v2.18.0
func ParseEntities(client IntrospectionClient, findBy, agentGroup string) error
ParseEntities parses the entities from the cluster.
func ParseGlobalCacheDelete ¶ added in v2.25.1
func ParseGlobalCacheDelete(client IntrospectionClient, input CacheDeleteInput) error
func ParseGlobalCacheLookup ¶ added in v2.25.1
func ParseGlobalCacheLookup(client IntrospectionClient, input CacheLookupInput) error
func ParseGlobalCacheUpsert ¶ added in v2.25.1
func ParseGlobalCacheUpsert(client IntrospectionClient, input CacheUpsertInput) error
func ParsePreview ¶ added in v2.18.0
func ParsePreview(client IntrospectionClient, input PreviewInput) error
ParsePreview parses the preview.
func ParseResultCacheDelete ¶ added in v2.25.0
func ParseResultCacheDelete(client IntrospectionClient, input CacheDeleteInput) error
func ParseResultCacheLookup ¶ added in v2.25.0
func ParseResultCacheLookup(client IntrospectionClient, input CacheLookupInput) error
func ParseResultCacheUpsert ¶ added in v2.25.0
func ParseResultCacheUpsert(client IntrospectionClient, input CacheUpsertInput) error
func ParseStatus ¶ added in v2.18.0
func ParseStatus(client StatusClient) error
ParseStatus parses the status.
func ProcessPolicy ¶ added in v2.23.1
ProcessPolicy processes the policy and returns the circuit and graph.
func Pull ¶ added in v2.23.1
func Pull(uri, version, cacheDirName, defaultRepo string, skipPull, localAllowed bool) (string, string, string, error)
Pull pulls the content from the given URI and version.
func PullSource ¶
PullSource pulls the source of the dependency and updates the lock file.
func URIToRawContentURL ¶ added in v2.18.1
URIToRawContentURL converts a URI to a raw content URL, mainly for GitHub right now.
func UpdatePolicyUsingAPI ¶ added in v2.18.0
func UpdatePolicyUsingAPI(client PolicyClient, listClient SelfHostedPolicyClient, name string, policyBytes []byte, force bool) error
UpdatePolicyUsingAPI updates the policy using the API.
func UpdateVersionFile ¶ added in v2.19.0
UpdateVersionFile updates the version file with the current version.
Types ¶
type CacheDeleteInput ¶ added in v2.25.0
type CacheLookupInput ¶ added in v2.25.0
type CacheUpsertInput ¶ added in v2.25.0
type CloudBlueprintsClient ¶ added in v2.20.0
type CloudBlueprintsClient interface { List(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*cloudv1.ListResponse, error) Get(ctx context.Context, in *cloudv1.GetRequest, opts ...grpc.CallOption) (*cloudv1.GetResponse, error) Apply(ctx context.Context, in *cloudv1.ApplyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) Delete(ctx context.Context, in *cloudv1.DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) Archive(ctx context.Context, in *cloudv1.DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) }
CloudBlueprintsClient is a subset of cloudv1.CloudControllerClient that covers APIs related to cloud blueprints.
type CloudPolicyClient ¶ added in v2.18.0
type CloudPolicyClient interface { UpsertPolicy(ctx context.Context, in *policylangv1.UpsertPolicyRequest, opts ...grpc.CallOption) (*policylangv1.UpsertPolicyResponse, error) DeletePolicy(ctx context.Context, in *policylangv1.DeletePolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) ArchivePolicy(ctx context.Context, in *policylangv1.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() (SelfHostedPolicyClient, 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 *cmdv1.ListAgentsRequest, 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) // Caching CacheLookup(ctx context.Context, in *cmdv1.GlobalCacheLookupRequest, opts ...grpc.CallOption) (*flowcontrolv1.CacheLookupResponse, error) CacheUpsert(ctx context.Context, in *cmdv1.GlobalCacheUpsertRequest, opts ...grpc.CallOption) (*flowcontrolv1.CacheUpsertResponse, error) CacheDelete(ctx context.Context, in *cmdv1.GlobalCacheDeleteRequest, opts ...grpc.CallOption) (*flowcontrolv1.CacheDeleteResponse, 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 { UpsertPolicy(ctx context.Context, in *policylangv1.UpsertPolicyRequest, opts ...grpc.CallOption) (*policylangv1.UpsertPolicyResponse, error) DeletePolicy(ctx context.Context, in *policylangv1.DeletePolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) }
PolicyClient is a subset of cmdv1.ControllerClient that covers APIs related to policies.
type PreviewInput ¶ added in v2.18.0
type SelfHostedPolicyClient ¶ added in v2.20.2
type SelfHostedPolicyClient interface { ListPolicies(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*policylangv1.GetPoliciesResponse, error) UpsertPolicy(ctx context.Context, in *policylangv1.UpsertPolicyRequest, opts ...grpc.CallOption) (*policylangv1.UpsertPolicyResponse, error) PostDynamicConfig(ctx context.Context, in *policylangv1.PostDynamicConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetDynamicConfig(ctx context.Context, in *policylangv1.GetDynamicConfigRequest, opts ...grpc.CallOption) (*policylangv1.GetDynamicConfigResponse, error) DeleteDynamicConfig(ctx context.Context, in *policylangv1.DeleteDynamicConfigRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) DeletePolicy(ctx context.Context, in *policylangv1.DeletePolicyRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) GetDecisions(ctx context.Context, in *policylangv1.GetDecisionsRequest, opts ...grpc.CallOption) (*policylangv1.GetDecisionsResponse, error) GetPolicy(ctx context.Context, in *policylangv1.GetPolicyRequest, opts ...grpc.CallOption) (*policylangv1.GetPolicyResponse, error) }
SelfHostedPolicyClient 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 StatusClient ¶ added in v2.16.0
type StatusClient interface {
GetStatus(ctx context.Context, in *statusv1.GroupStatusRequest, opts ...grpc.CallOption) (*statusv1.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).