mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-24 10:13:01 +00:00
fix staticcheck issues
add staticcheck CI action add staticcheck in Makefile Signed-off-by: roywang <seiwy2010@gmail.com>
This commit is contained in:
@@ -33,7 +33,6 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
"github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
|
||||
runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/event"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/logging"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/meta"
|
||||
@@ -473,7 +472,7 @@ func (w Workload) Status() v1alpha2.WorkloadStatus {
|
||||
acw := v1alpha2.WorkloadStatus{
|
||||
ComponentName: w.ComponentName,
|
||||
ComponentRevisionName: w.ComponentRevisionName,
|
||||
Reference: runtimev1alpha1.TypedReference{
|
||||
Reference: v1alpha1.TypedReference{
|
||||
APIVersion: w.Workload.GetAPIVersion(),
|
||||
Kind: w.Workload.GetKind(),
|
||||
Name: w.Workload.GetName(),
|
||||
@@ -485,14 +484,14 @@ func (w Workload) Status() v1alpha2.WorkloadStatus {
|
||||
if tr.Definition.Name == util.Dummy && tr.Definition.Spec.Reference.Name == util.Dummy {
|
||||
acw.Traits[i].Message = util.DummyTraitMessage
|
||||
}
|
||||
acw.Traits[i].Reference = runtimev1alpha1.TypedReference{
|
||||
acw.Traits[i].Reference = v1alpha1.TypedReference{
|
||||
APIVersion: w.Traits[i].Object.GetAPIVersion(),
|
||||
Kind: w.Traits[i].Object.GetKind(),
|
||||
Name: w.Traits[i].Object.GetName(),
|
||||
}
|
||||
}
|
||||
for i, s := range w.Scopes {
|
||||
acw.Scopes[i].Reference = runtimev1alpha1.TypedReference{
|
||||
acw.Scopes[i].Reference = v1alpha1.TypedReference{
|
||||
APIVersion: s.GetAPIVersion(),
|
||||
Kind: s.GetKind(),
|
||||
Name: s.GetName(),
|
||||
@@ -523,16 +522,16 @@ func IsRevisionWorkload(status v1alpha2.WorkloadStatus) bool {
|
||||
}
|
||||
|
||||
func eligible(namespace string, ws []v1alpha2.WorkloadStatus, w []Workload) []unstructured.Unstructured {
|
||||
applied := make(map[runtimev1alpha1.TypedReference]bool)
|
||||
applied := make(map[v1alpha1.TypedReference]bool)
|
||||
for _, wl := range w {
|
||||
r := runtimev1alpha1.TypedReference{
|
||||
r := v1alpha1.TypedReference{
|
||||
APIVersion: wl.Workload.GetAPIVersion(),
|
||||
Kind: wl.Workload.GetKind(),
|
||||
Name: wl.Workload.GetName(),
|
||||
}
|
||||
applied[r] = true
|
||||
for _, t := range wl.Traits {
|
||||
r := runtimev1alpha1.TypedReference{
|
||||
r := v1alpha1.TypedReference{
|
||||
APIVersion: t.Object.GetAPIVersion(),
|
||||
Kind: t.Object.GetKind(),
|
||||
Name: t.Object.GetName(),
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/crossplane/crossplane-runtime/pkg/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
v12 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -112,7 +111,7 @@ func TestComponentHandler(t *testing.T) {
|
||||
}
|
||||
comp := &v1alpha2.Component{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "biz", Name: "comp1", Generation: 1},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &v1.Deployment{Spec: v1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v1"}}}}}}}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &appsv1.Deployment{Spec: appsv1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v1"}}}}}}}},
|
||||
}
|
||||
|
||||
// ============ Test Create Event Start ===================
|
||||
@@ -148,7 +147,7 @@ func TestComponentHandler(t *testing.T) {
|
||||
comp2 := &v1alpha2.Component{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "biz", Name: "comp1"},
|
||||
// change image
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &v1.Deployment{Spec: v1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v2"}}}}}}}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &appsv1.Deployment{Spec: appsv1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v2"}}}}}}}},
|
||||
}
|
||||
curComp.Status.DeepCopyInto(&comp2.Status)
|
||||
updateEvt := event.UpdateEvent{
|
||||
@@ -185,7 +184,7 @@ func TestComponentHandler(t *testing.T) {
|
||||
// test no changes with component spec
|
||||
comp3 := &v1alpha2.Component{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "biz", Name: "comp1", Labels: map[string]string{"bar": "foo"}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &v1.Deployment{Spec: v1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v2"}}}}}}}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &appsv1.Deployment{Spec: appsv1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v2"}}}}}}}},
|
||||
}
|
||||
curComp.Status.DeepCopyInto(&comp3.Status)
|
||||
updateEvt = event.UpdateEvent{
|
||||
@@ -204,7 +203,7 @@ func TestComponentHandler(t *testing.T) {
|
||||
// test clean revision
|
||||
comp4 := &v1alpha2.Component{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "biz", Name: "comp1", Labels: map[string]string{"bar": "foo"}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &v1.Deployment{Spec: v1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v3"}}}}}}}},
|
||||
Spec: v1alpha2.ComponentSpec{Workload: runtime.RawExtension{Object: &appsv1.Deployment{Spec: appsv1.DeploymentSpec{Template: v12.PodTemplateSpec{Spec: v12.PodSpec{Containers: []v12.Container{{Image: "nginx:v3"}}}}}}}},
|
||||
}
|
||||
curComp.Status.DeepCopyInto(&comp4.Status)
|
||||
updateEvt = event.UpdateEvent{
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
|
||||
runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
|
||||
"github.com/crossplane/crossplane-runtime/pkg/test"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
@@ -506,7 +505,7 @@ func TestRenderComponents(t *testing.T) {
|
||||
oam.LabelAppComponentRevision: revisionName,
|
||||
oam.LabelOAMResourceType: oam.ResourceTypeTrait,
|
||||
})
|
||||
workloadRef := runtimev1alpha1.TypedReference{
|
||||
workloadRef := v1alpha1.TypedReference{
|
||||
APIVersion: "traitApiVersion",
|
||||
Kind: "traitKind",
|
||||
Name: componentName,
|
||||
|
||||
Reference in New Issue
Block a user