Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Yun-Tang Hsu <hsuy@vmware.com>
  • Loading branch information
yuntanghsu committed Aug 2, 2023
1 parent 8581346 commit 988300a
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions pkg/support/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/klog/v2"
"k8s.io/kubectl/pkg/cmd/cp"
"k8s.io/kubectl/pkg/cmd/util"

"antrea.io/antrea/pkg/util/logdir"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)

const (
Expand Down Expand Up @@ -187,18 +187,14 @@ func (d *managerDumper) DumpZookeeperLog(basedir string) error {
func (d *managerDumper) copyFromPod(namespace, pod, srcDir, dstDir string) error {
ioStreams, _, out, errOut := genericclioptions.NewTestIOStreams()
copyOptions := cp.NewCopyOptions(ioStreams)
// below 4 lines are only used to add args to copyOptions
factory := util.NewFactory(newRestClientGetter(d.namespace, d.restConfig))
cmd := cp.NewCmdCp(factory, ioStreams)
args := []string{pod + ":" + srcDir, dstDir}
if err := copyOptions.Complete(factory, cmd, args); err != nil {
if err := copyOptions.Complete(factory, cp.NewCmdCp(factory, ioStreams), []string{pod + ":" + srcDir, dstDir}); err != nil {
return fmt.Errorf("failed to complete: %v", err)
}
if err := copyOptions.Validate(); err != nil {
return fmt.Errorf("failed to validate: %v", err)
}
klog.V(4).InfoS("check config", "copyClientConfig", copyOptions.ClientConfig, "client", d.restConfig, "CP namespace", copyOptions.Namespace, "namespace", namespace)
//copyOptions.ClientConfig = d.restConfig
//copyOptions.Namespace = namespace
klog.InfoS("Config", "cpConfig", copyOptions.ClientConfig, "Config", d.restConfig, "cpNS", copyOptions.Namespace, "NS", namespace)
copyOptions.ClientConfig = d.restConfig
copyOptions.Namespace = namespace
copyOptions.Clientset = d.clientSet
if err := copyOptions.Run(); err != nil {
return fmt.Errorf("could not run copy operation: %v", err)
Expand Down Expand Up @@ -349,10 +345,9 @@ type restClientGetter struct {
}

func newRestClientGetter(namespace string, clientConfig *rest.Config) restClientGetter {
configLoader := clientcmd.NewDefaultClientConfig(clientcmdapi.Config{}, &clientcmd.ConfigOverrides{Context: clientcmdapi.Context{Namespace: namespace}})
return restClientGetter{
ClientConfig: clientConfig,
ConfigLoader: configLoader,
ConfigLoader: clientcmd.NewDefaultClientConfig(clientcmdapi.Config{}, &clientcmd.ConfigOverrides{Context: clientcmdapi.Context{Namespace: namespace}}),
}
}

Expand Down

0 comments on commit 988300a

Please sign in to comment.