mirror of https://github.com/knative/client.git
fix analyzer warnings (#412)
* remove unused codes (structcheck)(varcheck) * add error handling (errcheck) * add error handling (ineffassign) * fix lint errors (golint)
This commit is contained in:
parent
94bb1cf8db
commit
43f8386b82
|
|
@ -143,7 +143,10 @@ func TestServiceUpdateImageSync(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, output, err := fakeServiceUpdate(orig, []string{
|
action, updated, output, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy", "--namespace", "bar"}, true)
|
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy", "--namespace", "bar"}, true)
|
||||||
|
|
@ -166,7 +169,10 @@ func TestServiceUpdateImage(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, output, err := fakeServiceUpdate(orig, []string{
|
action, updated, output, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy", "--namespace", "bar", "--async"}, false)
|
"service", "update", "foo", "--image", "gcr.io/foo/quux:xyzzy", "--namespace", "bar", "--async"}, false)
|
||||||
|
|
@ -371,7 +377,10 @@ func TestServiceUpdatePinsToDigestWhenAsked(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "-e", "TARGET=Awesome", "--lock-to-digest", "--async"}, false)
|
"service", "update", "foo", "-e", "TARGET=Awesome", "--lock-to-digest", "--async"}, false)
|
||||||
|
|
@ -396,7 +405,10 @@ func TestServiceUpdatePinsToDigestWhenPreviouslyDidSo(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "-e", "TARGET=Awesome", "--async"}, false)
|
"service", "update", "foo", "-e", "TARGET=Awesome", "--async"}, false)
|
||||||
|
|
@ -421,7 +433,10 @@ func TestServiceUpdateDoesntPinToDigestWhenUnAsked(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "-e", "TARGET=Awesome", "--no-lock-to-digest", "--async"}, false)
|
"service", "update", "foo", "-e", "TARGET=Awesome", "--no-lock-to-digest", "--async"}, false)
|
||||||
|
|
@ -443,12 +458,15 @@ func TestServiceUpdateDoesntPinToDigestWhenPreviouslyDidnt(t *testing.T) {
|
||||||
orig := newEmptyService()
|
orig := newEmptyService()
|
||||||
|
|
||||||
template, err := servinglib.RevisionTemplateOfService(orig)
|
template, err := servinglib.RevisionTemplateOfService(orig)
|
||||||
delete(template.Annotations, servinglib.UserImageAnnotationKey)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
delete(template.Annotations, servinglib.UserImageAnnotationKey)
|
||||||
|
|
||||||
servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
err = servinglib.UpdateImage(template, "gcr.io/foo/bar:baz")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
action, updated, _, err := fakeServiceUpdate(orig, []string{
|
||||||
"service", "update", "foo", "-e", "TARGET=Awesome", "--async"}, false)
|
"service", "update", "foo", "-e", "TARGET=Awesome", "--async"}, false)
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ var (
|
||||||
output string
|
output string
|
||||||
|
|
||||||
readFile, writeFile *os.File
|
readFile, writeFile *os.File
|
||||||
|
|
||||||
origArgs []string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateTestKnCommand helper for creating test commands
|
// CreateTestKnCommand helper for creating test commands
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,6 @@ type typeTestCase struct {
|
||||||
|
|
||||||
func TestGetClientConfig(t *testing.T) {
|
func TestGetClientConfig(t *testing.T) {
|
||||||
multiConfigs := fmt.Sprintf("%s%s%s", "/testing/assets/kube-config-01.yml", string(os.PathListSeparator), "/testing/assets/kube-config-02.yml")
|
multiConfigs := fmt.Sprintf("%s%s%s", "/testing/assets/kube-config-01.yml", string(os.PathListSeparator), "/testing/assets/kube-config-02.yml")
|
||||||
|
|
||||||
multiConfigs = multiConfigs
|
|
||||||
for _, tc := range []typeTestCase{
|
for _, tc := range []typeTestCase{
|
||||||
{
|
{
|
||||||
"",
|
"",
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ type PrintHandler interface {
|
||||||
type handlerEntry struct {
|
type handlerEntry struct {
|
||||||
columnDefinitions []metav1beta1.TableColumnDefinition
|
columnDefinitions []metav1beta1.TableColumnDefinition
|
||||||
printFunc reflect.Value
|
printFunc reflect.Value
|
||||||
args []reflect.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HumanReadablePrinter is an implementation of ResourcePrinter which attempts to provide
|
// HumanReadablePrinter is an implementation of ResourcePrinter which attempts to provide
|
||||||
|
|
|
||||||
|
|
@ -165,11 +165,15 @@ func SetUserImageAnnot(template *servingv1alpha1.RevisionTemplateSpec) {
|
||||||
|
|
||||||
// FreezeImageToDigest sets the image on the template to the image digest of the base revision.
|
// FreezeImageToDigest sets the image on the template to the image digest of the base revision.
|
||||||
func FreezeImageToDigest(template *servingv1alpha1.RevisionTemplateSpec, baseRevision *servingv1alpha1.Revision) error {
|
func FreezeImageToDigest(template *servingv1alpha1.RevisionTemplateSpec, baseRevision *servingv1alpha1.Revision) error {
|
||||||
currentContainer, err := ContainerOfRevisionTemplate(template)
|
|
||||||
|
|
||||||
if baseRevision == nil {
|
if baseRevision == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentContainer, err := ContainerOfRevisionTemplate(template)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
baseContainer, err := ContainerOfRevisionSpec(&baseRevision.Spec)
|
baseContainer, err := ContainerOfRevisionSpec(&baseRevision.Spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -422,9 +422,8 @@ func TestGetBaseRevision(t *testing.T) {
|
||||||
if c.foundRevisionImage != "" {
|
if c.foundRevisionImage != "" {
|
||||||
revision.Spec.Containers[0].Image = c.foundRevisionImage
|
revision.Spec.Containers[0].Image = c.foundRevisionImage
|
||||||
return true, revision, nil
|
return true, revision, nil
|
||||||
} else {
|
|
||||||
return true, nil, errors.NewNotFound(v1alpha1.Resource("revision"), name)
|
|
||||||
}
|
}
|
||||||
|
return true, nil, errors.NewNotFound(v1alpha1.Resource("revision"), name)
|
||||||
})
|
})
|
||||||
for _, c = range cases {
|
for _, c = range cases {
|
||||||
service := v1alpha1.Service{}
|
service := v1alpha1.Service{}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue