<commit_before>package machine

import (
	"github.com/jeffjen/machine/lib/cert"
	"github.com/jeffjen/machine/lib/ssh"

	"fmt"
)

type Host struct {
	CertPath     string
	Organization string

	User     string
	Cert     string
	IsDocker bool
}

func (h *Host) InstallDockerEngineCertificate(host string, altname ...string) error {
	if !h.IsDocker { // Not processing because not a Docker Engine
		return nil
	}

	var subAltNames = []string{
		host,
		"localhost",
		"127.0.0.1",
	}
	subAltNames = append(subAltNames, altname...)

	fmt.Println(host, "- generate cert for subjects -", subAltNames)

	CA, Cert, Key, err := cert.GenerateServerCertificate(h.CertPath, h.Organization, subAltNames)
	if err != nil {
		return err
	}

	ssh_config := ssh.Config{
		User:   h.User,
		Server: host,
		Key:    h.Cert,
		Port:   "22",
	}
	fmt.Println(host, "- configure docker engine")<commit_msg>NIT: show skipping cert install when not a Docker Engine<commit_after>package machine

import (
	"github.com/jeffjen/machine/lib/cert"
	"github.com/jeffjen/machine/lib/ssh"

	"fmt"
)

type Host struct {
	CertPath     string
	Organization string

	User     string
	Cert     string
	IsDocker bool
}

func (h *Host) InstallDockerEngineCertificate(host string, altname ...string) error {
	if !h.IsDocker { // Not processing because not a Docker Engine
		fmt.Println(host, "- skipping Docker Certificate Install")
		return nil
	}

	var subAltNames = []string{
		host,
		"localhost",
		"127.0.0.1",
	}
	subAltNames = append(subAltNames, altname...)
	fmt.Println(host, "- generate cert for subjects -", subAltNames)

	CA, Cert, Key, err := cert.GenerateServerCertificate(h.CertPath, h.Organization, subAltNames)
	if err != nil {
		return err
	}
	ssh_config := ssh.Config{
		User:   h.User,
		Server: host,
		Key:    h.Cert,
		Port:   "22",
	}
	fmt.Println(host, "- configure docker engine")
{'fraction_non_alphanumeric': 0.1223175965665236, 'fraction_numerical': 0.008583690987124463, 'mean_word_length': 3.5266990291262137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4076855', 'n_tokens_mistral': 697, 'n_tokens_neox': 646, 'n_words': 171}