cspell lint go code (#3706)

This commit is contained in:
6543
2024-05-24 22:35:04 +02:00
committed by GitHub
parent 4628a97c93
commit 42f2734308
44 changed files with 214 additions and 161 deletions

View File

@@ -25,10 +25,10 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/volume"
"github.com/docker/go-connections/tlsconfig"
tls_config "github.com/docker/go-connections/tlsconfig"
"github.com/moby/moby/client"
"github.com/moby/moby/pkg/jsonmessage"
"github.com/moby/moby/pkg/stdcopy"
json_message "github.com/moby/moby/pkg/jsonmessage"
std_copy "github.com/moby/moby/pkg/stdcopy"
"github.com/moby/term"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
@@ -75,13 +75,13 @@ func httpClientOfOpts(dockerCertPath string, verifyTLS bool) *http.Client {
return nil
}
options := tlsconfig.Options{
options := tls_config.Options{
CAFile: filepath.Join(dockerCertPath, "ca.pem"),
CertFile: filepath.Join(dockerCertPath, "cert.pem"),
KeyFile: filepath.Join(dockerCertPath, "key.pem"),
InsecureSkipVerify: !verifyTLS,
}
tlsConf, err := tlsconfig.Client(options)
tlsConf, err := tls_config.Client(options)
if err != nil {
log.Error().Err(err).Msg("could not create http client out of docker backend options")
return nil
@@ -188,27 +188,27 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
containerName := toContainerName(step)
// create pull options with encoded authorization credentials.
pullopts := types.ImagePullOptions{}
pullOpts := types.ImagePullOptions{}
if step.AuthConfig.Username != "" && step.AuthConfig.Password != "" {
pullopts.RegistryAuth, _ = encodeAuthToBase64(step.AuthConfig)
pullOpts.RegistryAuth, _ = encodeAuthToBase64(step.AuthConfig)
}
// automatically pull the latest version of the image if requested
// by the process configuration.
if step.Pull {
responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts)
if perr == nil {
responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts)
if pErr == nil {
// TODO(1936): show image pull progress in web-ui
fd, isTerminal := term.GetFdInfo(os.Stdout)
if err := jsonmessage.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil {
if err := json_message.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil {
log.Error().Err(err).Msg("DisplayJSONMessagesStream")
}
responseBody.Close()
}
// Fix "Show warning when fail to auth to docker registry"
// (https://web.archive.org/web/20201023145804/https://github.com/drone/drone/issues/1917)
if perr != nil && step.AuthConfig.Password != "" {
return perr
if pErr != nil && step.AuthConfig.Password != "" {
return pErr
}
}
@@ -219,13 +219,13 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
if client.IsErrNotFound(err) {
// automatically pull and try to re-create the image if the
// failure is caused because the image does not exist.
responseBody, perr := e.client.ImagePull(ctx, config.Image, pullopts)
if perr != nil {
return perr
responseBody, pErr := e.client.ImagePull(ctx, config.Image, pullOpts)
if pErr != nil {
return pErr
}
// TODO(1936): show image pull progress in web-ui
fd, isTerminal := term.GetFdInfo(os.Stdout)
if err := jsonmessage.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil {
if err := json_message.DisplayJSONMessagesStream(responseBody, os.Stdout, fd, isTerminal, nil); err != nil {
log.Error().Err(err).Msg("DisplayJSONMessagesStream")
}
responseBody.Close()
@@ -263,10 +263,10 @@ func (e *docker) WaitStep(ctx context.Context, step *backend.Step, taskUUID stri
containerName := toContainerName(step)
wait, errc := e.client.ContainerWait(ctx, containerName, "")
wait, errC := e.client.ContainerWait(ctx, containerName, "")
select {
case <-wait:
case <-errc:
case <-errC:
}
info, err := e.client.ContainerInspect(ctx, containerName)
@@ -292,7 +292,7 @@ func (e *docker) TailStep(ctx context.Context, step *backend.Step, taskUUID stri
// de multiplex 'logs' who contains two streams, previously multiplexed together using StdWriter
go func() {
_, _ = stdcopy.StdCopy(wc, wc, logs)
_, _ = std_copy.StdCopy(wc, wc, logs)
_ = logs.Close()
_ = wc.Close()
}()