Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
interfaces - export config.Dash and related interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Wayne Witzel III <wayne@riotousliving.com>
  • Loading branch information
wwitzel3 committed Jul 12, 2021
1 parent 2202608 commit 8c991a6
Show file tree
Hide file tree
Showing 79 changed files with 703 additions and 560 deletions.
2 changes: 1 addition & 1 deletion internal/api/action_request_manager.go
Expand Up @@ -8,11 +8,11 @@ package api
import (
"context"

"github.com/vmware-tanzu/octant/internal/config"
ocontext "github.com/vmware-tanzu/octant/internal/context"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/pkg/action"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/config"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/api/api.go
Expand Up @@ -19,10 +19,10 @@ import (

"github.com/spf13/viper"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/mime"
"github.com/vmware-tanzu/octant/internal/module"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/config"
"github.com/vmware-tanzu/octant/pkg/log"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/api/container_logs.go
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/vmware-tanzu/octant/internal/gvk"
"github.com/vmware-tanzu/octant/pkg/store"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/modules/overview/container"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/pkg/action"
"github.com/vmware-tanzu/octant/pkg/config"
)

type logEntry struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/content_manager.go
Expand Up @@ -16,9 +16,9 @@ import (

"github.com/vmware-tanzu/octant/internal/util/json"

"github.com/vmware-tanzu/octant/internal/config"
ocontext "github.com/vmware-tanzu/octant/internal/context"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/config"
oevent "github.com/vmware-tanzu/octant/pkg/event"

oerrors "github.com/vmware-tanzu/octant/internal/errors"
Expand Down
2 changes: 1 addition & 1 deletion internal/api/context_manager.go
Expand Up @@ -16,10 +16,10 @@ import (

"github.com/pkg/errors"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/event"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/pkg/action"
"github.com/vmware-tanzu/octant/pkg/config"
)

// ContextManagerOption is an option for configuring ContextManager.
Expand Down
2 changes: 1 addition & 1 deletion internal/api/helper_manager.go
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/vmware-tanzu/octant/pkg/api"
oevent "github.com/vmware-tanzu/octant/pkg/event"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/event"
"github.com/vmware-tanzu/octant/internal/log"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/pkg/config"
)

// HelperStateManagerOption is an option for configuration HelperManager
Expand Down
2 changes: 1 addition & 1 deletion internal/api/namespaces_manager.go
Expand Up @@ -13,11 +13,11 @@ import (

"github.com/pkg/errors"

"github.com/vmware-tanzu/octant/internal/cluster"
"github.com/vmware-tanzu/octant/internal/event"
"github.com/vmware-tanzu/octant/internal/log"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/cluster"
oevent "github.com/vmware-tanzu/octant/pkg/event"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/api/streaming_service.go
Expand Up @@ -9,8 +9,8 @@ import (
"fmt"
"net/http"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/config"
)

func streamService(manager api.ClientManager, dashConfig config.Dash) http.HandlerFunc {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/terminal_manager.go
Expand Up @@ -20,12 +20,12 @@ import (

"github.com/pkg/errors"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/gvk"
"github.com/vmware-tanzu/octant/internal/log"
"github.com/vmware-tanzu/octant/internal/octant"
"github.com/vmware-tanzu/octant/internal/terminal"
"github.com/vmware-tanzu/octant/pkg/action"
"github.com/vmware-tanzu/octant/pkg/config"
"github.com/vmware-tanzu/octant/pkg/store"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/api/websocket_service_test.go
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"testing"

"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/pkg/api"
"github.com/vmware-tanzu/octant/pkg/config"
)

type fakeWebsocketClientManager struct {
Expand Down
36 changes: 5 additions & 31 deletions internal/cluster/cluster.go
Expand Up @@ -39,7 +39,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
)

//go:generate mockgen -source=cluster.go -destination=./fake/mock_client_interface.go -package=fake github.com/vmware-tanzu/octant/internal/cluster ClientInterface
//go:generate mockgen -source=../../pkg/cluster/client.go -destination=./fake/mock_client_interface.go -package=fake github.com/vmware-tanzu/octant/pkg/cluster ClientInterface
//go:generate mockgen -source=../../pkg/cluster/namespace.go -destination=./fake/mock_namespace_interface.go -package=fake github.com/vmware-tanzu/octant/pkg/cluster NamespaceInterface
//go:generate mockgen -source=../../pkg/cluster/info.go -destination=./fake/mock_info_interface.go -package=fake github.com/vmware-tanzu/octant/pkg/cluster InfoInterface
//go:generate mockgen -source=../../vendor/k8s.io/client-go/informers/generic.go -destination=./fake/mock_genericinformer.go -package=fake k8s.io/client-go/informers GenericInformer
Expand All @@ -50,26 +50,6 @@ import (
//go:generate mockgen -destination=./fake/mock_authorization.go -package=fake k8s.io/client-go/kubernetes/typed/authorization/v1 AuthorizationV1Interface,SelfSubjectAccessReviewInterface,SelfSubjectAccessReviewsGetter,SelfSubjectRulesReviewInterface,SelfSubjectRulesReviewsGetter
//go:generate mockgen -source=../../vendor/k8s.io/client-go/dynamic/interface.go -destination=./fake/mock_dynamic_client.go -package=fake -imports=github.com/vmware-tanzu/octant/vendor/k8s.io/client-go/dynamic=k8s.io/client-go/dynamic -mock_names=Interface=MockDynamicInterface k8s.io/client-go/dynamic Interface

// ClientInterface is a client for cluster operations.
type ClientInterface interface {
DefaultNamespace() string
ResourceExists(schema.GroupVersionResource) bool
Resource(schema.GroupKind) (schema.GroupVersionResource, bool, error)
ResetMapper()
KubernetesClient() (kubernetes.Interface, error)
DynamicClient() (dynamic.Interface, error)
DiscoveryClient() (discovery.DiscoveryInterface, error)
NamespaceClient() (clusterTypes.NamespaceInterface, error)
InfoClient() (clusterTypes.InfoInterface, error)
Close()
RESTInterface
}

type RESTInterface interface {
RESTClient() (rest.Interface, error)
RESTConfig() *rest.Config
}

// Cluster is a client for cluster operations
type Cluster struct {
clientConfig clientcmd.ClientConfig
Expand All @@ -88,7 +68,7 @@ type Cluster struct {
providedNamespaces []string
}

var _ ClientInterface = (*Cluster)(nil)
var _ clusterTypes.ClientInterface = (*Cluster)(nil)

func newCluster(ctx context.Context, clientConfig clientcmd.ClientConfig, restClient *rest.Config, defaultNamespace string, providedNamespaces []string) (*Cluster, error) {
logger := internalLog.From(ctx).With("component", "cluster client")
Expand Down Expand Up @@ -246,7 +226,7 @@ func (c *Cluster) Version() (string, error) {
type clusterOptions struct {
InitialNamespace string
ProvidedNamespaces []string
RESTConfigOptions RESTConfigOptions
RESTConfigOptions clusterTypes.RESTConfigOptions
}

type ClusterOption func(*clusterOptions)
Expand Down Expand Up @@ -281,7 +261,7 @@ func WithClientUserAgent(userAgent string) ClusterOption {
}
}

func WithRESTConfigOptions(restConfigOptions RESTConfigOptions) ClusterOption {
func WithRESTConfigOptions(restConfigOptions clusterTypes.RESTConfigOptions) ClusterOption {
return func(clusterOptions *clusterOptions) {
clusterOptions.RESTConfigOptions = restConfigOptions
}
Expand Down Expand Up @@ -326,7 +306,7 @@ func FromClientConfig(

// withConfigDefaults returns an extended rest.Config object with additional defaults applied
// See core_client.go#setConfigDefaults
func withConfigDefaults(inConfig *rest.Config, options RESTConfigOptions) *rest.Config {
func withConfigDefaults(inConfig *rest.Config, options clusterTypes.RESTConfigOptions) *rest.Config {
config := rest.CopyConfig(inConfig)
config.QPS = options.QPS
config.Burst = options.Burst
Expand All @@ -344,9 +324,3 @@ func withConfigDefaults(inConfig *rest.Config, options RESTConfigOptions) *rest.

return config
}

type RESTConfigOptions struct {
QPS float32
Burst int
UserAgent string
}
2 changes: 1 addition & 1 deletion internal/cluster/fake/mock_client_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions internal/commands/dash.go
Expand Up @@ -20,9 +20,8 @@ import (
"k8s.io/klog"

"github.com/vmware-tanzu/octant/internal/api"
"github.com/vmware-tanzu/octant/internal/config"
"github.com/vmware-tanzu/octant/internal/log"
pconfig "github.com/vmware-tanzu/octant/pkg/config"
"github.com/vmware-tanzu/octant/pkg/config"
"github.com/vmware-tanzu/octant/pkg/dash"
)

Expand Down Expand Up @@ -161,7 +160,7 @@ func newOctantCmd(version string, gitCommit string, buildTime string) *cobra.Com
octantCmd.Flags().StringSlice("namespace-list", []string{}, "a list of namespaces to use on start")
octantCmd.Flags().StringP("plugin-path", "", "", "plugin path")
octantCmd.Flags().BoolP("verbose", "v", false, "turn on debug logging")
octantCmd.Flags().IntP("client-max-recv-msg-size", "", pconfig.MaxMessageSize, "client max receiver message size")
octantCmd.Flags().IntP("client-max-recv-msg-size", "", config.MaxMessageSize, "client max receiver message size")

octantCmd.Flags().StringP("accepted-hosts", "", "", "accepted hosts list [DEV]")
octantCmd.Flags().Float32P("client-qps", "", 200, "maximum QPS for client [DEV]")
Expand Down

0 comments on commit 8c991a6

Please sign in to comment.