Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ApplyCmd = &cobra.Command{ Use: "apply", Short: "Apply Aperture Policy to the Aperture Cloud Controller", Long: `Use this command to apply the Aperture Policy to the Aperture Cloud Controller.`, SilenceErrors: true, Example: `aperturectl cloud policy apply --file=policies/rate-limiting.yaml aperturectl cloud policy apply --dir=policies`, RunE: func(_ *cobra.Command, _ []string) error { if file != "" { return applyPolicy(file) } else if dir != "" { policies, model, err := utils.GetPoliciesTUIModel(dir, selectAll) if err != nil { return err } for policyIndex := range model.Selected { fileName := policies[policyIndex] if err := applyPolicy(fileName); err != nil { log.Error().Err(err).Msgf("failed to apply policy '%s'.", fileName) } } return nil } else { return errors.New("either --file or --dir must be provided") } }, }
ApplyCmd is the command to apply a policy to the Aperture Cloud Controller.
View Source
var ArchiveCmd = &cobra.Command{ Use: "archive POLICY_NAME", Short: "Archive Aperture Policy from the Aperture Cloud Controller", Long: `Use this command to archive the Aperture Policy from the Aperture Cloud Controller.`, SilenceErrors: true, Args: cobra.ExactArgs(1), Example: `aperturectl cloud policy archive POLICY_NAME`, RunE: func(_ *cobra.Command, args []string) error { _, err := cloudClient.ArchivePolicy(context.Background(), &policylangv1.DeletePolicyRequest{ Name: args[0], }) if err != nil { return fmt.Errorf("failed to archive policy: %w", err) } log.Info().Str("policy", args[0]).Msg("Archived Policy successfully") return nil }, }
ArchiveCmd is the command to archive a policy from the Aperture Cloud Controller.
View Source
var (
Controller cloudutils.ControllerConn
)
View Source
var DeleteCmd = &cobra.Command{ Use: "delete POLICY_NAME", Short: "Delete Aperture Policy from the Aperture Cloud Controller", Long: `Use this command to delete the Aperture Policy from the Aperture Cloud Controller.`, SilenceErrors: true, Args: cobra.ExactArgs(1), Example: `aperturectl cloud policy delete POLICY_NAME`, RunE: func(_ *cobra.Command, args []string) error { return deletePolicy(args[0]) }, }
DeleteCmd is the command to delete a policy from the Aperture Cloud Controller.
View Source
var GetCmd = &cobra.Command{ Use: "get POLICY_NAME", Short: "Get Aperture Policy from the Aperture Cloud Controller", Long: `Use this command to get the Aperture Policy from the Aperture Cloud Controller.`, SilenceErrors: true, Args: cobra.ExactArgs(1), Example: `aperturectl cloud policy get POLICY_NAME`, RunE: func(_ *cobra.Command, args []string) error { policy, err := client.GetPolicy(context.Background(), &policylangv1.GetPolicyRequest{ Name: args[0], }) if err != nil { return fmt.Errorf("failed to get policy: %w", err) } jsonBytes, err := policy.Policy.MarshalJSON() if err != nil { return err } yamlString, err := utils.GetYAMLString(jsonBytes) if err != nil { return err } fmt.Println(yamlString) return nil }, }
GetCmd is the command to get a policy from the Aperture Cloud Controller.
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all Aperture Policies from the Aperture Cloud Controller", Long: `Use this command to list all the Aperture Policies from the Aperture Cloud Controller.`, SilenceErrors: true, Example: `aperturectl cloud policy list`, RunE: func(_ *cobra.Command, args []string) error { policies, err := client.ListPolicies(context.Background(), new(emptypb.Empty)) if err != nil { return fmt.Errorf("failed to list policies: %w", err) } for policyName := range policies.GetPolicies().GetPolicies() { fmt.Println(policyName) } return nil }, }
ListCmd is the command to list policies from the Aperture Cloud Controller.
View Source
var PolicyCmd = &cobra.Command{ Use: "policy", Short: "Aperture Policy related commands for the Cloud Controller", Long: ` Use this command to manage the Aperture Policies to the Cloud Controller.`, SilenceErrors: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { err := Controller.PreRunE(cmd, args) if err != nil { return fmt.Errorf("failed to run controller pre-run: %w", err) } client, err = Controller.PolicyClient() if err != nil { return fmt.Errorf("failed to get cloud controller client: %w", err) } cloudClient, err = Controller.CloudPolicyClient() if err != nil { return fmt.Errorf("failed to get cloud controller client: %w", err) } return nil }, PersistentPostRun: Controller.PostRun, }
PolicyCmd is the command to apply a policy to the Cloud Controller.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.