<commit_before>package kontena

import (
	"fmt"
	"log"

	"github.com/jakubknejzlik/kontena-git-cli/utils"
)

// Master ...
type Master struct {
	name string
	url  string
}

// CurrentMaster ...
func (c *Client) CurrentMaster() Master {

	if c.currentMaster != nil {
		return *c.currentMaster
	}

	var m Master
	res, err := utils.Run("kontena master current")
	if err != nil {
		return m
	}

	masterPair := utils.SplitString(string(res), " ")
	m = Master{masterPair[0], masterPair[1]}

	return m
}

// EnsureMasterLogin ...
func (c *Client) EnsureMasterLogin() error {
	masterURL := utils.Getenv("KONTENA_MASTER_URL", "")

	currentMasterURL := c.CurrentMaster().url

	if masterURL != "" && currentMasterURL != masterURL || currentMasterURL == "" {
		log.Println(currentMasterURL)
		token := utils.GetenvStrict("KONTENA_TOKEN")
		fmt.Println("logging to master", masterURL)
		return c.MasterLogin(masterURL, token)
	}

	// fmt.Println("logged to master", c.CurrentMaster().url)
	return nil
}

// MasterLogin ...
func (c *Client) MasterLogin(masterURL, token string) error {
	return utils.RunInteractive(fmt.Sprintf("kontena master login --skip-grid-auto-select --token %s %s", token, masterURL))
}
<commit_msg>Update master login envvars handling<commit_after>package kontena

import (
	"fmt"

	"github.com/jakubknejzlik/kontena-git-cli/utils"
)

// Master ...
type Master struct {
	name string
	url  string
}

// CurrentMaster ...
func (c *Client) CurrentMaster() Master {

	if c.currentMaster != nil {
		return *c.currentMaster
	}

	var m Master
	res, err := utils.Run("kontena master current")
	if err != nil {
		return m
	}

	masterPair := utils.SplitString(string(res), " ")
	m = Master{masterPair[0], masterPair[1]}

	return m
}

// EnsureMasterLogin ...
func (c *Client) EnsureMasterLogin() error {
	masterURL := utils.Getenv("KONTENA_MASTER_URL", "")

	currentMasterURL := c.CurrentMaster().url

	if masterURL != "" && currentMasterURL != masterURL || currentMasterURL == "" {
		masterURL = utils.GetenvStrict("KONTENA_MASTER_URL")
		token := utils.GetenvStrict("KONTENA_TOKEN")
		fmt.Println("logging to master", masterURL)
		return c.MasterLogin(masterURL, token)
	}

	// fmt.Println("logged to master", c.CurrentMaster().url)
	return nil
}

// MasterLogin ...
func (c *Client) MasterLogin(masterURL, token string) error {
	return utils.RunInteractive(fmt.Sprintf("kontena master login --skip-grid-auto-select --token %s %s", token, masterURL))
}

{'fraction_non_alphanumeric': 0.14786150712830956, 'fraction_numerical': 0.001629327902240326, 'mean_word_length': 4.170526315789473, 'pattern_counts': {'":': 0, '<': 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': '5799144', 'n_tokens_mistral': 858, 'n_tokens_neox': 846, 'n_words': 192}