Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ApplyCmd = &cobra.Command{ Use: "apply", Short: "Apply Aperture Policy to the cluster", Long: `Use this command to apply the Aperture Policy to the cluster.`, SilenceErrors: true, Example: `aperturectl policy apply --file=policies/rate-limiting.yaml aperturectl apply policy --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 cluster.
View Source
var (
Controller utils.ControllerConn
)
View Source
var DeleteCmd = &cobra.Command{ Use: "delete POLICY_NAME", Short: "Delete Aperture Policy from the Aperture Controller", Long: `Use this command to delete the Aperture Policy from the Aperture Controller.`, SilenceErrors: true, Args: cobra.ExactArgs(1), Example: `aperturectl 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 Controller.
View Source
var GetCmd = &cobra.Command{ Use: "get POLICY_NAME", Short: "Get Aperture Policy from the Aperture Controller", Long: `Use this command to get the Aperture Policy from the Aperture Controller.`, SilenceErrors: true, Args: cobra.ExactArgs(1), Example: `aperturectl 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 Controller.
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all Aperture Policies from the Aperture Controller", Long: `Use this command to list all the Aperture Policies from the Aperture Controller.`, SilenceErrors: true, Example: `aperturectl 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 Controller.
View Source
var PolicyCmd = &cobra.Command{ Use: "policy", Short: "Aperture Policy related commands for the Controller", Long: ` Use this command to manage the Aperture Policies to the Controller.`, SilenceErrors: true, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { var err error err = Controller.PreRunE(cmd, args) if err != nil { return fmt.Errorf("failed to run controller pre-run: %w", err) } controllerNs = utils.GetControllerNs() client, err = Controller.PolicyClient() if err != nil { return fmt.Errorf("failed to get controller client: %w", err) } return nil }, PersistentPostRun: Controller.PostRun, }
PolicyCmd is the command to apply a policy to the Controller.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.