Skip to content

Commit

Permalink
fixed path issue in import kvm, #303 #304 (#305)
Browse files Browse the repository at this point in the history
* fixed path issue in import kvm, #303 #304

* Empty-Commit

* fixed spacing

* code formating

---------

Co-authored-by: Ali Asgar <[email protected]>
  • Loading branch information
aliasgar55 and alia5gar authored Oct 5, 2023
1 parent 4508d7e commit a9e08e9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/kvm/impkvms.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package kvm

import (
"path/filepath"
"strings"

"internal/apiclient"
Expand Down Expand Up @@ -45,7 +46,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
Expand All @@ -60,7 +62,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 {
Expand All @@ -76,9 +79,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)
Expand Down

0 comments on commit a9e08e9

Please sign in to comment.