@@ -87,37 +87,43 @@ const (
87
87
)
88
88
89
89
// GetDBPath returns the path where the file-system persistence is stored
90
- // based on the STEPPATH environment variable .
90
+ // based on the $(step path) .
91
91
func GetDBPath () string {
92
92
return filepath .Join (step .Path (), dbPath )
93
93
}
94
94
95
95
// GetConfigPath returns the directory where the configuration files are stored
96
- // based on the STEPPATH environment variable .
96
+ // based on the $(step path) .
97
97
func GetConfigPath () string {
98
98
return filepath .Join (step .Path (), configPath )
99
99
}
100
100
101
+ // GetProfileConfigPath returns the directory where the profile configuration
102
+ // files are stored based on the $(step path).
103
+ func GetProfileConfigPath () string {
104
+ return filepath .Join (step .ProfilePath (), configPath )
105
+ }
106
+
101
107
// GetPublicPath returns the directory where the public keys are stored based on
102
- // the STEPPATH environment variable .
108
+ // the $(step path) .
103
109
func GetPublicPath () string {
104
110
return filepath .Join (step .Path (), publicPath )
105
111
}
106
112
107
113
// GetSecretsPath returns the directory where the private keys are stored based
108
- // on the STEPPATH environment variable .
114
+ // on the $(step path) .
109
115
func GetSecretsPath () string {
110
116
return filepath .Join (step .Path (), privatePath )
111
117
}
112
118
113
119
// GetRootCAPath returns the path where the root CA is stored based on the
114
- // STEPPATH environment variable .
120
+ // $(step path) .
115
121
func GetRootCAPath () string {
116
122
return filepath .Join (step .Path (), publicPath , "root_ca.crt" )
117
123
}
118
124
119
125
// GetOTTKeyPath returns the path where the one-time token key is stored based
120
- // on the STEPPATH environment variable .
126
+ // on the $(step path) .
121
127
func GetOTTKeyPath () string {
122
128
return filepath .Join (step .Path (), privatePath , "ott_key" )
123
129
}
@@ -301,6 +307,7 @@ type PKI struct {
301
307
302
308
// New creates a new PKI configuration.
303
309
func New (o apiv1.Options , opts ... Option ) (* PKI , error ) {
310
+ currentCtx := step .Contexts ().GetCurrent ()
304
311
caService , err := cas .New (context .Background (), o )
305
312
if err != nil {
306
313
return nil , err
@@ -359,6 +366,9 @@ func New(o apiv1.Options, opts ...Option) (*PKI, error) {
359
366
cfg = GetConfigPath ()
360
367
// Create directories
361
368
dirs := []string {public , private , cfg , GetTemplatesPath ()}
369
+ if currentCtx != nil {
370
+ dirs = append (dirs , GetProfileConfigPath ())
371
+ }
362
372
for _ , name := range dirs {
363
373
if _ , err := os .Stat (name ); os .IsNotExist (err ) {
364
374
if err = os .MkdirAll (name , 0700 ); err != nil {
@@ -416,8 +426,8 @@ func New(o apiv1.Options, opts ...Option) (*PKI, error) {
416
426
if p .defaults , err = getPath (cfg , "defaults.json" ); err != nil {
417
427
return nil , err
418
428
}
419
- if c := step . Contexts (). GetCurrent (); c != nil {
420
- p .profileDefaults = c .ProfileDefaultsFile ()
429
+ if currentCtx != nil {
430
+ p .profileDefaults = currentCtx .ProfileDefaultsFile ()
421
431
}
422
432
423
433
if p .config , err = getPath (cfg , "ca.json" ); err != nil {
0 commit comments