Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
EronWright committed Oct 18, 2023
1 parent 9afac39 commit 819e5b4
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions provider/pkg/provider/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package provider

import (
"encoding/json"
"fmt"
"os"
"os/user"
Expand Down Expand Up @@ -148,35 +147,6 @@ func loadKubeconfig(pathOrContents string, overrides *clientcmd.ConfigOverrides)
return kubeconfig, &apiConfig, nil
}

// parseKubeconfigPropertyValue takes a PropertyValue that possibly contains a raw kubeconfig
// (YAML or JSON) string or map and attempts to unmarshal it into a Config struct. If the property value
// is empty, an empty Config is returned.
func parseKubeconfigPropertyValue(kubeconfig resource.PropertyValue) (*clientapi.Config, error) {
if kubeconfig.IsNull() {
return &clientapi.Config{}, nil
}

var cfg []byte
if kubeconfig.IsString() {
cfg = []byte(kubeconfig.StringValue())
} else if kubeconfig.IsObject() {
raw := kubeconfig.ObjectValue().Mappable()
jsonBytes, err := json.Marshal(raw)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal kubeconfig: %v", err)
}
cfg = jsonBytes
} else {
return nil, fmt.Errorf("unexpected kubeconfig format, type: %v", kubeconfig.TypeString())
}
config, err := clientcmd.Load(cfg)
if err != nil {
return nil, fmt.Errorf("failed to parse kubeconfig: %v", err)
}

return config, nil
}

// pruneMap builds a pruned map by recursively copying elements from the source map that have a matching key in the
// target map. This is useful as a preprocessing step for live resource state before comparing it to program inputs.
func pruneMap(source, target map[string]any) map[string]any {
Expand Down

0 comments on commit 819e5b4

Please sign in to comment.