Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 44 additions & 31 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
# This file contains all available configuration options
# with their default values.

# options for analysis running
version: "2"
run:
# https://github.com/golangci/golangci-lint/issues/2649
# enable go 1.17 linting, will not allow generics
go: "1.17"

# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 1m

# exit code when at least one issue was found, default is 1
go: "1.25"
issues-exit-code: 1

linters:
default: none
enable:
- goconst
- gocyclo
- errcheck
- godox
# all available settings of specific linters
linters-settings:
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false

# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 20
- goprintffuncname
- misspell
- nakedret
- unconvert
- whitespace
settings:
errcheck:
check-type-assertions: false
check-blank: false
gocyclo:
min-complexity: 20
nakedret:
max-func-lines: 0
nonamedreturns:
report-error-in-defer: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- goconst
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
VERSION=v0.2.17
VERSION=v1.0.0

GOLANGCI_LINT_VERSION?= v2.8.0

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down Expand Up @@ -124,9 +126,9 @@ $(OUT_DIR)/$(CLI_NAME).image: $(CLI_SRCS)
@touch $(OUT_DIR)/$(CLI_NAME).image

.PHONY: lint
lint: $(GOBIN)/golangci-lint tidy
lint: build-lint tidy
@echo linting go code...
@golangci-lint run --fix --timeout 10m
@$(GOBIN)/golangci-lint run --fix --timeout 10m

