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

pkg/terraform: remove OutputBytes #827

Merged
merged 2 commits into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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