<commit_before>package commands

import (
	"encoding/base64"
	"fmt"
	"strings"

	docker "github.com/fsouza/go-dockerclient"
	"github.com/treeder/operator/common"
	"golang.org/x/net/context"
)

func Pull(ctx context.Context, image, username, password string) error {
	ctx, log := common.LoggerWithFields(ctx, map[string]interface{}{
		"command": "pull",
	})

	endpoint := "unix:///var/run/docker.sock"
	client, err := docker.NewClient(endpoint)
	if err != nil {
		log.WithError(err).Fatalln("Error making docker client!")
		return err
	}

	repo, tag := docker.ParseRepositoryTag(image)
	log.Infoln("username:", username, "password:", password, "image:", image, "repo:", repo, "tag:", tag)

	auth := ""
	if username != "" {
		auth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
	}

	authConfig := docker.AuthConfiguration{}
	if auth != "" {
		read := strings.NewReader(fmt.Sprintf(`{"docker.io":{"auth":"%s"}}`, auth))
		ac, err := docker.NewAuthConfigurations(read)
		if err != nil {
			log.WithError(err).Errorln("error with new auth config")
			return err
		}
		authConfig = ac.Configs["docker.io"]
	}

	err = client.PullImage(docker.PullImageOptions{Repository: repo, Tag: tag}, authConfig)
	if err != nil {
		log.WithError(err).Errorln("error pulling image")
		return err
	}
	return nil
}<commit_msg>Removed secret from log line.<commit_after>package commands

import (
	"encoding/base64"
	"fmt"
	"strings"

	docker "github.com/fsouza/go-dockerclient"
	"github.com/treeder/operator/common"
	"golang.org/x/net/context"
)

func Pull(ctx context.Context, image, username, password string) error {
	ctx, log := common.LoggerWithFields(ctx, map[string]interface{}{
		"command": "pull",
	})

	endpoint := "unix:///var/run/docker.sock"
	client, err := docker.NewClient(endpoint)
	if err != nil {
		log.WithError(err).Fatalln("Error making docker client!")
		return err
	}

	repo, tag := docker.ParseRepositoryTag(image)
	log.Infoln("username:", username, "image:", image, "repo:", repo, "tag:", tag)

	auth := ""
	if username != "" {
		auth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
	}

	authConfig := docker.AuthConfiguration{}
	if auth != "" {
		read := strings.NewReader(fmt.Sprintf(`{"docker.io":{"auth":"%s"}}`, auth))
		ac, err := docker.NewAuthConfigurations(read)
		if err != nil {
			log.WithError(err).Errorln("error with new auth config")
			return err
		}
		authConfig = ac.Configs["docker.io"]
	}

	err = client.PullImage(docker.PullImageOptions{Repository: repo, Tag: tag}, authConfig)
	if err != nil {
		log.WithError(err).Errorln("error pulling image")
		return err
	}
	return nil
}
{'fraction_non_alphanumeric': 0.1707593502077824, 'fraction_numerical': 0.003022289384208538, 'mean_word_length': 4.6581196581196584, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6388964', 'n_tokens_mistral': 969, 'n_tokens_neox': 887, 'n_words': 192}