Skip to content

Commit

Permalink
I don't think there is a need to refresh the remote cluster secret an…
Browse files Browse the repository at this point in the history
…ymore
  • Loading branch information
jmazzitelli committed Jan 12, 2024
1 parent 919ccec commit 63a89d0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 89 deletions.
35 changes: 0 additions & 35 deletions kubernetes/cluster_secret.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kubernetes

import (
"bytes"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -139,40 +138,6 @@ func getClusterName(config *api.Config) string {
return clusterName
}

// reloadRemoteClusterInfoFromFile will re-read the remote cluster secret from the file system and if the data is different
// than the given RemoteClusterInfo, a new one is returned. Otherwise, nil is returned to indicate nothing has changed and
// the given RemoteClusterInfo is already up to date.
func reloadRemoteClusterInfoFromFile(rci RemoteClusterInfo) (*RemoteClusterInfo, error) {
newRci, err := newRemoteClusterInfo(rci.SecretName, rci.SecretFile)
if err != nil {
kubeConfig, cfgErr := rci.Config.RawConfig()
if cfgErr == nil {
return nil, fmt.Errorf("Failed to process data for remote cluster [%s] secret file [%s]", getClusterName(&kubeConfig), rci.SecretFile)
}
return nil, fmt.Errorf("failed to process data for remote cluster secret file [%s]", rci.SecretFile)
}

// Compare the byte representation of the two
o, _ := rci.Config.RawConfig()
old, err := clientcmd.Write(o)
if err != nil {
return nil, fmt.Errorf("unable to marshal old config. Err: %s", err)
}

n, _ := newRci.Config.RawConfig()
new, err := clientcmd.Write(n)
if err != nil {
return nil, fmt.Errorf("unable to marshal old config. Err: %s", err)
}

if !bytes.Equal(old, new) {
return &newRci, nil
}

// the information did not change - return nil to indicate the original one passed to this funcation is already up to date
return nil, nil
}

// TODO: These types probably belong in the business package but since the biz package imports
// this package, we'd need to move the cache out of /kubernetes and into /business. Something
// that should probably be done anyways.
Expand Down
54 changes: 0 additions & 54 deletions kubernetes/cluster_secret_test.go

This file was deleted.

0 comments on commit 63a89d0

Please sign in to comment.