.PHONY: test
test:
Expand All @@ -135,7 +137,7 @@ test:
.PHONY: codegen
codegen: $(GOBIN)/mockgen
rm -f ./docs/commands/*
go generate ./...
PATH="$(GOBIN):$$PATH" go generate ./...
go run ./hack/license.go --license ./hack/boilerplate.txt --year $(YEAR) .

.PHONY: pre-commit
Expand Down Expand Up @@ -171,9 +173,9 @@ check-worktree:

$(GOBIN)/mockgen:
@go install github.com/golang/mock/mockgen@v1.6.0
@mockgen -version
@$(GOBIN)/mockgen -version

$(GOBIN)/golangci-lint:
@mkdir dist || true
.PHONY: build-lint
build-lint:
@echo installing: golangci-lint
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.64.8
@GOBIN=$(GOBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
5 changes: 3 additions & 2 deletions cmd/commands/account.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,8 @@ package commands
import (
"context"
"fmt"
"strings"

"github.com/codefresh-io/cli-v2/internal/kube"
"github.com/codefresh-io/cli-v2/internal/log"
"github.com/codefresh-io/cli-v2/internal/store"
Expand All @@ -27,7 +29,6 @@ import (
"github.com/codefresh-io/go-sdk/pkg/graphql"
platmodel "github.com/codefresh-io/go-sdk/pkg/model/platform"
"github.com/spf13/cobra"
"strings"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/account_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions cmd/commands/cluster.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -396,7 +396,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding annotations: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprint("annotations="+annotationsStr))
k.ConfigMapGenerator[0].LiteralSources = append(k.ConfigMapGenerator[0].LiteralSources, fmt.Sprint("annotations="+annotationsStr))
}

if len(opts.labels) > 0 {
Expand All @@ -405,7 +405,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding labels: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprint("labels="+labelsStr))
k.ConfigMapGenerator[0].LiteralSources = append(k.ConfigMapGenerator[0].LiteralSources, fmt.Sprint("labels="+labelsStr))
}

if opts.tag != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
13 changes: 9 additions & 4 deletions cmd/commands/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,13 +19,14 @@ import (
_ "embed"
"errors"
"fmt"
"github.com/codefresh-io/cli-v2/internal/util/helm"
kubeutil "github.com/codefresh-io/cli-v2/internal/util/kube"
"github.com/codefresh-io/go-sdk/pkg/codefresh"
"os"
"regexp"
"strings"

"github.com/codefresh-io/cli-v2/internal/util/helm"
kubeutil "github.com/codefresh-io/cli-v2/internal/util/kube"
"github.com/codefresh-io/go-sdk/pkg/codefresh"

"github.com/codefresh-io/cli-v2/internal/config"
"github.com/codefresh-io/cli-v2/internal/log"
"github.com/codefresh-io/cli-v2/internal/store"
Expand All @@ -38,6 +39,10 @@ import (
"github.com/spf13/viper"
)

const (
notAvailable = "N/A"
)

var (
die = util.Die
exit = os.Exit
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/completion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
8 changes: 3 additions & 5 deletions cmd/commands/component.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,8 +28,6 @@ import (
"github.com/spf13/cobra"
)

type ()

func newComponentCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "component",
Expand Down Expand Up @@ -112,8 +110,8 @@ func printComponents(w io.Writer, components []platmodel.Component) error {

func printComponent(w io.Writer, c platmodel.Component) error {
name := c.Metadata.Name
healthStatus := "N/A"
syncStatus := "N/A"
healthStatus := notAvailable
syncStatus := notAvailable
version := c.Version

if c.Self != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
8 changes: 4 additions & 4 deletions cmd/commands/git-source.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -247,9 +247,9 @@ func runGitSourceList(ctx context.Context, runtimeName string, includeInternal b
continue
}

repoURL := "N/A"
path := "N/A"
healthStatus := "N/A"
repoURL := notAvailable
path := notAvailable
healthStatus := notAvailable
syncStatus := gs.Self.Status.SyncStatus.String()

if gs.Self.Status.HealthStatus != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/commands/helm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -137,7 +137,7 @@ func runHelmValidate(ctx context.Context, opts *HelmValidateValuesOptions) error
return fmt.Errorf("failed validating git credentials data: %w", err)
}

log.G(ctx).Infof("Successfuly validated helm values file")
log.G(ctx).Infof("Successfully validated helm values file")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/helm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/integrations.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions cmd/commands/pipeline.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -140,7 +140,7 @@ func runPipelineGet(ctx context.Context, name, namespace, runtime string) error
return err
}

healthStatus := "N/A"
healthStatus := notAvailable
if pipeline.Self.HealthStatus != nil {
healthStatus = pipeline.Self.HealthStatus.String()
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func runPipelineList(ctx context.Context, filterArgs platmodel.PipelinesFilterAr
}

for _, p := range pipelines {
healthStatus := "N/A"
healthStatus := notAvailable
if p.Self.HealthStatus != nil {
healthStatus = p.Self.HealthStatus.String()
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/commands/product-release.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -216,16 +216,15 @@ func newProductReleaseListCommand() *cobra.Command {
},
}

cmd.Flags().StringSliceVarP(&statuses, "status", "s", []string{}, "Filter by statuses, comma seperated array RUNNING|SUCCEEDED|SUSPENDED|FAILED")
cmd.Flags().StringSliceVar(&promotionFlows, "promotion-flows", []string{}, "Filter by promotion flows, comma seperated array")
cmd.Flags().StringSliceVarP(&statuses, "status", "s", []string{}, "Filter by statuses, comma separated array RUNNING|SUCCEEDED|SUSPENDED|FAILED")
cmd.Flags().StringSliceVar(&promotionFlows, "promotion-flows", []string{}, "Filter by promotion flows, comma separated array")
cmd.Flags().IntVar(&pageLimit, "page-limit", 20, "page limit number, limited to 50")

return cmd
}

// client here is for mock testings usage
func runProductReleaseList(ctx context.Context, filterArgs platmodel.ProductReleaseFiltersArgs, productName string, pageLimit int) error {

// add pagination - default for now is last 20
filterArgs.ProductNames = []string{productName}
variables := map[string]any{
Expand Down
4 changes: 2 additions & 2 deletions cmd/commands/product-release_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,7 +66,7 @@ func Test_ToProductReleaseStatus(t *testing.T) {
wantErr: "invalid product release status: non-existent",
},
{
name: "should convert to release status when seperated by , with lower cases",
name: "should convert to release status when separated by , with lower cases",
args: args{
statuses: []string{
"running",
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 The Codefresh Authors.
// Copyright 2026 The Codefresh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading