From ca265740510292df154dca9063987be2de305f39 Mon Sep 17 00:00:00 2001 From: Ali Asgar Date: Wed, 27 Sep 2023 12:54:07 +0530 Subject: [PATCH 1/4] fixed path issue in import kvm, #303 #304 --- cmd/kvm/impkvms.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/kvm/impkvms.go b/cmd/kvm/impkvms.go index 76b3923d6..7a42c8c1d 100644 --- a/cmd/kvm/impkvms.go +++ b/cmd/kvm/impkvms.go @@ -15,6 +15,7 @@ package kvm import ( + "path/filepath" "strings" "internal/apiclient" @@ -38,6 +39,7 @@ var ImpCmd = &cobra.Command{ apiclient.DisableCmdPrintHttpResponse() orgKVMFileList, envKVMFileList, proxyKVMFileList, err := utils.ListKVMFiles(folder) + if err != nil { return err } @@ -45,7 +47,8 @@ var ImpCmd = &cobra.Command{ if len(orgKVMFileList) > 0 { clilog.Info.Println("Importing org scoped KVMs...") for _, orgKVMFile := range orgKVMFileList { - kvmMetadata := strings.Split(orgKVMFile, "_") + kvmFile := filepath.Base(orgKVMFile) + kvmMetadata := strings.Split(kvmFile, "_") clilog.Info.Printf("\tCreating KVM %s\n", orgKVMFile) if _, err = kvm.Create("", kvmMetadata[1], true); err != nil { return err @@ -60,7 +63,8 @@ var ImpCmd = &cobra.Command{ if len(envKVMFileList) > 0 { clilog.Info.Println("Importing env scoped KVMs...") for _, envKVMFile := range envKVMFileList { - kvmMetadata := strings.Split(envKVMFile, "_") + kvmFile := filepath.Base(envKVMFile) + kvmMetadata := strings.Split(kvmFile, "_") apiclient.SetApigeeEnv(kvmMetadata[1]) clilog.Info.Printf("\tCreating KVM %s\n", envKVMFile) if _, err = kvm.Create("", kvmMetadata[2], true); err != nil { @@ -76,9 +80,10 @@ var ImpCmd = &cobra.Command{ if len(proxyKVMFileList) > 0 { clilog.Info.Println("Importing proxy scoped KVMs...") for _, proxyKVMFile := range proxyKVMFileList { - kvmMetadata := strings.Split(proxyKVMFile, "_") + kvmFile := filepath.Base(proxyKVMFile) + kvmMetadata := strings.Split(kvmFile, "_") clilog.Info.Printf("\tCreating KVM %s\n", proxyKVMFile) - if _, err = kvm.Create(kvmMetadata[1], "", true); err != nil { + if _, err = kvm.Create(kvmMetadata[1], kvmMetadata[2], true); err != nil { return err } clilog.Info.Printf("\tImporting entries for %s\n", proxyKVMFile) From 09b217b19d9020cb188fe28de37950edb2c0b75b Mon Sep 17 00:00:00 2001 From: Ali Asgar Date: Wed, 27 Sep 2023 13:01:01 +0530 Subject: [PATCH 2/4] Empty-Commit From 0322cbf5429ecfd639cd6453d87a2cf0d9d432d5 Mon Sep 17 00:00:00 2001 From: Ali Asgar Date: Sat, 30 Sep 2023 11:21:07 +0530 Subject: [PATCH 3/4] fixed spacing --- cmd/kvm/impkvms.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/kvm/impkvms.go b/cmd/kvm/impkvms.go index 7a42c8c1d..72d2f8cf2 100644 --- a/cmd/kvm/impkvms.go +++ b/cmd/kvm/impkvms.go @@ -47,7 +47,7 @@ var ImpCmd = &cobra.Command{ if len(orgKVMFileList) > 0 { clilog.Info.Println("Importing org scoped KVMs...") for _, orgKVMFile := range orgKVMFileList { - kvmFile := filepath.Base(orgKVMFile) + kvmFile := filepath.Base(orgKVMFile) kvmMetadata := strings.Split(kvmFile, "_") clilog.Info.Printf("\tCreating KVM %s\n", orgKVMFile) if _, err = kvm.Create("", kvmMetadata[1], true); err != nil { @@ -63,7 +63,7 @@ var ImpCmd = &cobra.Command{ if len(envKVMFileList) > 0 { clilog.Info.Println("Importing env scoped KVMs...") for _, envKVMFile := range envKVMFileList { - kvmFile := filepath.Base(envKVMFile) + kvmFile := filepath.Base(envKVMFile) kvmMetadata := strings.Split(kvmFile, "_") apiclient.SetApigeeEnv(kvmMetadata[1]) clilog.Info.Printf("\tCreating KVM %s\n", envKVMFile) @@ -80,7 +80,7 @@ var ImpCmd = &cobra.Command{ if len(proxyKVMFileList) > 0 { clilog.Info.Println("Importing proxy scoped KVMs...") for _, proxyKVMFile := range proxyKVMFileList { - kvmFile := filepath.Base(proxyKVMFile) + kvmFile := filepath.Base(proxyKVMFile) kvmMetadata := strings.Split(kvmFile, "_") clilog.Info.Printf("\tCreating KVM %s\n", proxyKVMFile) if _, err = kvm.Create(kvmMetadata[1], kvmMetadata[2], true); err != nil { From f63036c8d1c08eed2935bf9e1248befd275c32fa Mon Sep 17 00:00:00 2001 From: Ali Asgar Date: Thu, 5 Oct 2023 11:45:45 +0530 Subject: [PATCH 4/4] code formating --- cmd/kvm/impkvms.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/kvm/impkvms.go b/cmd/kvm/impkvms.go index 72d2f8cf2..3e2d79a05 100644 --- a/cmd/kvm/impkvms.go +++ b/cmd/kvm/impkvms.go @@ -39,7 +39,6 @@ var ImpCmd = &cobra.Command{ apiclient.DisableCmdPrintHttpResponse() orgKVMFileList, envKVMFileList, proxyKVMFileList, err := utils.ListKVMFiles(folder) - if err != nil { return err }