config --profiles to list all defined profiles

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-06-09 12:44:38 +02:00
parent b0a66356e0
commit 1ad964603a
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E

View File

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