utils

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowDeprecated = false

Functions

func BackupFile added in v1.0.0

func BackupFile(file string) error

BackupFile backs up a file. If backup exists, it will be restored first.

func CompilePolicy

func CompilePolicy(path string) (*circuitfactory.Circuit, *languagev1.Policy, error)

CompilePolicy compiles the policy and returns the circuit.

func FetchPolicyFromCR

func FetchPolicyFromCR(crPath string) (string, error)

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 added in v1.5.0

func GetControllerDeployment(kubeRestConfig *rest.Config, namespace string) (*appsv1.Deployment, error)

GetControllerDeployment returns the deployment of the Aperture Controller.

func GetKubeConfig added in v0.23.0

func GetKubeConfig(kubeConfig string) (*rest.Config, error)

GetKubeConfig prepares Kubernetes config to connect with the cluster using provided or default kube config file location.

func GetRelPath added in v1.0.0

func GetRelPath(dir string) string

GetRelPath returns the relative path to the dependency.

func GetSource added in v1.0.0

func GetSource(dir string) string

GetSource returns the source of the dependency.

func GetVersion added in v1.0.0

func GetVersion(dir string) string

GetVersion returns the version of the dependency.

func IsBlueprintDeprecated added in v1.4.0

func IsBlueprintDeprecated(policyDir string) (bool, string)

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 PullSource added in v1.0.0

func PullSource(dir, uri string) error

func ReaderLock added in v1.0.0

func ReaderLock(dir string) error

ReaderLock acquires a reader lock on the directory.

func ResolveLatestVersion added in v0.23.0

func ResolveLatestVersion() (string, error)

ResolveLatestVersion returns the latest release version of Aperture.

func RestoreFile added in v1.0.0

func RestoreFile(file string)

RestoreFile restores a file from its backup.

func Unlock added in v1.0.0

func Unlock(dir string)

Unlock releases the lock on the directory.

func ValidateWithJSONSchema added in v0.24.0

func ValidateWithJSONSchema(rootSchema string, schemas []string, documentFile string) error

ValidateWithJSONSchema validates the given document (YAML) against the given JSON schema.

func WriterLock added in v1.0.0

func WriterLock(dir string) error

WriterLock acquires a writer lock on the directory.

Types

type ControllerConn added in v0.25.0

type ControllerConn struct {
	// contains filtered or unexported fields
}

ControllerConn manages flags for connecting to controller – either via address or kubeconfig.

func (*ControllerConn) Client added in v0.25.0

func (c *ControllerConn) Client() (cmdv1.ControllerClient, error)

Client returns Controller Client, connecting to controller if not yet connected.

func (*ControllerConn) InitFlags added in v0.25.0

func (c *ControllerConn) InitFlags(flags *flag.FlagSet)

InitFlags sets up flags for kubeRestConfig.

func (*ControllerConn) PostRun added in v0.25.0

func (c *ControllerConn) PostRun(_ *cobra.Command, _ []string)

PostRun cleans up ControllerConn's resources, and should be run at PostRun stage.

func (*ControllerConn) PreRunE added in v0.25.0

func (c *ControllerConn) PreRunE(_ *cobra.Command, _ []string) error

PreRunE verifies flags (optionally loading kubeconfig) and should be run at PreRunE stage.

Jump to

Keyboard shortcuts

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