-
Notifications
You must be signed in to change notification settings - Fork 205
/
runtime.go
43 lines (35 loc) · 1.01 KB
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cnabprovider
import (
"os"
"github.com/deislabs/cnab-go/driver"
"github.com/deislabs/cnab-go/driver/lookup"
"github.com/deislabs/porter/pkg/config"
instancestorage "github.com/deislabs/porter/pkg/instance-storage"
)
type Runtime struct {
*config.Config
instanceStorage instancestorage.Provider
}
func NewRuntime(c *config.Config, instanceStorage instancestorage.Provider) *Runtime {
return &Runtime{
Config: c,
instanceStorage: instanceStorage,
}
}
func (d *Runtime) newDriver(driverName string, claimName string, args ActionArguments) (driver.Driver, error) {
driverImpl, err := lookup.Lookup(driverName)
if err != nil {
return driverImpl, err
}
if configurable, ok := driverImpl.(driver.Configurable); ok {
driverCfg := make(map[string]string)
// Load any driver-specific config out of the environment
for env := range configurable.Config() {
if val, ok := os.LookupEnv(env); ok {
driverCfg[env] = val
}
}
configurable.SetConfig(driverCfg)
}
return driverImpl, err
}