diff --git a/cmd/initContainer/main.go b/cmd/initContainer/main.go index e2ab820b20..358d5779d5 100644 --- a/cmd/initContainer/main.go +++ b/cmd/initContainer/main.go @@ -102,6 +102,26 @@ func main() { } } +<<<<<<< HEAD +======= +func init() { + // arguments + flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") + err := flag.Set("logtostderr", "true") + if err != nil { + glog.Errorf("failed to set flag %v", err) + } + err = flag.Set("stderrthreshold", "WARNING") + if err != nil { + glog.Errorf("failed to set flag %v", err) + } + err = flag.Set("v", "2") + if err != nil { + glog.Errorf("failed to set flag %v", err) + } + flag.Parse() +} +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 func removeWebhookIfExists(client *client.Client, kind string, name string) error { logger := log.Log.WithName("removeExistingWebhook").WithValues("kind", kind, "name", name) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2d6ccdcb68..6d3f69a0e1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -71,6 +71,25 @@ var ( //VerifyMutatingWebhookServicePath is the path for verify webhook(used to veryfing if admission control is enabled and active) VerifyMutatingWebhookServicePath = "/verifymutate" ) +<<<<<<< HEAD +======= +//LogDefaultFlags sets default glog flags +func LogDefaultFlags() { + var err error + err = flag.Set("logtostderr", "true") + if err != nil { + glog.Fatalf("failed to set flag 'logtostderr' to 'true':%v", err) + } + err = flag.Set("stderrthreshold", "WARNING") + if err != nil { + glog.Fatalf("failed to set flag 'stderrthreshold' to 'WARNING':%v", err) + } + err = flag.Set("v", "2") + if err != nil { + glog.Fatalf("failed to set flag 'v' to '2':%v", err) + } +} +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 //CreateClientConfig creates client config func CreateClientConfig(kubeconfig string, log logr.Logger) (*rest.Config, error) { diff --git a/pkg/engine/mutate/overlayCondition_test.go b/pkg/engine/mutate/overlayCondition_test.go index 618b9e4599..1c8fc2c89e 100644 --- a/pkg/engine/mutate/overlayCondition_test.go +++ b/pkg/engine/mutate/overlayCondition_test.go @@ -32,6 +32,7 @@ func TestMeetConditions_NoAnchor(t *testing.T) { _, err := meetConditions(log.Log, nil, overlay) + assert.Assert(t, reflect.DeepEqual(err, overlayError{})) } @@ -86,7 +87,6 @@ func TestMeetConditions_conditionalAnchorOnMap(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) - _, err := meetConditions(log.Log, resource, overlay) assert.Assert(t, !reflect.DeepEqual(err, overlayError{})) @@ -149,6 +149,7 @@ func TestMeetConditions_DifferentTypes(t *testing.T) { assert.NilError(t, err) // anchor exist + _, err := meetConditions(log.Log, resource, overlay) assert.Assert(t, strings.Contains(err.Error(), "Found anchor on different types of element at path /subsets/")) } @@ -204,6 +205,7 @@ func TestMeetConditions_anchosInSameObject(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) + _, err := meetConditions(log.Log, resource, overlay) assert.Error(t, err, "[overlayError:0] Failed validating value 443 with overlay 444") } @@ -264,6 +266,7 @@ func TestMeetConditions_anchorOnPeer(t *testing.T) { assert.NilError(t, err) err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) + _, err := meetConditions(log.Log, resource, overlay) assert.Assert(t, reflect.DeepEqual(err, overlayError{})) @@ -344,11 +347,16 @@ func TestMeetConditions_anchorsOnMetaAndSpec(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) +<<<<<<< HEAD <<<<<<< HEAD _, err = meetConditions(resource, overlay) ======= _, err := meetConditions(log.Log, resource, overlay) >>>>>>> 589f8ece47f95aedc4ee0decee8d29cb77b73dd6 +======= + _, err = meetConditions(resource, overlay) + +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 assert.Assert(t, reflect.DeepEqual(err, overlayError{})) } @@ -431,11 +439,16 @@ func TestMeetConditions_anchorsOnPeer_single(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) +<<<<<<< HEAD <<<<<<< HEAD _, err = meetConditions(resource, overlay) ======= _, err := meetConditions(log.Log, resource, overlay) >>>>>>> 589f8ece47f95aedc4ee0decee8d29cb77b73dd6 +======= + _, err = meetConditions(resource, overlay) + +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 assert.Assert(t, reflect.DeepEqual(err, overlayError{})) } @@ -471,11 +484,16 @@ func TestMeetConditions_anchorsOnPeer_two(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) +<<<<<<< HEAD <<<<<<< HEAD _, err = meetConditions(resource, overlay) ======= _, err := meetConditions(log.Log, resource, overlay) >>>>>>> 589f8ece47f95aedc4ee0decee8d29cb77b73dd6 +======= + _, err = meetConditions(resource, overlay) + +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 assert.Error(t, err, "[overlayError:0] Failed validating value true with overlay false") overlayRaw = []byte(`{ @@ -571,11 +589,16 @@ func TestMeetConditions_anchorsOnPeer_multiple(t *testing.T) { err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) +<<<<<<< HEAD <<<<<<< HEAD _, err = meetConditions(resource, overlay) ======= _, err := meetConditions(log.Log, resource, overlay) >>>>>>> 589f8ece47f95aedc4ee0decee8d29cb77b73dd6 +======= + _, err = meetConditions(resource, overlay) + +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 assert.Assert(t, reflect.DeepEqual(err, overlayError{})) overlayRaw = []byte(`{ @@ -692,17 +715,24 @@ func TestMeetConditions_AtleastOneExist(t *testing.T) { var resource, overlay interface{} <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 err := json.Unmarshal(resourceRaw, &resource) assert.NilError(t, err) err = json.Unmarshal(overlayRaw, &overlay) assert.NilError(t, err) path, err := meetConditions(resource, overlay) +<<<<<<< HEAD ======= json.Unmarshal(resourceRaw, &resource) json.Unmarshal(overlayRaw, &overlay) path, err := meetConditions(log.Log, resource, overlay) >>>>>>> 589f8ece47f95aedc4ee0decee8d29cb77b73dd6 +======= + +>>>>>>> 010bc2b43d99e27daf8709baca5b02ac5ca10011 assert.Assert(t, reflect.DeepEqual(err, overlayError{})) assert.Assert(t, len(path) == 0) }