~egtann/terrafirma

8b3210192883a482de543cc2d9e0c78e43a29d39 — Evan Tann 4 months ago 5ea0c09 master
fix tests, lint
2 files changed, 6 insertions(+), 5 deletions(-)

M cloud_provider.go
M terrafirma.go
M cloud_provider.go => cloud_provider.go +5 -4
@@ 29,11 29,12 @@ type CloudProvider interface {
type MockCloudProvider struct{ vals []string }

func (m *MockCloudProvider) GetAll(ctx context.Context) ([]*VM, error) {
	const img = "tf-image-s6hkplzzvvp67nv7xsbkdricgskl3lpc"
	m.vals = append(m.vals, "GetAll")
	vm1 := &VM{Name: "tf-vm-box-2", Tags: []string{"a", "box"}}      // Keep
	vm2 := &VM{Name: "tf-vm-box-1", Tags: []string{"a", "c", "box"}} // Delete, no bin
	vm3 := &VM{Name: "tf-vm-box-3", Tags: []string{}}                // Delete, no tag
	vm4 := &VM{Name: "x", Tags: []string{"a"}}                       // Ignore, no prefix
	vm1 := &VM{Name: "tf-vm-box-2", Tags: []string{"a", "box", img}}      // Keep
	vm2 := &VM{Name: "tf-vm-box-1", Tags: []string{"a", "c", "box", img}} // Delete, no bin
	vm3 := &VM{Name: "tf-vm-box-3", Tags: []string{}}                     // Delete, no tag
	vm4 := &VM{Name: "x", Tags: []string{"a"}}                            // Ignore, no prefix
	vms := []*VM{vm1, vm2, vm3, vm4}
	return vms, nil
}

M terrafirma.go => terrafirma.go +1 -1
@@ 404,7 404,7 @@ func (t *Terrafirma) createIP(
func fingerprint(s string) (string, error) {
	h := sha1.New()
	if _, err := io.WriteString(h, s); err != nil {
		return "", fmt.Errorf("write: %w", s)
		return "", fmt.Errorf("write: %s", s)
	}
	enc := base32.StdEncoding.WithPadding(base32.NoPadding)
	return strings.ToLower(enc.EncodeToString(h.Sum(nil))), nil