Skip to content
Open
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
6 changes: 5 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ linters-settings:
disabled: true
- name: exported
disabled: false
goconst:
goconst:
min-len: 2
min-occurrences: 10
match-constant: true
Expand All @@ -39,3 +39,7 @@ issues:
- ^*\.yaml$
- ^*\.yml$
exclude-generated-strict: true
exclude-rules:
- path: extensions/kubeconfig/podlogs.go
linters:
- forbidigo
6 changes: 3 additions & 3 deletions clients/dynamic/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Client struct {
}

// NewForConfig creates a new dynamic client or returns an error.
func NewForConfig(ts *session.Session, inConfig *rest.Config) (dynamic.Interface, error) {
func NewForConfig(ts *session.Session, inConfig *rest.Config) (*Client, error) {
logrus.Debugf("Dynamic Client Host:%s", inConfig.Host)

dynamicClient, err := dynamic.NewForConfig(inConfig)
Expand All @@ -44,7 +44,7 @@ func NewForConfig(ts *session.Session, inConfig *rest.Config) (dynamic.Interface
// Version: "v3",
// Resource: "users",
// }
func (d *Client) Resource(resource schema.GroupVersionResource) dynamic.NamespaceableResourceInterface {
func (d *Client) Resource(resource schema.GroupVersionResource) *NamespaceableResourceClient {
return &NamespaceableResourceClient{
NamespaceableResourceInterface: d.Interface.Resource(resource),
ts: d.ts,
Expand All @@ -59,7 +59,7 @@ type NamespaceableResourceClient struct {
}

// Namespace returns a dynamic.ResourceInterface that is embedded in ResourceClient, so ultimately its Create is overwritten.
func (d *NamespaceableResourceClient) Namespace(s string) dynamic.ResourceInterface {
func (d *NamespaceableResourceClient) Namespace(s string) *ResourceClient {
return &ResourceClient{
ResourceInterface: d.NamespaceableResourceInterface.Namespace(s),
ts: d.ts,
Expand Down
55 changes: 55 additions & 0 deletions clients/helm/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package helm

import (
"fmt"
"os"

"github.com/pkg/errors"
helmAction "helm.sh/helm/v3/pkg/action"
helmCLI "helm.sh/helm/v3/pkg/cli"
)

func InitHelmSettings(kubeconfigPath, kubeContext, namespace string) *helmCLI.EnvSettings {
settings := helmCLI.New()
if kubeconfigPath != "" {
settings.KubeConfig = kubeconfigPath
}
if kubeContext != "" {
settings.KubeContext = kubeContext
}
if namespace != "" {
settings.SetNamespace(namespace)
}
return settings
}

func InitActionConfig(settings *helmCLI.EnvSettings, namespace, helmDriver string) (*helmAction.Configuration, error) {
if namespace == "" {
return nil, errors.New("InitActionConfig: 'namespace' must be a non-zero length string")
}
actionConfig := new(helmAction.Configuration)
if helmDriver == "" {
helmDriver = os.Getenv("HELM_DRIVER")
}

if err := actionConfig.Init(settings.RESTClientGetter(), namespace, helmDriver, func(format string, v ...interface{}) {
_ = fmt.Sprintf(format, v)
}); err != nil {
return nil, err
}
return actionConfig, nil
}

func InitActionConfigWithGetter(getter *RESTClientGetter, namespace, helmDriver string) (*helmAction.Configuration, error) {
actionConfig := new(helmAction.Configuration)
if helmDriver == "" {
helmDriver = os.Getenv("HELM_DRIVER")
}

if err := actionConfig.Init(getter, namespace, helmDriver, func(format string, v ...interface{}) {
_ = fmt.Sprintf(format, v)
}); err != nil {
return nil, err
}
return actionConfig, nil
}
Loading