Skip to content

Commit

Permalink
Merge pull request #476 from rksharma95/deprecate-vm-package
Browse files Browse the repository at this point in the history
Deprecate vm package and upgrade dependencies
  • Loading branch information
rksharma95 authored Jan 17, 2025
2 parents a5af11a + c01547a commit 325762c
Show file tree
Hide file tree
Showing 16 changed files with 383 additions and 1,407 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Contributions are not necessarily in the form of code changes. KubeArmor communi

2. Blogs

a. Explain The use of KubeArmor-Client's features (KVMService, Event Auditor, Visibility, etc)
a. Explain The use of KubeArmor-Client's features (Event Auditor, Visibility, etc)

b. Describe How to use KubeArmor-Client to protect your workload with specific use-cases you may have. Please do not shy away from getting as technical as you can.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Available Commands:
sysdump Collect system dump information for troubleshooting and error report
uninstall Uninstall KubeArmor from a Kubernetes Cluster
version Display version information
vm VM commands for kvmservice
vm VM commands for non kubernetes/bare metal KubeArmor

Flags:
--context string Name of the kubeconfig context to use
Expand Down
22 changes: 8 additions & 14 deletions cmd/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package cmd

import (
"errors"
"net"

"github.com/kubearmor/kubearmor-client/vm"
"github.com/spf13/cobra"
Expand All @@ -17,26 +16,23 @@ var policyOptions vm.PolicyOptions
// vmPolicyCmd represents the vm command for policy enforcement
var vmPolicyCmd = &cobra.Command{
Use: "policy",
Short: "policy handling for bare-metal vm/kvms control plane vm",
Long: `policy handling for bare-metal vm/kvms control plane vm`,
Short: "policy handling for non kubernetes/bare metal KubeArmor",
Long: `policy handling for non kubernetes/bare metal KubeArmor`,
}

// vmPolicyAddCmd represents the vm add policy command for policy enforcement
var vmPolicyAddCmd = &cobra.Command{
Use: "add",
Short: "add policy for bare-metal vm/kvms control plane vm",
Long: `add policy for bare-metal vm/kvms control plane vm`,
Short: "add policy for non kubernetes/bare metal KubeArmor",
Long: `add policy for non kubernetes/bare metal KubeArmor`,
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 {
// Create http address
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)

if err := vm.PolicyHandling("ADDED", args[0], policyOptions, httpAddress, IsKvmsEnv); err != nil {
if err := vm.PolicyHandling("ADDED", args[0], policyOptions); err != nil {
return err
}
return nil
Expand All @@ -46,18 +42,16 @@ var vmPolicyAddCmd = &cobra.Command{
// vmPolicyDeleteCmd represents the vm delete policy command for policy enforcement
var vmPolicyDeleteCmd = &cobra.Command{
Use: "delete",
Short: "delete policy for bare-metal vm/kvms control plane vm",
Long: `delete policy for bare-metal vm/kvms control plane vm`,
Short: "delete policy for non kubernetes/bare metal KubeArmor",
Long: `delete policy for non kubernetes/bare metal KubeArmor`,
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 {
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)

if err := vm.PolicyHandling("DELETED", args[0], policyOptions, httpAddress, IsKvmsEnv); err != nil {
if err := vm.PolicyHandling("DELETED", args[0], policyOptions); err != nil {
return err
}
return nil
Expand Down
51 changes: 3 additions & 48 deletions cmd/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,14 @@
package cmd

import (
"fmt"

"github.com/kubearmor/kubearmor-client/vm"
"github.com/spf13/cobra"
)

var (
scriptOptions vm.ScriptOptions
// HTTPIP : IP of the http request
HTTPIP string
// HTTPPort : Port of the http request
HTTPPort string
//IsKvmsEnv : Is kubearmor virtual machine env?
IsKvmsEnv bool
)

// vmCmd represents the vm command
var vmCmd = &cobra.Command{
Use: "vm",
Short: "VM commands for kvmservice",
Long: `VM commands for kvmservice`,
}

// vmScriptCmd represents the vm command for script download
var vmScriptCmd = &cobra.Command{
Use: "getscript",
Short: "download vm installation script for kvms control plane",
Long: `download vm installation script for kvms control plane`,
RunE: func(cmd *cobra.Command, args []string) error {
ip := HTTPIP

if err := vm.GetScript(client, scriptOptions, ip, IsKvmsEnv); err != nil {
return err
}
return nil
},
Short: "VM commands for non kubernetes/bare metal KubeArmor",
Long: `VM commands for non kubernetes/bare metal KubeArmor`,
}

// ========== //
Expand All @@ -48,23 +20,6 @@ var vmScriptCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(vmCmd)

// Options for vm script download
vmScriptCmd.Flags().StringVarP(&scriptOptions.Port, "port", "p", "32770", "Port of kvmservice")
vmScriptCmd.Flags().StringVarP(&scriptOptions.VMName, "kvm", "v", "", "Name of configured vm")
vmScriptCmd.Flags().StringVarP(&scriptOptions.File, "file", "f", "none", "Filename with path to store the configured vm installation script")

// Marking this flag as markedFlag and mandatory
err := vmScriptCmd.MarkFlagRequired("kvm")
if err != nil {
_ = fmt.Errorf("kvm option not supplied")
}

// options for vm generic commands related to HTTP Request
vmCmd.PersistentFlags().StringVar(&HTTPIP, "http-ip", "127.0.0.1", "IP of kvm-service")
vmCmd.PersistentFlags().StringVar(&HTTPPort, "http-port", "8000", "Port of kvm-service")
vmCmd.PersistentFlags().BoolVar(&IsKvmsEnv, "kvms", false, "Enable if kvms environment/control-plane")

// All subcommands
vmCmd.AddCommand(vmScriptCmd)
rootCmd.AddCommand(vmPolicyCmd)
}
86 changes: 0 additions & 86 deletions cmd/vmlabel.go

This file was deleted.

76 changes: 0 additions & 76 deletions cmd/vmonboarding.go

This file was deleted.

Loading

0 comments on commit 325762c

Please sign in to comment.