Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
return
}
}
var hasErrors bool

// Handle multiple specification files separated by comma.
sepSpecificationFiles := strings.Split(specificationFiles, ",")
Expand All @@ -132,16 +133,17 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
}

// Try uploading this artifact.
msg, err := mc.UploadArtifact(f, mainArtifact)
if err != nil {
fmt.Printf("Got error when invoking Microcks client importing Artifact: %s", err)
os.Exit(1)
}
action := "discovered"
if !mainArtifact {
action = "completed"
}
fmt.Printf("Microcks has %s '%s'\n", action, msg)
msg, err := mc.UploadArtifact(f, mainArtifact)
if err != nil {
fmt.Printf("Failed to import '%s': %s\n", f, err)
hasErrors = true
continue
}
action := "discovered"
if !mainArtifact {
action = "completed"
}
fmt.Printf("Microcks has %s '%s'\n", action, msg)

// If watch flag is provided, update watch config.
if watch {
Expand All @@ -155,9 +157,8 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
}

// Normalize file path to match the watcher fsnotify events format.
if strings.HasPrefix(f, "./") {
f = strings.TrimPrefix(f, "./")
}

f = strings.TrimPrefix(f, "./")

// Upsert entry.
watchCfg.UpsertEntry(config.WatchEntry{
Expand All @@ -171,6 +172,9 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
errors.CheckError(err)
}
}
if hasErrors {
os.Exit(1)
}

// Start watcher if --watch flag is provided.
if watch {
Expand Down
Loading