Merge pull request #1766 from ndeloof/config_profiles

config --profiles to list all defined profiles
This commit is contained in:
Nicolas De loof 2021-06-10 09:59:48 +02:00 committed by GitHub
commit 1b54a38db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 { }
profiles := make([]string, 0, len(set))
for p := range set {
profiles = append(profiles, p)
}
sort.Strings(profiles)
for _, p := range profiles {
fmt.Println(p) fmt.Println(p)
} }
}
return nil return nil
} }