fix lint errors

This commit is contained in:
jingfangliu 2019-07-22 13:42:56 -07:00
parent 452b74480e
commit 675fa4b45b
6 changed files with 18 additions and 9 deletions

View File

@ -281,7 +281,7 @@ func TestApplyWithPresenceAnnotation(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, false, exist)
r, err = a.Do()
_, err = a.Do()
assert.NoError(t, err)
exist, err = util.ObjectExist(a.DynamicClient, context.Background(), liveService)
assert.NoError(t, err)

View File

@ -21,10 +21,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)
func jsonPath(fields []string) string {
return "." + strings.Join(fields, ".")
}
// ObjWithConditions Represent meta object with status.condition array
type ObjWithConditions struct {
// Status as expected to be present in most compliant kubernetes resources

View File

@ -20,7 +20,6 @@ import (
helperu "sigs.k8s.io/cli-experimental/internal/pkg/client/unstructured"
)
var emptyObj = map[string]interface{}{}
var testObj = map[string]interface{}{
"f1": map[string]interface{}{
"f2": map[string]interface{}{

View File

@ -519,6 +519,7 @@ func TestDeleteWithPresenceNoInventory(t *testing.T) {
// Then run delete
// Confirm that the service is deleted
_, err = d.Do()
assert.NoError(t, err)
exist, err = util.ObjectExist(a.DynamicClient, context.Background(), liveService)
assert.NoError(t, err)
assert.Equal(t, false, exist)

View File

@ -16,6 +16,7 @@ package resourceconfig
import (
"bytes"
"io/ioutil"
"log"
"os"
"path/filepath"
"sigs.k8s.io/kustomize/k8sdeps/validator"
@ -68,7 +69,11 @@ func (p *KustomizeProvider) getKustTarget(path string) (ifc.Loader, *target.Kust
// IsSupported checks if the path is supported by KustomizeProvider
func (p *KustomizeProvider) IsSupported(path string) bool {
ldr, _, err := p.getKustTarget(path)
defer ldr.Cleanup()
defer func() {
if err := ldr.Cleanup(); err != nil {
log.Fatal("failed to clean up the loader")
}
}()
if err != nil {
return false
@ -82,7 +87,12 @@ func (p *KustomizeProvider) GetConfig(path string) ([]*unstructured.Unstructured
if err != nil {
return nil, err
}
defer ldr.Cleanup()
defer func() {
if err := ldr.Cleanup(); err != nil {
log.Fatal("failed to clean up the loader")
}
}()
rm, err := kt.MakeCustomizedResMap()
if err != nil {
return nil, err

View File

@ -63,7 +63,8 @@ func TestKustomizeProvider2(t *testing.T) {
assert.NotEmpty(t, pobject)
assert.NotNil(t, pobject)
inv := inventory.NewInventory()
inv.LoadFromAnnotation(pobject[1].GetAnnotations())
err = inv.LoadFromAnnotation(pobject[1].GetAnnotations())
assert.NoError(t, err)
assert.Equal(t, len(inv.Current), 1)
}
@ -189,6 +190,8 @@ func TestRawConfigFileProvider(t *testing.T) {
assert.Equal(t, expected[0], resources[0])
b = cp.IsSupported(subdir)
assert.Equal(t, b, true)
assert.Equal(t, b, true)
resources, err = cp.GetConfig(subdir)
assert.NoError(t, err)
assert.Equal(t, len(resources), 2)