mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-13 19:28:55 +00:00
fix: remove unused parameters (#10327)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
parent
022620ef43
commit
aa59bbc947
6 changed files with 13 additions and 22 deletions
|
@ -153,7 +153,7 @@ func (c *ApplyCommandConfig) applyCommandHelper(out io.Writer) (*processor.Resul
|
|||
return nil, nil, skipInvalidPolicies, nil, fmt.Errorf("failed to decode yaml (%w)", err)
|
||||
}
|
||||
var store store.Store
|
||||
rc, resources1, skipInvalidPolicies, responses1, err, dClient := c.initStoreAndClusterClient(&store, skipInvalidPolicies)
|
||||
rc, resources1, skipInvalidPolicies, responses1, dClient, err := c.initStoreAndClusterClient(&store, skipInvalidPolicies)
|
||||
if err != nil {
|
||||
return rc, resources1, skipInvalidPolicies, responses1, err
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ func (c *ApplyCommandConfig) loadPolicies(skipInvalidPolicies SkippedInvalidPoli
|
|||
return nil, nil, skipInvalidPolicies, nil, policies, vaps, vapBindings, nil
|
||||
}
|
||||
|
||||
func (c *ApplyCommandConfig) initStoreAndClusterClient(store *store.Store, skipInvalidPolicies SkippedInvalidPolicies) (*processor.ResultCounts, []*unstructured.Unstructured, SkippedInvalidPolicies, []engineapi.EngineResponse, error, dclient.Interface) {
|
||||
func (c *ApplyCommandConfig) initStoreAndClusterClient(store *store.Store, skipInvalidPolicies SkippedInvalidPolicies) (*processor.ResultCounts, []*unstructured.Unstructured, SkippedInvalidPolicies, []engineapi.EngineResponse, dclient.Interface, error) {
|
||||
store.SetLocal(true)
|
||||
store.SetRegistryAccess(c.RegistryAccess)
|
||||
if c.Cluster {
|
||||
|
@ -389,22 +389,22 @@ func (c *ApplyCommandConfig) initStoreAndClusterClient(store *store.Store, skipI
|
|||
if c.Cluster {
|
||||
restConfig, err := config.CreateClientConfigWithContext(c.KubeConfig, c.Context)
|
||||
if err != nil {
|
||||
return nil, nil, skipInvalidPolicies, nil, err, nil
|
||||
return nil, nil, skipInvalidPolicies, nil, nil, err
|
||||
}
|
||||
kubeClient, err := kubernetes.NewForConfig(restConfig)
|
||||
if err != nil {
|
||||
return nil, nil, skipInvalidPolicies, nil, err, nil
|
||||
return nil, nil, skipInvalidPolicies, nil, nil, err
|
||||
}
|
||||
dynamicClient, err := dynamic.NewForConfig(restConfig)
|
||||
if err != nil {
|
||||
return nil, nil, skipInvalidPolicies, nil, err, nil
|
||||
return nil, nil, skipInvalidPolicies, nil, nil, err
|
||||
}
|
||||
dClient, err = dclient.NewClient(context.Background(), dynamicClient, kubeClient, 15*time.Minute)
|
||||
if err != nil {
|
||||
return nil, nil, skipInvalidPolicies, nil, err, nil
|
||||
return nil, nil, skipInvalidPolicies, nil, nil, err
|
||||
}
|
||||
}
|
||||
return nil, nil, skipInvalidPolicies, nil, err, dClient
|
||||
return nil, nil, skipInvalidPolicies, nil, dClient, err
|
||||
}
|
||||
|
||||
func (c *ApplyCommandConfig) cleanPreviousContent(mutateLogPathIsDir bool, skipInvalidPolicies SkippedInvalidPolicies) (*processor.ResultCounts, []*unstructured.Unstructured, SkippedInvalidPolicies, []engineapi.EngineResponse, error) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
|
||||
func Test_Apply(t *testing.T) {
|
||||
type TestCase struct {
|
||||
gitBranch string
|
||||
expectedPolicyReports []policyreportv1alpha2.PolicyReport
|
||||
config ApplyCommandConfig
|
||||
stdinFile string
|
||||
|
|
|
@ -194,7 +194,7 @@ func (p *PolicyProcessor) ApplyPoliciesOnResource() ([]engineapi.EngineResponse,
|
|||
}
|
||||
responses = append(responses, generateResponse)
|
||||
}
|
||||
p.Rc.addGenerateResponse(p.AuditWarn, resPath, generateResponse)
|
||||
p.Rc.addGenerateResponse(p.AuditWarn, generateResponse)
|
||||
}
|
||||
}
|
||||
p.Rc.addEngineResponses(p.AuditWarn, responses...)
|
||||
|
@ -332,7 +332,7 @@ func (p *PolicyProcessor) makePolicyContext(
|
|||
}
|
||||
|
||||
func (p *PolicyProcessor) processMutateEngineResponse(response engineapi.EngineResponse, resourcePath string) error {
|
||||
printMutatedRes := p.Rc.addMutateResponse(resourcePath, response)
|
||||
printMutatedRes := p.Rc.addMutateResponse(response)
|
||||
if printMutatedRes && p.PrintPatchResource {
|
||||
yamlEncodedResource, err := yamlv2.Marshal(response.PatchedResource.Object)
|
||||
if err != nil {
|
||||
|
|
|
@ -55,13 +55,6 @@ var policyNamespaceSelector = []byte(`{
|
|||
`)
|
||||
|
||||
func Test_NamespaceSelector(t *testing.T) {
|
||||
type resultCounts struct {
|
||||
pass int
|
||||
fail int
|
||||
warn int
|
||||
err int
|
||||
skip int
|
||||
}
|
||||
type TestCase struct {
|
||||
policy []byte
|
||||
resource []byte
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/policy/annotations"
|
||||
"github.com/kyverno/kyverno/pkg/autogen"
|
||||
engineapi "github.com/kyverno/kyverno/pkg/engine/api"
|
||||
"k8s.io/api/admissionregistration/v1alpha1"
|
||||
)
|
||||
|
||||
type ResultCounts struct {
|
||||
|
@ -64,7 +63,7 @@ func (rc *ResultCounts) addEngineResponse(auditWarn bool, response engineapi.Eng
|
|||
}
|
||||
}
|
||||
|
||||
func (rc *ResultCounts) addGenerateResponse(auditWarn bool, resPath string, response engineapi.EngineResponse) {
|
||||
func (rc *ResultCounts) addGenerateResponse(auditWarn bool, response engineapi.EngineResponse) {
|
||||
genericPolicy := response.Policy()
|
||||
if polType := genericPolicy.GetType(); polType == engineapi.ValidatingAdmissionPolicyType {
|
||||
return
|
||||
|
@ -88,7 +87,7 @@ func (rc *ResultCounts) addGenerateResponse(auditWarn bool, resPath string, resp
|
|||
}
|
||||
}
|
||||
|
||||
func (rc *ResultCounts) addMutateResponse(resourcePath string, response engineapi.EngineResponse) bool {
|
||||
func (rc *ResultCounts) addMutateResponse(response engineapi.EngineResponse) bool {
|
||||
genericPolicy := response.Policy()
|
||||
if polType := genericPolicy.GetType(); polType == engineapi.ValidatingAdmissionPolicyType {
|
||||
return false
|
||||
|
@ -124,7 +123,7 @@ func (rc *ResultCounts) addMutateResponse(resourcePath string, response engineap
|
|||
return printMutatedRes
|
||||
}
|
||||
|
||||
func (rc *ResultCounts) addValidatingAdmissionResponse(vap v1alpha1.ValidatingAdmissionPolicy, engineResponse engineapi.EngineResponse) {
|
||||
func (rc *ResultCounts) addValidatingAdmissionResponse(engineResponse engineapi.EngineResponse) {
|
||||
for _, ruleResp := range engineResponse.PolicyResponse.Rules {
|
||||
if ruleResp.Status() == engineapi.RuleStatusPass {
|
||||
rc.Pass++
|
||||
|
|
|
@ -29,7 +29,7 @@ func (p *ValidatingAdmissionPolicyProcessor) ApplyPolicyOnResource() ([]engineap
|
|||
}
|
||||
response, _ := validatingadmissionpolicy.Validate(policyData, *p.Resource, p.NamespaceSelectorMap, p.Client)
|
||||
responses = append(responses, response)
|
||||
p.Rc.addValidatingAdmissionResponse(policy, response)
|
||||
p.Rc.addValidatingAdmissionResponse(response)
|
||||
}
|
||||
return responses, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue