Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Nov 16, 2023
1 parent fb6dba8 commit 796ed48
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 89 deletions.
15 changes: 8 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ require (
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/mitchellh/go-homedir v1.1.0
github.com/pluralsh/console-client-go v0.0.36
github.com/pluralsh/plural-cli v0.8.1-0.20231114161007-183eafb99b03
github.com/pluralsh/polly v0.1.1
github.com/samber/lo v1.38.1
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
)

require (
Expand Down Expand Up @@ -124,6 +129,7 @@ require (
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-github/v45 v45.2.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand Down Expand Up @@ -199,7 +205,6 @@ require (
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand Down Expand Up @@ -227,7 +232,6 @@ require (
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pluralsh/gqlclient v1.11.0 // indirect
github.com/pluralsh/polly v0.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.4.5 // indirect
github.com/posener/complete v1.2.3 // indirect
Expand All @@ -245,7 +249,6 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryancurrah/gomodguard v1.3.0 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
github.com/samber/lo v1.38.1 // indirect
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.24.0 // indirect
Expand Down Expand Up @@ -326,16 +329,14 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
helm.sh/helm/v3 v3.11.2 // indirect
honnef.co/go/tools v0.4.6 // indirect
k8s.io/api v0.26.4 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apimachinery v0.26.4 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/cli-runtime v0.26.1 // indirect
k8s.io/client-go v0.26.4 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/helm v2.17.0+incompatible // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230601164746-7562a1006961 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/kubectl v0.26.1 // indirect
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
mvdan.cc/gofumpt v0.5.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0=
github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down Expand Up @@ -485,8 +487,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
Expand Down Expand Up @@ -855,8 +857,6 @@ github.com/pluralsh/console-client-go v0.0.36 h1:yjABMAgkRu0nI5QtmM/rO+rvXvLUAoV
github.com/pluralsh/console-client-go v0.0.36/go.mod h1:kZjk0pXAWnvyj+miXveCho4kKQaX1Tm3CGAM+iwurWU=
github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA=
github.com/pluralsh/gqlclient v1.11.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I=
github.com/pluralsh/plural-cli v0.8.1-0.20231114145714-860fa85f7e63 h1:1IWFJ6th8IMzSTND6RkmK/iYiOodtU3hXVs9X6nFWOQ=
github.com/pluralsh/plural-cli v0.8.1-0.20231114145714-860fa85f7e63/go.mod h1:Cj5ZD6kf9OLd+333rdkUVvqFxcnKOecLxoy+nx8h22g=
github.com/pluralsh/plural-cli v0.8.1-0.20231114161007-183eafb99b03 h1:toUJzv4+4SYGsw8kvrx2oQxrmKu8XYirrNmNyxx9NHk=
github.com/pluralsh/plural-cli v0.8.1-0.20231114161007-183eafb99b03/go.mod h1:Cj5ZD6kf9OLd+333rdkUVvqFxcnKOecLxoy+nx8h22g=
github.com/pluralsh/polly v0.1.1 h1:VtbS83re2YuDgscvaFgfzEDZs9uXRV84fCdvKCgIRE4=
Expand Down Expand Up @@ -1647,18 +1647,18 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.4.6 h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
honnef.co/go/tools v0.4.6/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0=
k8s.io/api v0.26.4 h1:qSG2PmtcD23BkYiWfoYAcak870eF/hE7NNYBYavTT94=
k8s.io/api v0.26.4/go.mod h1:WwKEXU3R1rgCZ77AYa7DFksd9/BAIKyOmRlbVxgvjCk=
k8s.io/api v0.28.3 h1:Gj1HtbSdB4P08C8rs9AR94MfSGpRhJgsS+GF9V26xMM=
k8s.io/api v0.28.3/go.mod h1:MRCV/jr1dW87/qJnZ57U5Pak65LGmQVkKTzf3AtKFHc=
k8s.io/apiextensions-apiserver v0.26.1 h1:cB8h1SRk6e/+i3NOrQgSFij1B2S0Y0wDoNl66bn8RMI=
k8s.io/apiextensions-apiserver v0.26.1/go.mod h1:AptjOSXDGuE0JICx/Em15PaoO7buLwTs0dGleIHixSM=
k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs=
k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A=
k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8=
k8s.io/apiserver v0.26.1 h1:6vmnAqCDO194SVCPU3MU8NcDgSqsUA62tBUSWrFXhsc=
k8s.io/apiserver v0.26.1/go.mod h1:wr75z634Cv+sifswE9HlAo5FQ7UoUauIICRlOE+5dCg=
k8s.io/cli-runtime v0.26.3 h1:3ULe0oI28xmgeLMVXIstB+ZL5CTGvWSMVMLeHxitIuc=
k8s.io/cli-runtime v0.26.3/go.mod h1:5YEhXLV4kLt/OSy9yQwtSSNZU2Z7aTEYta1A+Jg4VC4=
k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4=
k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI=
k8s.io/client-go v0.28.3 h1:2OqNb72ZuTZPKCl+4gTKvqao0AMOl9f3o2ijbAj3LI4=
k8s.io/client-go v0.28.3/go.mod h1:LTykbBp9gsA7SwqirlCXBWtK0guzfhpoW4qSm7i9dxo=
k8s.io/component-base v0.26.1 h1:4ahudpeQXHZL5kko+iDHqLj/FSGAEUnSVO0EBbgDd+4=
k8s.io/component-base v0.26.1/go.mod h1:VHrLR0b58oC035w6YQiBSbtsf0ThuSwXP+p5dD/kAWU=
k8s.io/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao=
Expand Down
2 changes: 1 addition & 1 deletion internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Kubeconfig struct {
Host types.String `tfsdk:"host"`
Username types.String `tfsdk:"username"`
Password types.String `tfsdk:"password"`
Inscure types.String `tfsdk:"insecure"`
Inscure types.Bool `tfsdk:"insecure"`
TlsServerName types.String `tfsdk:"tls_server_name"`
ClientCertificate types.String `tfsdk:"client_certificate"`
ClientKey types.String `tfsdk:"client_key"`
Expand Down
122 changes: 51 additions & 71 deletions internal/resource/cluster_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@ package resource

import (
"bytes"
"fmt"
"os"
"sync"

"terraform-provider-plural/internal/model"

"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/mitchellh/go-homedir"
"k8s.io/apimachinery/pkg/api/meta"
apimachineryschema "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/tools/clientcmd"

"terraform-provider-plural/internal/model"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)

func kubeconfigAttribute() schema.SingleNestedAttribute {
return schema.SingleNestedAttribute{
Optional: true,
Attributes: map[string]schema.Attribute{
"host": schema.StringAttribute{
Optional: true,
Optional: true,
//Default: defaults.EnvString("PLURAL_KUBE_HOST", ""),
MarkdownDescription: "The address of the Kubernetes clusters. Can be sourced from `PLURAL_KUBE_HOST`.",
MarkdownDescription: "The complete address of the Kubernetes cluster, using scheme://hostname:port format. Can be sourced from `PLURAL_KUBE_HOST`.",
},
"username": schema.StringAttribute{
Optional: true,
Optional: true,
//Default: defaults.EnvString("PLURAL_KUBE_HOST", ""),
MarkdownDescription: "The username for basic authentication to the Kubernetes cluster. Can be sourced from `PLURAL_KUBE_USER`.",
},
Expand Down Expand Up @@ -121,8 +121,6 @@ func kubeconfigAttribute() schema.SingleNestedAttribute {
type KubeConfig struct {
ClientConfig clientcmd.ClientConfig

Burst int

sync.Mutex
}

Expand All @@ -139,11 +137,6 @@ func (k *KubeConfig) ToDiscoveryClient() (discovery.DiscoveryInterface, error) {
return nil, err
}

// The more groups you have, the more discovery requests you need to make.
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
// double it just so we don't end up here again for a while. This config is only used for discovery.
config.Burst = k.Burst

return discovery.NewDiscoveryClientForConfigOrDie(config), nil
}

Expand All @@ -164,14 +157,10 @@ func (k *KubeConfig) ToRawKubeConfigLoader() clientcmd.ClientConfig {
return k.ClientConfig
}

func newKubeConfig(configData *model.Kubeconfig, namespace *string) (*KubeConfig, error) {
func newKubeconfig(kubeconfig model.Kubeconfig, namespace *string) (*KubeConfig, error) {
overrides := &clientcmd.ConfigOverrides{}
loader := &clientcmd.ClientConfigLoadingRules{}

if v := os.Getenv("PLURAL_KUBE_CONFIG_PATH"); v != "" {
configData.ConfigPath = types.StringValue(v)
}

if len(configPaths) > 0 {

Check failure on line 164 in internal/resource/cluster_kubeconfig.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: configPaths (typecheck)
expandedPaths := []string{}
for _, p := range configPaths {

Check failure on line 166 in internal/resource/cluster_kubeconfig.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: configPaths (typecheck)
Expand All @@ -190,94 +179,85 @@ func newKubeConfig(configData *model.Kubeconfig, namespace *string) (*KubeConfig
loader.Precedence = expandedPaths
}

ctx, ctxOk := k8sGetOk(configData, "config_context")
authInfo, authInfoOk := k8sGetOk(configData, "config_context_auth_info")
cluster, clusterOk := k8sGetOk(configData, "config_context_cluster")
if ctxOk || authInfoOk || clusterOk {
if ctxOk {
overrides.CurrentContext = ctx.(string)
if !kubeconfig.ConfigContext.IsNull() || !kubeconfig.ConfigContextAuthInfo.IsNull() || !kubeconfig.ConfigContextCluster.IsNull() {
if !kubeconfig.ConfigContext.IsNull() {
overrides.CurrentContext = kubeconfig.ConfigContext.ValueString()
log.Printf("[DEBUG] Using custom current context: %q", overrides.CurrentContext)

Check failure on line 185 in internal/resource/cluster_kubeconfig.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: log (typecheck)
}

overrides.Context = clientcmdapi.Context{}
if authInfoOk {
overrides.Context.AuthInfo = authInfo.(string)
if !kubeconfig.ConfigContextAuthInfo.IsNull() {
overrides.Context.AuthInfo = kubeconfig.ConfigContextAuthInfo.ValueString()
}
if clusterOk {
overrides.Context.Cluster = cluster.(string)
if !kubeconfig.ConfigContextCluster.IsNull() {
overrides.Context.Cluster = kubeconfig.ConfigContextCluster.ValueString()
}
log.Printf("[DEBUG] Using overidden context: %#v", overrides.Context)

Check failure on line 195 in internal/resource/cluster_kubeconfig.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: log (typecheck)
}
}

// Overriding with static configuration
if v, ok := k8sGetOk(configData, "insecure"); ok {
overrides.ClusterInfo.InsecureSkipTLSVerify = v.(bool)
if !kubeconfig.Inscure.IsNull() {
overrides.ClusterInfo.InsecureSkipTLSVerify = kubeconfig.Inscure.ValueBool()
}
if v, ok := k8sGetOk(configData, "tls_server_name"); ok {
overrides.ClusterInfo.TLSServerName = v.(string)
if !kubeconfig.TlsServerName.IsNull() {
overrides.ClusterInfo.TLSServerName = kubeconfig.TlsServerName.ValueString()
}
if v, ok := k8sGetOk(configData, "cluster_ca_certificate"); ok {
overrides.ClusterInfo.CertificateAuthorityData = bytes.NewBufferString(v.(string)).Bytes()
if !kubeconfig.ClusterCACertificate.IsNull() {
overrides.ClusterInfo.CertificateAuthorityData = bytes.NewBufferString(kubeconfig.ClusterCACertificate.ValueString()).Bytes()
}
if v, ok := k8sGetOk(configData, "client_certificate"); ok {
overrides.AuthInfo.ClientCertificateData = bytes.NewBufferString(v.(string)).Bytes()
if !kubeconfig.ClientCertificate.IsNull() {
overrides.AuthInfo.ClientCertificateData = bytes.NewBufferString(kubeconfig.ClientCertificate.ValueString()).Bytes()
}
if v, ok := k8sGetOk(configData, "host"); ok {
// Server has to be the complete address of the kubernetes cluster (scheme://hostname:port), not just the hostname,
// because `overrides` are processed too late to be taken into account by `defaultServerUrlFor()`.
// This basically replicates what defaultServerUrlFor() does with config but for overrides,
// see https://github.com/kubernetes/client-go/blob/v12.0.0/rest/url_utils.go#L85-L87
if !kubeconfig.Host.IsNull() {
hasCA := len(overrides.ClusterInfo.CertificateAuthorityData) != 0
hasCert := len(overrides.AuthInfo.ClientCertificateData) != 0
defaultTLS := hasCA || hasCert || overrides.ClusterInfo.InsecureSkipTLSVerify
host, _, err := rest.DefaultServerURL(v.(string), "", apimachineryschema.GroupVersion{}, defaultTLS)
host, _, err := rest.DefaultServerURL(kubeconfig.Host.ValueString(), "", apimachineryschema.GroupVersion{}, defaultTLS)
if err != nil {
return nil, err
}

overrides.ClusterInfo.Server = host.String()
}
if v, ok := k8sGetOk(configData, "username"); ok {
overrides.AuthInfo.Username = v.(string)
if !kubeconfig.Username.IsNull() {
overrides.AuthInfo.Username = kubeconfig.Username.ValueString()
}
if v, ok := k8sGetOk(configData, "password"); ok {
overrides.AuthInfo.Password = v.(string)
if !kubeconfig.Password.IsNull() {
overrides.AuthInfo.Password = kubeconfig.Password.ValueString()
}
if v, ok := k8sGetOk(configData, "client_key"); ok {
overrides.AuthInfo.ClientKeyData = bytes.NewBufferString(v.(string)).Bytes()
if !kubeconfig.ClientKey.IsNull() {
overrides.AuthInfo.ClientKeyData = bytes.NewBufferString(kubeconfig.ClientKey.ValueString()).Bytes()
}
if v, ok := k8sGetOk(configData, "token"); ok {
overrides.AuthInfo.Token = v.(string)
if !kubeconfig.Token.IsNull() {
overrides.AuthInfo.Token = kubeconfig.Token.ValueString()
}

if v, ok := k8sGetOk(configData, "proxy_url"); ok {
overrides.ClusterDefaults.ProxyURL = v.(string)
if !kubeconfig.ProxyURL.IsNull() {
overrides.ClusterDefaults.ProxyURL = kubeconfig.ProxyURL.ValueString()
}

if v, ok := k8sGetOk(configData, "exec"); ok {
if !kubeconfig.Exec.IsNull() {
exec := &clientcmdapi.ExecConfig{}
if spec, ok := v.([]interface{})[0].(map[string]interface{}); ok {
exec.InteractiveMode = clientcmdapi.IfAvailableExecInteractiveMode
exec.APIVersion = spec["api_version"].(string)
exec.Command = spec["command"].(string)
exec.Args = expandStringSlice(spec["args"].([]interface{}))
for kk, vv := range spec["env"].(map[string]interface{}) {
exec.Env = append(exec.Env, clientcmdapi.ExecEnvVar{Name: kk, Value: vv.(string)})
}
} else {
log.Printf("[ERROR] Failed to parse exec")
return nil, fmt.Errorf("failed to parse exec")
}

//if spec, ok := v.([]interface{})[0].(map[string]interface{}); ok {
// exec.InteractiveMode = clientcmdapi.IfAvailableExecInteractiveMode
// exec.APIVersion = spec["api_version"].(string)
// exec.Command = spec["command"].(string)
// exec.Args = expandStringSlice(spec["args"].([]interface{}))
// for kk, vv := range spec["env"].(map[string]interface{}) {
// exec.Env = append(exec.Env, clientcmdapi.ExecEnvVar{Name: kk, Value: vv.(string)})
// }
//} else {
// log.Printf("[ERROR] Failed to parse exec")
// return nil, fmt.Errorf("failed to parse exec")
//}

overrides.AuthInfo.Exec = exec
}

overrides.Context.Namespace = "default"

if namespace != nil {
overrides.Context.Namespace = *namespace
}
burstLimit := configData.Get("burst_limit").(int)

client := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loader, overrides)
if client == nil {
Expand All @@ -286,5 +266,5 @@ func newKubeConfig(configData *model.Kubeconfig, namespace *string) (*KubeConfig
}
log.Printf("[INFO] Successfully initialized kubernetes config")

Check failure on line 267 in internal/resource/cluster_kubeconfig.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: log (typecheck)

return &KubeConfig{ClientConfig: client, Burst: burstLimit}, nil
return &KubeConfig{ClientConfig: client}, nil
}

0 comments on commit 796ed48

Please sign in to comment.