fix staticcheck issues

add staticcheck CI action

add staticcheck in Makefile

Signed-off-by: roywang <seiwy2010@gmail.com>
This commit is contained in:
roy wang
2021-01-29 18:42:03 +09:00
committed by roywang
parent af61a81828
commit 93ae8a9099
43 changed files with 136 additions and 115 deletions
+5 -6
View File
@@ -20,7 +20,6 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
corev1alpha2 "github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
"github.com/oam-dev/kubevela/apis/types"
"github.com/oam-dev/kubevela/pkg/appfile"
@@ -54,7 +53,7 @@ type AppfileOptions struct {
// BuildResult is the export struct from AppFile yaml or AppFile object
type BuildResult struct {
appFile *api.AppFile
application *v1alpha2.Application
application *corev1alpha2.Application
scopes []oam.Object
}
@@ -461,13 +460,13 @@ func (o *AppfileOptions) saveToAppDir(f *api.AppFile) error {
// - for create, it displays app status along with information of url, metrics, ssh, logging.
// - for update, it rolls out a canary deployment and prints its information. User can verify the canary deployment.
// This will wait for user approval. If approved, it continues upgrading the whole; otherwise, it would rollback.
func (o *AppfileOptions) ApplyApp(app *v1alpha2.Application, scopes []oam.Object) error {
func (o *AppfileOptions) ApplyApp(app *corev1alpha2.Application, scopes []oam.Object) error {
key := apitypes.NamespacedName{
Namespace: app.Namespace,
Name: app.Name,
}
o.IO.Infof("Checking if app has been deployed...\n")
var tmpApp v1alpha2.Application
var tmpApp corev1alpha2.Application
err := o.Kubecli.Get(context.TODO(), key, &tmpApp)
switch {
case apierrors.IsNotFound(err):
@@ -484,7 +483,7 @@ func (o *AppfileOptions) ApplyApp(app *v1alpha2.Application, scopes []oam.Object
return nil
}
func (o *AppfileOptions) apply(app *v1alpha2.Application, scopes []oam.Object) error {
func (o *AppfileOptions) apply(app *corev1alpha2.Application, scopes []oam.Object) error {
if err := appfile.Run(context.TODO(), o.Kubecli, app, scopes); err != nil {
return err
}
@@ -492,7 +491,7 @@ func (o *AppfileOptions) apply(app *v1alpha2.Application, scopes []oam.Object) e
}
// Info shows the status of each service in the Appfile
func (o *AppfileOptions) Info(app *v1alpha2.Application) string {
func (o *AppfileOptions) Info(app *corev1alpha2.Application) string {
appName := app.Name
var appUpMessage = "✅ App has been deployed 🚀🚀🚀\n" +
fmt.Sprintf(" Port forward: vela port-forward %s\n", appName) +
+3
View File
@@ -213,6 +213,9 @@ func TestGetParameterFromOpenAPISchema(t *testing.T) {
t.Run(name, func(t *testing.T) {
rawFile := filepath.Join(tc.fileDir, tc.fileName)
raw, err := ioutil.ReadFile(rawFile)
if err != nil {
t.Errorf("%s\ngetParameterFromOpenAPISchema(...): raw file %s could not be read: %s", tc.reason, rawFile, err)
}
got, err := getParameterFromOpenAPISchema(raw)
if (err == nil && tc.want != nil) || (err != nil && tc.want == nil) {
t.Errorf("%s\ngetParameterFromOpenAPISchema(...): -want %s, +got %s", tc.reason, tc.want, err)
+1 -2
View File
@@ -14,7 +14,6 @@ import (
"github.com/oam-dev/kubevela/pkg/appfile"
"github.com/oam-dev/kubevela/pkg/appfile/api"
"github.com/oam-dev/kubevela/pkg/commands/util"
cmdutil "github.com/oam-dev/kubevela/pkg/commands/util"
"github.com/oam-dev/kubevela/pkg/plugins"
)
@@ -134,7 +133,7 @@ func BaseComplete(envName string, workloadName string, appName string, flagSet *
}
// BaseRun will check if it's a stating operation before run
func BaseRun(staging bool, app *api.Application, kubeClient client.Client, env *types.EnvMeta, io cmdutil.IOStreams) (string, error) {
func BaseRun(staging bool, app *api.Application, kubeClient client.Client, env *types.EnvMeta, io util.IOStreams) (string, error) {
if staging {
return "Staging saved", nil
}