浏览代码

Merge pull request #1766 from ndeloof/config_profiles

config --profiles to list all defined profiles
Nicolas De loof 4 年之前
父节点
当前提交
1b54a38db3
共有 1 个文件被更改,包括 14 次插入8 次删除
  1. 14 8
      cli/cmd/compose/convert.go

+ 14 - 8
cli/cmd/compose/convert.go

@@ -22,6 +22,7 @@ import (
 	"fmt"
 	"io"
 	"os"
+	"sort"
 	"strings"
 
 	"github.com/cnabio/cnab-to-oci/remotes"
@@ -189,18 +190,23 @@ func runHash(opts convertOptions) error {
 }
 
 func runProfiles(opts convertOptions, services []string) error {
-	profiles := map[string]interface{}{}
-	_, err := opts.toProject(services)
+	set := map[string]struct{}{}
+	project, err := opts.toProject(services)
 	if err != nil {
 		return err
 	}
-	if opts.projectOptions != nil {
-		for _, p := range opts.projectOptions.Profiles {
-			profiles[p] = nil
-		}
-		for p := range profiles {
-			fmt.Println(p)
+	for _, s := range project.AllServices() {
+		for _, p := range s.Profiles {
+			set[p] = struct{}{}
 		}
 	}
+	profiles := make([]string, 0, len(set))
+	for p := range set {
+		profiles = append(profiles, p)
+	}
+	sort.Strings(profiles)
+	for _, p := range profiles {
+		fmt.Println(p)
+	}
 	return nil
 }