File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,12 @@ package main
33import (
44 "encoding/json"
55 "fmt"
6+ "io"
67 "io/ioutil"
78 "os"
89 "path"
910 "reflect"
11+ "regexp"
1012 "strings"
1113
1214 "github.com/spf13/cobra"
@@ -156,18 +158,29 @@ cdsctl action import myAction.yml`,
156158
157159func actionImportRun (v cli.Values ) error {
158160 path := v .GetString ("path" )
159- f , err := os .Open (path )
160- if err != nil {
161- return err
162- }
163- defer f .Close ()
161+ var contentFile io.Reader
162+ var err error
164163
165- var format = "yaml"
164+ format : = "yaml"
166165 if strings .HasSuffix (path , ".json" ) {
167166 format = "json"
168167 }
169168
170- if errImport := client .ActionImport (f , format ); errImport != nil {
169+ if isURL , _ := regexp .MatchString (`http[s]?:\/\/(.*)` , path ); isURL {
170+ contentFile , _ , err = exportentities .OpenURL (path , format )
171+ if err != nil {
172+ return err
173+ }
174+ } else {
175+ f , err := os .Open (path )
176+ if err != nil {
177+ return err
178+ }
179+ defer f .Close ()
180+ contentFile = f
181+ }
182+
183+ if errImport := client .ActionImport (contentFile , format ); errImport != nil {
171184 return errImport
172185 }
173186
You can’t perform that action at this time.
0 commit comments