Skip to content

Commit

Permalink
fix kubeclient creation with CAData
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancisc committed Jul 29, 2024
1 parent 3b12bea commit 6f6e5fc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ func NewClient(token, apiEndpoint string) (runtimeclient.Client, error) {
}

func NewClientFromRestConfig(config *rest.Config) (runtimeclient.Client, error) {
config.Insecure = true
tc, err := config.TransportConfig()
if err != nil {
return nil, err

Check warning on line 67 in pkg/client/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/client.go#L65-L67

Added lines #L65 - L67 were not covered by tests
}
// when specifying the insecure flag with a certificate file the runtime client throws the following error:
// cannot create client: specifying a root certificates file with the insecure flag is not allowed
//
// set insecure flag only if certificate file is not present
if !tc.HasCA() {
config.Insecure = true

Check warning on line 74 in pkg/client/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/client/client.go#L73-L74

Added lines #L73 - L74 were not covered by tests
}
return newClientFromRestConfig(config)
}

Expand Down

0 comments on commit 6f6e5fc

Please sign in to comment.