-
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 #359 from Prateeknandle/refractor-recommend
refactor recommend cli
- Loading branch information
Showing
31 changed files
with
1,224 additions
and
1,684 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2023 Authors of KubeArmor | ||
|
||
// Package hacks close the file | ||
package hacks | ||
|
||
import ( | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// CloseCheckErr close file | ||
func CloseCheckErr(f *os.File, fname string) { | ||
err := f.Close() | ||
if err != nil { | ||
log.WithFields(log.Fields{ | ||
"file": fname, | ||
}).Error("close file failed") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,61 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2023 Authors of KubeArmor | ||
|
||
// Package common contains object types used by multiple packages | ||
package common | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
|
||
pol "github.com/kubearmor/KubeArmor/pkg/KubeArmorController/api/security.kubearmor.com/v1" | ||
) | ||
|
||
// Handler interface | ||
var Handler interface{} | ||
|
||
// MatchSpec spec to match for defining policy | ||
type MatchSpec struct { | ||
Name string `json:"name" yaml:"name"` | ||
Precondition []string `json:"precondition" yaml:"precondition"` | ||
Description Description `json:"description" yaml:"description"` | ||
Yaml string `json:"yaml" yaml:"yaml"` | ||
Spec pol.KubeArmorPolicySpec `json:"spec,omitempty" yaml:"spec,omitempty"` | ||
} | ||
|
||
// Ref for the policy rules | ||
type Ref struct { | ||
Name string `json:"name" yaml:"name"` | ||
URL []string `json:"url" yaml:"url"` | ||
} | ||
|
||
// Description detailed description for the policy rule | ||
type Description struct { | ||
Refs []Ref `json:"refs" yaml:"refs"` | ||
Tldr string `json:"tldr" yaml:"tldr"` | ||
Detailed string `json:"detailed" yaml:"detailed"` | ||
} | ||
|
||
// Options for karmor recommend | ||
type Options struct { | ||
Images []string | ||
Labels []string | ||
Tags []string | ||
Policy []string | ||
Namespace string | ||
OutDir string | ||
ReportFile string | ||
Config string | ||
} | ||
|
||
// UserHome function returns users home directory | ||
func UserHome() string { | ||
if runtime.GOOS == "windows" { | ||
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") | ||
if home == "" { | ||
home = os.Getenv("USERPROFILE") | ||
} | ||
return home | ||
} | ||
return os.Getenv("HOME") | ||
} |
Oops, something went wrong.