-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from daemon1024/policy-handling-grpc
- v1.3.0
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.14.3
- v0.14.2
- v0.14.1
- v0.14
- v0.13.16
- v0.13.15
- v0.13.14
- v0.13.13
- v0.13.12
- v0.13.11
- v0.13.10
- v0.13.9
- v0.13.8
- v0.13.7
- v0.13.6
- v0.13.5
- v0.13.4
- v0.13.3
- v0.13.2
- v0.13.1
- v0.13.0
- v0.12.4
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.7
- v0.11.6
- v0.11.5
- v0.11.4
- v0.11.3
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.7
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.10
- v0.9.9
- v0.9.8
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.6
- v0.8.4
- v0.8.3
- v0.8.0
- v0.7.12
- v0.7.11
- v0.7.10
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7
- v0.6.4
- v0.6.3-rc1
- v0.6.2
- v0.6.1
- v0.6
- v0.5
- v0.5-rc1
- v0.4
Showing
6 changed files
with
624 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2021 Authors of KubeArmor | ||
|
||
package cmd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/kubearmor/kubearmor-client/vm" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var policyOptions vm.PolicyOptions | ||
|
||
// vmPolicyCmd represents the vm command for policy enforcement | ||
var vmPolicyCmd = &cobra.Command{ | ||
Use: "policy", | ||
Short: "policy handling for vm nonk8s control plane", | ||
Long: `policy handling for vm nonk8s control plane`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("must specify add/delete policy") | ||
}, | ||
} | ||
|
||
// vmPolicyAddCmd represents the vm add policy command for policy enforcement | ||
var vmPolicyAddCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "add policy for vm k8s/nonk8s control plane", | ||
Long: `add policy for vm k8s/nonk8s control plane`, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 1 { | ||
return errors.New("requires a path to valid policy YAML as argument") | ||
} | ||
return nil | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := vm.PolicyHandling("ADDED", args[0], policyOptions); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
// vmPolicyDeleteCmd represents the vm delete policy command for policy enforcement | ||
var vmPolicyDeleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "delete policy for vm k8s/nonk8s control plane", | ||
Long: `delete policy for vm k8s/nonk8s control plane`, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 1 { | ||
return errors.New("requires a path to valid policy YAML as argument") | ||
} | ||
return nil | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if err := vm.PolicyHandling("DELETED", args[0], policyOptions); err != nil { | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
// ========== // | ||
// == Init == // | ||
// ========== // | ||
|
||
func init() { | ||
vmCmd.AddCommand(vmPolicyCmd) | ||
|
||
// Subcommand for policy command | ||
vmPolicyCmd.AddCommand(vmPolicyAddCmd) | ||
vmPolicyCmd.AddCommand(vmPolicyDeleteCmd) | ||
|
||
// gRPC endpoint flag to communicate with KubeArmor. Available across subcommands. | ||
vmPolicyCmd.PersistentFlags().StringVar(&policyOptions.GRPC, "gRPC", "", "gRPC server information") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.