Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #827 from kinvolk/invidian/terraform-simplification
Browse files Browse the repository at this point in the history
pkg/terraform: remove OutputBytes
  • Loading branch information
invidian authored Aug 23, 2020
2 parents c7308aa + e6efa3f commit a175b37
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
10 changes: 2 additions & 8 deletions pkg/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package dns

import (
"bufio"
"encoding/json"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -107,15 +106,10 @@ func (c *Config) ManualConfigPrompt() terraform.ExecutionHook {
}

func readDNSEntries(ex *terraform.Executor) ([]dnsEntry, error) {
output, err := ex.OutputBytes("dns_entries")
if err != nil {
return nil, errors.Wrap(err, "failed to get DNS entries")
}

var entries []dnsEntry

if err := json.Unmarshal(output, &entries); err != nil {
return nil, errors.Wrap(err, "failed to parse DNS entries file")
if err := ex.Output("dns_entries", &entries); err != nil {
return nil, errors.Wrap(err, "failed to get DNS entries")
}

return entries, nil
Expand Down
10 changes: 0 additions & 10 deletions pkg/terraform/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,6 @@ func (ex *Executor) Output(key string, s interface{}) error {
return json.Unmarshal(o, s)
}

// OutputBytes returns the value of the Terraform output key in JSON format as a byte slice.
func (ex *Executor) OutputBytes(key string) ([]byte, error) {
o, err := ex.executeSync("output", "-json", key)
if err != nil {
return []byte{}, fmt.Errorf("getting Terraform output for key %q: %w", key, err)
}

return o, nil
}

// GenerateCommand prepares a Terraform command with the given arguments
// by setting up the command, configuration, working directory
// (so the files such as terraform.tfstate are stored at the right place) and
Expand Down

0 comments on commit a175b37

Please sign in to comment.