Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove text.ServiceType abstraction #449

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion pkg/commands/service/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *ListCommand) Exec(in io.Reader, out io.Writer) error {
}
}

tw.AddLine(service.Name, service.ID, text.ServiceType(service.Type), activeVersion, updatedAt)
tw.AddLine(service.Name, service.ID, service.Type, activeVersion, updatedAt)
}
tw.Print()
return nil
Expand Down
16 changes: 2 additions & 14 deletions pkg/text/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ import (
"github.com/segmentio/textio"
)

// ServiceType is a utility function which returns the given type string if
// non-empty otherwise returns the default `vcl`. This should be used until the
// API properly returns Service.Type for non-wasm services.
// TODO(phamann): remove once API returns correct type.
func ServiceType(t string) string {
st := "vcl"
if t != "" {
st = t
}
return st
}

// PrintService pretty prints a fastly.Service structure in verbose format
// to a given io.Writer. Consumers can provide a prefix string which will
// be used as a prefix to each line, useful for indentation.
Expand All @@ -29,7 +17,7 @@ func PrintService(out io.Writer, prefix string, s *fastly.Service) {

fmt.Fprintf(out, "ID: %s\n", s.ID)
fmt.Fprintf(out, "Name: %s\n", s.Name)
fmt.Fprintf(out, "Type: %s\n", ServiceType(s.Type))
fmt.Fprintf(out, "Type: %s\n", s.Type)
if s.Comment != "" {
fmt.Fprintf(out, "Comment: %s\n", s.Comment)
}
Expand Down Expand Up @@ -67,7 +55,7 @@ func PrintServiceDetail(out io.Writer, indent string, s *fastly.ServiceDetail) {

fmt.Fprintf(out, "ID: %s\n", s.ID)
fmt.Fprintf(out, "Name: %s\n", s.Name)
fmt.Fprintf(out, "Type: %s\n", ServiceType(s.Type))
fmt.Fprintf(out, "Type: %s\n", s.Type)
if s.Comment != "" {
fmt.Fprintf(out, "Comment: %s\n", s.Comment)
}
Expand Down
29 changes: 0 additions & 29 deletions pkg/text/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,6 @@ import (
"github.com/fastly/go-fastly/v5/fastly"
)

func TestServiceType(t *testing.T) {
for _, testcase := range []struct {
name string
in string
wantResult string
}{
{
name: "empty",
in: "",
wantResult: "vcl",
},
{
name: "vcl",
in: "vcl",
wantResult: "vcl",
},
{
name: "wasm",
in: "wasm",
wantResult: "wasm",
},
} {
t.Run(testcase.name, func(t *testing.T) {
result := text.ServiceType(testcase.in)
testutil.AssertString(t, testcase.wantResult, result)
})
}
}

func TestPrintService(t *testing.T) {
for _, testcase := range []struct {
name string
Expand Down