@@ -5,9 +5,12 @@ import (
5
5
"os"
6
6
"path/filepath"
7
7
8
- "github.com/deislabs/cnab-go/utils/crud"
8
+ cnabCrud "github.com/deislabs/cnab-go/utils/crud"
9
+ "github.com/docker/cli/cli/command"
9
10
digest "github.com/opencontainers/go-digest"
10
11
"github.com/pkg/errors"
12
+
13
+ appCrud "github.com/docker/app/internal/store/crud"
11
14
)
12
15
13
16
const (
@@ -51,12 +54,28 @@ func NewApplicationStore(configDir string) (*ApplicationStore, error) {
51
54
}
52
55
53
56
// 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
58
78
}
59
- return & installationStore {store : crud .NewFileSystemStore (path , "json" )}, nil
60
79
}
61
80
62
81
// CredentialStore initializes and returns a context based credential store
0 commit comments