Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 084ff32

Browse files
kaufersDavid Chung
authored andcommitted
Plugin start JSON processing fixes (#688)
* Change time.Duration to types.Duration for Option parsing `time.Duration` does not implement the JSON marshall/unmarshall interfaces, the `Option` parsing in `group` and `terraform` plugins needs to be changed to use `types.Duration`. Signed-off-by: Steven Kaufer <[email protected]> * Add nil check on TLS options on new Docker client Signed-off-by: Steven Kaufer <[email protected]>
1 parent f6e94d6 commit 084ff32

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

pkg/run/v0/group/group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func init() {
3737
// Options capture the options for starting up the group controller.
3838
type Options struct {
3939
// PollInterval is the frequency for syncing the state
40-
PollInterval time.Duration
40+
PollInterval types.Duration
4141

4242
// MaxParallelNum is the max number of parallel instance operation. Default =0 (no limit)
4343
MaxParallelNum uint
@@ -51,7 +51,7 @@ type Options struct {
5151

5252
// DefaultOptions return an Options with default values filled in.
5353
var DefaultOptions = Options{
54-
PollInterval: 10 * time.Second,
54+
PollInterval: types.FromDuration(10 * time.Second),
5555
MaxParallelNum: 0,
5656
PollIntervalGroupSpec: 1 * time.Second,
5757
PollIntervalGroupDetail: 30 * time.Second,
@@ -87,7 +87,7 @@ func Run(plugins func() discovery.Plugins, name plugin.Name,
8787
}
8888

8989
groupPlugin := group.NewGroupPlugin(instancePluginLookup, flavorPluginLookup,
90-
options.PollInterval, options.MaxParallelNum)
90+
options.PollInterval.Duration(), options.MaxParallelNum)
9191

9292
// Start a poller to load the snapshot and make that available as metadata
9393
updateSnapshot := make(chan func(map[string]interface{}))

pkg/run/v0/terraform/terraform.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Options struct {
4343
Dir string
4444

4545
// PollInterval is the Terraform polling interval
46-
PollInterval time.Duration
46+
PollInterval types.Duration
4747

4848
// Standalone - set if running standalone, disables manager leadership verification
4949
Standalone bool
@@ -65,7 +65,7 @@ type Options struct {
6565
// simply get this struct and bind the fields to the flags.
6666
var DefaultOptions = Options{
6767
Dir: local.Getenv(EnvDir, filepath.Join(local.InfrakitHome(), "terraform")),
68-
PollInterval: 30 * time.Second,
68+
PollInterval: types.FromDuration(30 * time.Second),
6969
Standalone: false,
7070
}
7171

@@ -99,7 +99,7 @@ func Run(plugins func() discovery.Plugins, name plugin.Name,
9999
log.Info("NewOptions", "value", options.NewOption, "Dir", options.Dir)
100100

101101
impls = map[run.PluginCode]interface{}{
102-
run.Instance: terraform.NewTerraformInstancePlugin(options.Dir, options.PollInterval,
102+
run.Instance: terraform.NewTerraformInstancePlugin(options.Dir, options.PollInterval.Duration(),
103103
options.Standalone, &terraform.ImportOptions{
104104
InstanceSpec: importInstSpec,
105105
InstanceID: &options.ImportInstanceID,

pkg/util/docker/docker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type APIClientCloser interface {
3535
// NewClient creates a new API client.
3636
func NewClient(host string, tls *tlsconfig.Options) (APIClientCloser, error) {
3737
tlsOptions := tls
38-
if tls.KeyFile == "" || tls.CAFile == "" || tls.CertFile == "" {
38+
if tls == nil || tls.KeyFile == "" || tls.CAFile == "" || tls.CertFile == "" {
3939
// The api doesn't like it when you pass in not nil but with zero field values...
4040
tlsOptions = nil
4141
}

0 commit comments

Comments
 (0)