mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
Add gocritic to linters
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
923e01d151
commit
2e96829607
@ -7,6 +7,7 @@ linters:
|
||||
- deadcode
|
||||
- depguard
|
||||
- errcheck
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- goimports
|
||||
|
@ -16,9 +16,11 @@
|
||||
# limitations under the License.
|
||||
|
||||
ARG GO_VERSION=1.18.4-alpine
|
||||
ARG GOLANGCI_LINT_VERSION=v1.40.1-alpine
|
||||
ARG GOLANGCI_LINT_VERSION=v1.46.2-alpine
|
||||
ARG PROTOC_GEN_GO_VERSION=v1.4.3
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS local-golangci-lint
|
||||
|
||||
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
|
||||
WORKDIR /compose-cli
|
||||
RUN apk add --no-cache -vv \
|
||||
@ -34,7 +36,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
|
||||
FROM base AS lint
|
||||
ENV CGO_ENABLED=0
|
||||
COPY --from=golangci/golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
|
||||
COPY --from=local-golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
|
||||
ARG BUILD_TAGS
|
||||
ARG GIT_TAG
|
||||
RUN --mount=target=. \
|
||||
|
@ -69,8 +69,7 @@ func downCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
||||
flags.BoolVarP(&opts.volumes, "volumes", "v", false, " Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.")
|
||||
flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`)
|
||||
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
switch name {
|
||||
case "volume":
|
||||
if name == "volume" {
|
||||
name = "volumes"
|
||||
logrus.Warn("--volume is deprecated, please use --volumes")
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
//ExitCodeLoginRequired exit code when command cannot execute because it requires cloud login
|
||||
// ExitCodeLoginRequired exit code when command cannot execute because it requires cloud login
|
||||
// This will be used by VSCode to detect when creating context if the user needs to login first
|
||||
ExitCodeLoginRequired = 5
|
||||
)
|
||||
|
@ -106,9 +106,9 @@ func combinedStatus(statuses []string) string {
|
||||
for _, status := range keys {
|
||||
nb := nbByStatus[status]
|
||||
if result != "" {
|
||||
result = result + ", "
|
||||
result += ", "
|
||||
}
|
||||
result = result + fmt.Sprintf("%s(%d)", status, nb)
|
||||
result += fmt.Sprintf("%s(%d)", status, nb)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -50,13 +50,13 @@ var (
|
||||
ComposeParseFailure = FailureCategory{MetricsStatus: ComposeParseFailureStatus, ExitCode: 15}
|
||||
// CommandSyntaxFailure failure for command line syntax
|
||||
CommandSyntaxFailure = FailureCategory{MetricsStatus: CommandSyntaxFailureStatus, ExitCode: 16}
|
||||
//BuildFailure failure while building images.
|
||||
// BuildFailure failure while building images.
|
||||
BuildFailure = FailureCategory{MetricsStatus: BuildFailureStatus, ExitCode: 17}
|
||||
// PullFailure failure while pulling image
|
||||
PullFailure = FailureCategory{MetricsStatus: PullFailureStatus, ExitCode: 18}
|
||||
)
|
||||
|
||||
//ByExitCode retrieve FailureCategory based on command exit code
|
||||
// ByExitCode retrieve FailureCategory based on command exit code
|
||||
func ByExitCode(exitCode int) FailureCategory {
|
||||
switch exitCode {
|
||||
case 0:
|
||||
|
@ -46,13 +46,16 @@ var (
|
||||
|
||||
// DockerScanExecutableName is the OS dependent Docker CLI binary name
|
||||
DockerScanExecutableName = "docker-scan"
|
||||
|
||||
// WindowsExecutableSuffix is the Windows executable suffix
|
||||
WindowsExecutableSuffix = ".exe"
|
||||
)
|
||||
|
||||
func init() {
|
||||
if runtime.GOOS == "windows" {
|
||||
DockerExecutableName = DockerExecutableName + ".exe"
|
||||
DockerComposeExecutableName = DockerComposeExecutableName + ".exe"
|
||||
DockerScanExecutableName = DockerScanExecutableName + ".exe"
|
||||
DockerExecutableName += WindowsExecutableSuffix
|
||||
DockerComposeExecutableName += WindowsExecutableSuffix
|
||||
DockerScanExecutableName += WindowsExecutableSuffix
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,99 +44,99 @@ type Event struct {
|
||||
}
|
||||
|
||||
// ErrorMessageEvent creates a new Error Event with message
|
||||
func ErrorMessageEvent(ID string, msg string) Event {
|
||||
return NewEvent(ID, Error, msg)
|
||||
func ErrorMessageEvent(id string, msg string) Event {
|
||||
return NewEvent(id, Error, msg)
|
||||
}
|
||||
|
||||
// ErrorEvent creates a new Error Event
|
||||
func ErrorEvent(ID string) Event {
|
||||
return NewEvent(ID, Error, "Error")
|
||||
func ErrorEvent(id string) Event {
|
||||
return NewEvent(id, Error, "Error")
|
||||
}
|
||||
|
||||
// CreatingEvent creates a new Create in progress Event
|
||||
func CreatingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Creating")
|
||||
func CreatingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Creating")
|
||||
}
|
||||
|
||||
// StartingEvent creates a new Starting in progress Event
|
||||
func StartingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Starting")
|
||||
func StartingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Starting")
|
||||
}
|
||||
|
||||
// StartedEvent creates a new Started in progress Event
|
||||
func StartedEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Started")
|
||||
func StartedEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Started")
|
||||
}
|
||||
|
||||
// Waiting creates a new waiting event
|
||||
func Waiting(ID string) Event {
|
||||
return NewEvent(ID, Working, "Waiting")
|
||||
func Waiting(id string) Event {
|
||||
return NewEvent(id, Working, "Waiting")
|
||||
}
|
||||
|
||||
// Healthy creates a new healthy event
|
||||
func Healthy(ID string) Event {
|
||||
return NewEvent(ID, Done, "Healthy")
|
||||
func Healthy(id string) Event {
|
||||
return NewEvent(id, Done, "Healthy")
|
||||
}
|
||||
|
||||
// Exited creates a new exited event
|
||||
func Exited(ID string) Event {
|
||||
return NewEvent(ID, Done, "Exited")
|
||||
func Exited(id string) Event {
|
||||
return NewEvent(id, Done, "Exited")
|
||||
}
|
||||
|
||||
// RestartingEvent creates a new Restarting in progress Event
|
||||
func RestartingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Restarting")
|
||||
func RestartingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Restarting")
|
||||
}
|
||||
|
||||
// RestartedEvent creates a new Restarted in progress Event
|
||||
func RestartedEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Restarted")
|
||||
func RestartedEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Restarted")
|
||||
}
|
||||
|
||||
// RunningEvent creates a new Running in progress Event
|
||||
func RunningEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Running")
|
||||
func RunningEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Running")
|
||||
}
|
||||
|
||||
// CreatedEvent creates a new Created (done) Event
|
||||
func CreatedEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Created")
|
||||
func CreatedEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Created")
|
||||
}
|
||||
|
||||
// StoppingEvent creates a new Stopping in progress Event
|
||||
func StoppingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Stopping")
|
||||
func StoppingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Stopping")
|
||||
}
|
||||
|
||||
// StoppedEvent creates a new Stopping in progress Event
|
||||
func StoppedEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Stopped")
|
||||
func StoppedEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Stopped")
|
||||
}
|
||||
|
||||
// KillingEvent creates a new Killing in progress Event
|
||||
func KillingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Killing")
|
||||
func KillingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Killing")
|
||||
}
|
||||
|
||||
// KilledEvent creates a new Killed in progress Event
|
||||
func KilledEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Killed")
|
||||
func KilledEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Killed")
|
||||
}
|
||||
|
||||
// RemovingEvent creates a new Removing in progress Event
|
||||
func RemovingEvent(ID string) Event {
|
||||
return NewEvent(ID, Working, "Removing")
|
||||
func RemovingEvent(id string) Event {
|
||||
return NewEvent(id, Working, "Removing")
|
||||
}
|
||||
|
||||
// RemovedEvent creates a new removed (done) Event
|
||||
func RemovedEvent(ID string) Event {
|
||||
return NewEvent(ID, Done, "Removed")
|
||||
func RemovedEvent(id string) Event {
|
||||
return NewEvent(id, Done, "Removed")
|
||||
}
|
||||
|
||||
// NewEvent new event
|
||||
func NewEvent(ID string, status EventStatus, statusText string) Event {
|
||||
func NewEvent(id string, status EventStatus, statusText string) Event {
|
||||
return Event{
|
||||
ID: ID,
|
||||
ID: id,
|
||||
Status: status,
|
||||
StatusText: statusText,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user