Skip to content

Commit

Permalink
Change pkg/command/cf path to internal/command path
Browse files Browse the repository at this point in the history
We don't expect any of these commands to be used externally to this cf
CLI plugin, so there's no point in exporting them. Moving them behind
internal makes them only available to our main package.
  • Loading branch information
ctlong committed Feb 25, 2022
1 parent 4f3ad86 commit d4498ce
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 27 deletions.
23 changes: 23 additions & 0 deletions internal/command/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package command

import (
"context"
"io"
"net/http"

"code.cloudfoundry.org/cli/plugin"
)

// Command is the interface to implement plugin commands
type Command func(ctx context.Context, cli plugin.CliConnection, args []string, c HTTPClient, log Logger, w io.Writer)

// Logger is used for outputting log-cache results and errors
type Logger interface {
Fatalf(format string, args ...interface{})
Printf(format string, args ...interface{})
}

// HTTPClient is the client used for HTTP requests
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf_test
package command_test

import (
"errors"
Expand All @@ -9,7 +9,7 @@ import (
"sync"

"code.cloudfoundry.org/cli/plugin"
"code.cloudfoundry.org/cli/plugin/models"
plugin_models "code.cloudfoundry.org/cli/plugin/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf
package command

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/cf/meta.go → internal/command/meta.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf
package command

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions pkg/command/cf/meta_test.go → internal/command/meta_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf_test
package command_test

import (
"bytes"
Expand All @@ -9,7 +9,7 @@ import (
"os"
"strings"

"code.cloudfoundry.org/log-cache-cli/v4/pkg/command/cf"
cf "code.cloudfoundry.org/log-cache-cli/v4/internal/command"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/cf/query.go → internal/command/query.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf
package command

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cf_test
package command_test

import (
"context"
"fmt"
"net/url"

"code.cloudfoundry.org/log-cache-cli/v4/pkg/command/cf"
cf "code.cloudfoundry.org/log-cache-cli/v4/internal/command"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
16 changes: 1 addition & 15 deletions pkg/command/cf/tail.go → internal/command/tail.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf
package command

import (
"context"
Expand All @@ -25,20 +25,6 @@ const (
timeFormat = "2006-01-02T15:04:05.00-0700"
)

// Command is the interface to implement plugin commands
type Command func(ctx context.Context, cli plugin.CliConnection, args []string, c HTTPClient, log Logger, w io.Writer)

// Logger is used for outputting log-cache results and errors
type Logger interface {
Fatalf(format string, args ...interface{})
Printf(format string, args ...interface{})
}

// HTTPClient is the client used for HTTP requests
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}

type TailOption func(*tailOptions)

func WithTailNoHeaders() TailOption {
Expand Down
4 changes: 2 additions & 2 deletions pkg/command/cf/tail_test.go → internal/command/tail_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cf_test
package command_test

import (
"context"
Expand All @@ -10,7 +10,7 @@ import (
"strconv"
"time"

"code.cloudfoundry.org/log-cache-cli/v4/pkg/command/cf"
cf "code.cloudfoundry.org/log-cache-cli/v4/internal/command"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"

"code.cloudfoundry.org/cli/plugin"
"code.cloudfoundry.org/log-cache-cli/v4/pkg/command/cf"
cf "code.cloudfoundry.org/log-cache-cli/v4/internal/command"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down

0 comments on commit d4498ce

Please sign in to comment.