Skip to content

Commit 94a9aac

Browse files
chore: replace util output local implementation score-go library (#288)
Signed-off-by: lekaf974 <[email protected]> Signed-off-by: Ben Meier <[email protected]> Co-authored-by: Ben Meier <[email protected]>
1 parent fe25903 commit 94a9aac

File tree

3 files changed

+11
-98
lines changed

3 files changed

+11
-98
lines changed

internal/command/provisioners.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/score-spec/score-compose/internal/project"
2727
"github.com/score-spec/score-compose/internal/provisioners"
2828
"github.com/score-spec/score-compose/internal/provisioners/loader"
29-
"github.com/score-spec/score-compose/internal/util"
29+
"github.com/score-spec/score-go/formatter"
3030
)
3131

3232
var (
@@ -72,7 +72,7 @@ func listProvisioners(cmd *cobra.Command, args []string) error {
7272
}
7373

7474
func displayProvisioners(loadedProvisioners []provisioners.Provisioner, outputFormat string) error {
75-
var outputFormatter util.OutputFormatter
75+
var outputFormatter formatter.OutputFormatter
7676
sortedProvisioners := sortProvisionersByType(loadedProvisioners)
7777

7878
switch outputFormat {
@@ -94,15 +94,15 @@ func displayProvisioners(loadedProvisioners []provisioners.Provisioner, outputFo
9494
Description: provisioner.Description(),
9595
})
9696
}
97-
outputFormatter = &util.JSONOutputFormatter[[]jsonData]{Data: outputs}
97+
outputFormatter = &formatter.JSONOutputFormatter[[]jsonData]{Data: outputs}
9898
default:
9999
rows := [][]string{}
100100

101101
for _, provisioner := range sortedProvisioners {
102102
rows = append(rows, []string{provisioner.Type(), provisioner.Class(), strings.Join(provisioner.Params(), ", "), strings.Join(provisioner.Outputs(), ", "), provisioner.Description()})
103103
}
104104
headers := []string{"Type", "Class", "Params", "Outputs", "Description"}
105-
outputFormatter = &util.TableOutputFormatter{
105+
outputFormatter = &formatter.TableOutputFormatter{
106106
Headers: headers,
107107
Rows: rows,
108108
}

internal/command/resources.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222
"text/template"
2323

2424
"github.com/Masterminds/sprig/v3"
25+
"github.com/score-spec/score-go/formatter"
2526
"github.com/score-spec/score-go/framework"
2627
"github.com/spf13/cobra"
2728

2829
"github.com/score-spec/score-compose/internal/project"
29-
"github.com/score-spec/score-compose/internal/util"
3030
)
3131

3232
const (
@@ -122,12 +122,12 @@ func getResourceOutputsKeys(uid framework.ResourceUid, state *project.State) ([]
122122

123123
func displayResourcesOutputs(outputs map[string]interface{}, cmd *cobra.Command) error {
124124
outputFormat := cmd.Flags().Lookup(getOutputsCmdFormatFlag).Value.String()
125-
var outputFormatter util.OutputFormatter
125+
var outputFormatter formatter.OutputFormatter
126126
switch outputFormat {
127127
case "json":
128-
outputFormatter = &util.JSONOutputFormatter[map[string]interface{}]{Data: outputs, Out: cmd.OutOrStdout()}
128+
outputFormatter = &formatter.JSONOutputFormatter[map[string]interface{}]{Data: outputs, Out: cmd.OutOrStdout()}
129129
case "yaml":
130-
outputFormatter = &util.YAMLOutputFormatter[map[string]interface{}]{Data: outputs, Out: cmd.OutOrStdout()}
130+
outputFormatter = &formatter.YAMLOutputFormatter[map[string]interface{}]{Data: outputs, Out: cmd.OutOrStdout()}
131131
default:
132132
// ensure there is a new line at the end if one is not already present
133133
if !strings.HasSuffix(outputFormat, "\n") {
@@ -148,7 +148,7 @@ func displayResourcesOutputs(outputs map[string]interface{}, cmd *cobra.Command)
148148

149149
func displayResourcesList(resources []framework.ResourceUid, state project.State, cmd *cobra.Command) error {
150150
outputFormat := cmd.Flag("format").Value.String()
151-
var outputFormatter util.OutputFormatter
151+
var outputFormatter formatter.OutputFormatter
152152

153153
switch outputFormat {
154154
case "json":
@@ -168,7 +168,7 @@ func displayResourcesList(resources []framework.ResourceUid, state project.State
168168
Outputs: keys,
169169
})
170170
}
171-
outputFormatter = &util.JSONOutputFormatter[[]jsonData]{Data: outputs, Out: cmd.OutOrStdout()}
171+
outputFormatter = &formatter.JSONOutputFormatter[[]jsonData]{Data: outputs, Out: cmd.OutOrStdout()}
172172
default:
173173
var rows [][]string
174174
for _, resource := range resources {
@@ -179,7 +179,7 @@ func displayResourcesList(resources []framework.ResourceUid, state project.State
179179
row := []string{string(resource), strings.Join(keys, ", ")}
180180
rows = append(rows, row)
181181
}
182-
outputFormatter = &util.TableOutputFormatter{
182+
outputFormatter = &formatter.TableOutputFormatter{
183183
Headers: []string{"UID", "Outputs"},
184184
Rows: rows,
185185
Out: cmd.OutOrStdout(),

internal/util/output_format.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)