@@ -5,9 +5,12 @@ import (
55 "os"
66 "path/filepath"
77
8- "github.com/deislabs/cnab-go/utils/crud"
8+ cnabCrud "github.com/deislabs/cnab-go/utils/crud"
9+ "github.com/docker/cli/cli/command"
910 digest "github.com/opencontainers/go-digest"
1011 "github.com/pkg/errors"
12+
13+ appCrud "github.com/docker/app/internal/store/crud"
1114)
1215
1316const (
@@ -51,12 +54,28 @@ func NewApplicationStore(configDir string) (*ApplicationStore, error) {
5154}
5255
5356// InstallationStore initializes and returns a context based installation store
54- func (a ApplicationStore ) InstallationStore (context string ) (InstallationStore , error ) {
55- path := filepath .Join (a .path , InstallationStoreDirectory , makeDigestedDirectory (context ))
56- if err := os .MkdirAll (path , 0755 ); err != nil {
57- return nil , errors .Wrapf (err , "failed to create installation store directory for context %q" , context )
57+ func (a ApplicationStore ) InstallationStore (context string , orchestrator command.Orchestrator ) (InstallationStore , error ) {
58+ switch {
59+ // FIXME What if orchestrator.HasKubernetes() and still want to use local store?
60+ case orchestrator .HasKubernetes ():
61+ // FIXME Get this namespace, labelKey and labelValue dynamically through cli opts
62+ k8sStore , err := appCrud .NewKubernetesSecretsStore (
63+ appCrud .DefaultKubernetesNamespace ,
64+ appCrud.LabelKV {
65+ appCrud .DefaultSecretLabelKey ,
66+ appCrud .DefaultSecretLabelValue ,
67+ })
68+ if err != nil {
69+ return nil , err
70+ }
71+ return & installationStore {store : k8sStore }, nil
72+ default :
73+ path := filepath .Join (a .path , InstallationStoreDirectory , makeDigestedDirectory (context ))
74+ if err := os .MkdirAll (path , 0755 ); err != nil {
75+ return nil , errors .Wrapf (err , "failed to create installation store directory for context %q" , context )
76+ }
77+ return & installationStore {store : cnabCrud .NewFileSystemStore (path , "json" )}, nil
5878 }
59- return & installationStore {store : crud .NewFileSystemStore (path , "json" )}, nil
6079}
6180
6281// CredentialStore initializes and returns a context based credential store
0 commit comments