mirror of https://github.com/kubevela/kubevela.git
				
				
				
			upgrade golang ci lint to 1.38.0 and fix lint error
This commit is contained in:
		
							parent
							
								
									f589471640
								
							
						
					
					
						commit
						1cdcf2ab48
					
				|  | @ -14,7 +14,7 @@ on: | ||||||
| env: | env: | ||||||
|   # Common versions |   # Common versions | ||||||
|   GO_VERSION: '1.14' |   GO_VERSION: '1.14' | ||||||
|   GOLANGCI_VERSION: 'v1.31' |   GOLANGCI_VERSION: 'v1.38' | ||||||
|   DOCKER_BUILDX_VERSION: 'v0.4.2' |   DOCKER_BUILDX_VERSION: 'v0.4.2' | ||||||
|   KIND_VERSION: 'v0.7.0' |   KIND_VERSION: 'v0.7.0' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -113,7 +113,6 @@ linters: | ||||||
|     - govet |     - govet | ||||||
|     - gocyclo |     - gocyclo | ||||||
|     - gocritic |     - gocritic | ||||||
|     - interfacer |  | ||||||
|     - goconst |     - goconst | ||||||
|     - goimports |     - goimports | ||||||
|     - gofmt  # We enable this as well as goimports for its simplify mode. |     - gofmt  # We enable this as well as goimports for its simplify mode. | ||||||
|  |  | ||||||
|  | @ -59,6 +59,7 @@ func (c *CloneSetController) VerifySpec(ctx context.Context) (bool, error) { | ||||||
| 	if verifyErr != nil { | 	if verifyErr != nil { | ||||||
| 		// do not fail the rollout because we can't get the resource
 | 		// do not fail the rollout because we can't get the resource
 | ||||||
| 		c.rolloutStatus.RolloutRetry(verifyErr.Error()) | 		c.rolloutStatus.RolloutRetry(verifyErr.Error()) | ||||||
|  | 		// nolint: nilerr
 | ||||||
| 		return false, nil | 		return false, nil | ||||||
| 	} | 	} | ||||||
| 	// record the size
 | 	// record the size
 | ||||||
|  |  | ||||||
|  | @ -226,6 +226,7 @@ func (h *appHandler) createOrUpdateComponent(ctx context.Context, comp *v1alpha2 | ||||||
| 	checkForRevision := func() (bool, error) { | 	checkForRevision := func() (bool, error) { | ||||||
| 		if err := h.r.Get(ctx, compKey, &curComp); err != nil { | 		if err := h.r.Get(ctx, compKey, &curComp); err != nil { | ||||||
| 			// retry no matter what
 | 			// retry no matter what
 | ||||||
|  | 			// nolint:nilerr
 | ||||||
| 			return false, nil | 			return false, nil | ||||||
| 		} | 		} | ||||||
| 		if curComp.Status.LatestRevision == nil || curComp.Status.LatestRevision.Name == preRevisionName { | 		if curComp.Status.LatestRevision == nil || curComp.Status.LatestRevision.Name == preRevisionName { | ||||||
|  | @ -235,6 +236,7 @@ func (h *appHandler) createOrUpdateComponent(ctx context.Context, comp *v1alpha2 | ||||||
| 			compNameSpace, curComp.Status.LatestRevision.Name, &updatedComp.Spec) | 			compNameSpace, curComp.Status.LatestRevision.Name, &updatedComp.Spec) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			// retry no matter what
 | 			// retry no matter what
 | ||||||
|  | 			// nolint:nilerr
 | ||||||
| 			return false, nil | 			return false, nil | ||||||
| 		} | 		} | ||||||
| 		// end the loop if we find the revision
 | 		// end the loop if we find the revision
 | ||||||
|  |  | ||||||
|  | @ -69,7 +69,7 @@ func (def *CapabilityComponentDefinition) GetCapabilityObject(ctx context.Contex | ||||||
| 	} | 	} | ||||||
| 	err := k8sClient.Get(ctx, objectKey, &componentDefinition) | 	err := k8sClient.Get(ctx, objectKey, &componentDefinition) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, fmt.Errorf("failed to get ComponentDefinition %s: %v", def.Name, err) | 		return nil, fmt.Errorf("failed to get ComponentDefinition %s: %w", def.Name, err) | ||||||
| 	} | 	} | ||||||
| 	def.ComponentDefinition = componentDefinition | 	def.ComponentDefinition = componentDefinition | ||||||
| 	capability, err = util.ConvertTemplateJSON2Object(name, componentDefinition.Spec.Extension, componentDefinition.Spec.Schematic) | 	capability, err = util.ConvertTemplateJSON2Object(name, componentDefinition.Spec.Extension, componentDefinition.Spec.Schematic) | ||||||
|  |  | ||||||
|  | @ -100,7 +100,7 @@ func openPrint(v cue.Value) (string, error) { | ||||||
| 	sysopts := []cue.Option{cue.All(), cue.DisallowCycles(true), cue.ResolveReferences(true), cue.Docs(true)} | 	sysopts := []cue.Option{cue.All(), cue.DisallowCycles(true), cue.ResolveReferences(true), cue.Docs(true)} | ||||||
| 	f, err := sets.ToFile(v.Syntax(sysopts...)) | 	f, err := sets.ToFile(v.Syntax(sysopts...)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", nil | 		return "", err | ||||||
| 	} | 	} | ||||||
| 	for _, decl := range f.Decls { | 	for _, decl := range f.Decls { | ||||||
| 		listOpen(decl) | 		listOpen(decl) | ||||||
|  |  | ||||||
|  | @ -191,7 +191,7 @@ func (o *VelaExecOptions) getPodName(compName string) (string, error) { | ||||||
| 		}).String(), | 		}).String(), | ||||||
| 	}) | 	}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", nil | 		return "", err | ||||||
| 	} | 	} | ||||||
| 	if podList != nil && len(podList.Items) == 0 { | 	if podList != nil && len(podList.Items) == 0 { | ||||||
| 		return "", fmt.Errorf("cannot get pods") | 		return "", fmt.Errorf("cannot get pods") | ||||||
|  |  | ||||||
|  | @ -190,19 +190,19 @@ func generateSideBar(capabilities []types.Capability, docsPath string) error { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	if _, err := f.WriteString("- Workload Types\n"); err != nil { | 	if _, err := f.WriteString("- Workload Types\n"); err != nil { | ||||||
| 		return nil | 		return err | ||||||
| 	} | 	} | ||||||
| 	for _, w := range workloads { | 	for _, w := range workloads { | ||||||
| 		if _, err := f.WriteString(fmt.Sprintf("  - [%s](%s/%s.md)\n", w, plugins.WorkloadTypePath, w)); err != nil { | 		if _, err := f.WriteString(fmt.Sprintf("  - [%s](%s/%s.md)\n", w, plugins.WorkloadTypePath, w)); err != nil { | ||||||
| 			return nil | 			return err | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	if _, err := f.WriteString("- Traits\n"); err != nil { | 	if _, err := f.WriteString("- Traits\n"); err != nil { | ||||||
| 		return nil | 		return err | ||||||
| 	} | 	} | ||||||
| 	for _, t := range traits { | 	for _, t := range traits { | ||||||
| 		if _, err := f.WriteString(fmt.Sprintf("  - [%s](%s/%s.md)\n", t, plugins.TraitPath, t)); err != nil { | 		if _, err := f.WriteString(fmt.Sprintf("  - [%s](%s/%s.md)\n", t, plugins.TraitPath, t)); err != nil { | ||||||
| 			return nil | 			return err | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return nil | 	return nil | ||||||
|  |  | ||||||
|  | @ -112,7 +112,7 @@ func ListApplications(ctx context.Context, c client.Reader, opt Option) ([]apis. | ||||||
| 		} | 		} | ||||||
| 		applicationMeta, err := RetrieveApplicationStatusByName(ctx, c, a.Name, a.Namespace) | 		applicationMeta, err := RetrieveApplicationStatusByName(ctx, c, a.Name, a.Namespace) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return applicationMetaList, nil | 			return applicationMetaList, err | ||||||
| 		} | 		} | ||||||
| 		applicationMeta.Components = nil | 		applicationMeta.Components = nil | ||||||
| 		applicationMetaList = append(applicationMetaList, applicationMeta) | 		applicationMetaList = append(applicationMetaList, applicationMeta) | ||||||
|  |  | ||||||
|  | @ -258,7 +258,7 @@ func (ref *MarkdownReference) CreateMarkdown(caps []types.Capability, baseRefPat | ||||||
| 		} | 		} | ||||||
| 		refContent = title + description + specification + refContent + conflictWithAndMoreSection | 		refContent = title + description + specification + refContent + conflictWithAndMoreSection | ||||||
| 		if _, err := f.WriteString(refContent); err != nil { | 		if _, err := f.WriteString(refContent); err != nil { | ||||||
| 			return nil | 			return err | ||||||
| 		} | 		} | ||||||
| 		if err := f.Close(); err != nil { | 		if err := f.Close(); err != nil { | ||||||
| 			return err | 			return err | ||||||
|  | @ -403,7 +403,7 @@ func (ref *MarkdownReference) generateConflictWithAndMore(capabilityName string, | ||||||
| 	} | 	} | ||||||
| 	data, err := ioutil.ReadFile(filepath.Clean(conflictWithFile)) | 	data, err := ioutil.ReadFile(filepath.Clean(conflictWithFile)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", nil | 		return "", err | ||||||
| 	} | 	} | ||||||
| 	return "\n" + string(data), nil | 	return "\n" + string(data), nil | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue