Skip to content

Commit

Permalink
fix: go-lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Aryan-sharma11 <aryan1126.sharma@gmail.com>
  • Loading branch information
Aryan-sharma11 committed May 9, 2023
1 parent 1dfc0ec commit 3263182
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 52 deletions.
6 changes: 2 additions & 4 deletions cmd/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ var discoverCmd = &cobra.Command{
Short: "Discover applicable policies",
Long: `Discover applicable policies`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := discover.Policy(client, discoverOptions); err != nil {
return err
}
return nil
err := discover.Policy(client, discoverOptions)
return err
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/recommend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ var recommendCmd = &cobra.Command{
Short: "Recommend Policies",
Long: `Recommend policies based on container image, k8s manifest or the actual runtime env`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := recommend.Recommend(client, recommendOptions); err != nil {
return err
}
return nil
err := recommend.Recommend(client, recommendOptions)
return err
},
}
var updateCmd = &cobra.Command{
Expand Down
6 changes: 2 additions & 4 deletions cmd/rotate-tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ var rotateCmd = &cobra.Command{
Short: "Rotate webhook controller tls certificates",
Long: `Rotate webhook controller tls certificates`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := rotatetls.RotateTLS(client, namespace); err != nil {
return err
}
return nil
err := rotatetls.RotateTLS(client, namespace)
return err
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ var selfUpdateCmd = &cobra.Command{
Short: "selfupdate this cli tool",
Long: `selfupdate this cli tool for checking the latest release on the github`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := selfupdate.SelfUpdate(client); err != nil {
return err
}
return nil
err := selfupdate.SelfUpdate()
return err
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ var uninstallCmd = &cobra.Command{
Long: `Uninstall KubeArmor from a Kubernetes Clusters`,
RunE: func(cmd *cobra.Command, args []string) error {
uninstallOptions.Animation = true
if err := install.K8sUninstaller(client, uninstallOptions); err != nil {
return err
}
return nil
err := install.K8sUninstaller(client, uninstallOptions)
return err
},
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ var versionCmd = &cobra.Command{
Short: "Display version information",
Long: `Display version information`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := version.PrintVersion(client); err != nil {
return err
}
return nil
err := version.PrintVersion(client)
return err
},
}

Expand Down
18 changes: 6 additions & 12 deletions cmd/vmlabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ var vmLabelAddCmd = &cobra.Command{
// Create http address
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)

if err := vm.LabelHandling("ADD", labelOptions, httpAddress, IsKvmsEnv); err != nil {
return err
}
return nil
err := vm.LabelHandling("ADD", labelOptions, httpAddress, IsKvmsEnv)
return err
},
}

Expand All @@ -46,10 +44,8 @@ var vmLabelDeleteCmd = &cobra.Command{
// Create http address
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)

if err := vm.LabelHandling("DELETE", labelOptions, httpAddress, IsKvmsEnv); err != nil {
return err
}
return nil
err := vm.LabelHandling("DELETE", labelOptions, httpAddress, IsKvmsEnv)
return err
},
}

Expand All @@ -62,10 +58,8 @@ var vmLabelListCmd = &cobra.Command{
// Create http address
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)

if err := vm.LabelHandling("LIST", labelOptions, httpAddress, IsKvmsEnv); err != nil {
return err
}
return nil
err := vm.LabelHandling("LIST", labelOptions, httpAddress, IsKvmsEnv)
return err
},
}

Expand Down
12 changes: 4 additions & 8 deletions cmd/vmonboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ var vmOnboardAddCmd = &cobra.Command{
},
RunE: func(cmd *cobra.Command, args []string) error {
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)
if err := vm.Onboarding("ADDED", args[0], httpAddress); err != nil {
return err
}
return nil
err := vm.Onboarding("ADDED", args[0], httpAddress)
return err
},
}

Expand All @@ -44,10 +42,8 @@ var vmOnboardDeleteCmd = &cobra.Command{
},
RunE: func(cmd *cobra.Command, args []string) error {
httpAddress := "http://" + net.JoinHostPort(HTTPIP, HTTPPort)
if err := vm.Onboarding("DELETED", args[0], httpAddress); err != nil {
return err
}
return nil
err := vm.Onboarding("DELETED", args[0], httpAddress)
return err
},
}

Expand Down
13 changes: 7 additions & 6 deletions probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ func isKubeArmorRunning(c *k8s.Client, o Options) (bool, *Status) {

}

// Status data
type Status struct {
Desired string `json:"desired"`
Ready string `json:"ready"`
Expand Down Expand Up @@ -471,6 +472,7 @@ func getKubeArmorDeployments(c *k8s.Client, o Options) map[string]*Status {
return nil
}

// KubeArmorPodSpec structure definition
type KubeArmorPodSpec struct {
Running string `json:"running"`
Image_Version string `json:"image_version"`
Expand Down Expand Up @@ -743,7 +745,7 @@ func getNsSecurityPostureAndVisibility(c *k8s.Client, postureData map[string]str
return mp, err
}

// To store Namespace default posture and visibility data
// NamespaceData structure definition
type NamespaceData struct {
NsPostureString string `json:"-"`
NsVisibilityString string `json:"-"`
Expand All @@ -752,15 +754,15 @@ type NamespaceData struct {
NsPodList []PodInfo `json:"pod_list"`
}

// To store visibility data
// Visibility data structure definition
type Visibility struct {
File bool `json:"file"`
Capabilities bool `json:"capabilities"`
Process bool `json:"process"`
Network bool `json:"network"`
}

// To store pod data
// PodInfo structure definition
type PodInfo struct {
PodName string `json:"pod_name"`
Policy string `json:"policy"`
Expand Down Expand Up @@ -805,9 +807,8 @@ func getAnnotatedPods(c *k8s.Client, o Options, postureData map[string]string) (
for policyKey, policyValue := range policyMap {
s2 := sliceToSet(policyValue)
if s2.IsSubset(labels) {
if checkIfDataAlreadyContainsPodName(data, armoredPod.Name, policyKey) {
continue
} else {
if !checkIfDataAlreadyContainsPodName(data, armoredPod.Name, policyKey) {

data = append(data, []string{armoredPod.Namespace, mp[armoredPod.Namespace].NsPostureString, mp[armoredPod.Namespace].NsVisibilityString, armoredPod.Name, policyKey})

}
Expand Down
3 changes: 1 addition & 2 deletions selfupdate/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/blang/semver"
"github.com/fatih/color"
"github.com/kubearmor/kubearmor-client/k8s"
"github.com/rhysd/go-github-selfupdate/selfupdate"
)

Expand Down Expand Up @@ -107,7 +106,7 @@ func doSelfUpdate(curver string) error {
}

// SelfUpdate handler for karmor cli tool
func SelfUpdate(c *k8s.Client) error {
func SelfUpdate() error {
var ver = GitSummary
fmt.Printf("current karmor version %s\n", ver)
if !isValidVersion(ver) {
Expand Down

0 comments on commit 3263182

Please sign in to comment.