func (d *Duration) Value() time.Duration {
	if d == nil {
		return 0
	}
	return d.Duration
}
Value returns 0 if the duration is null, the inner duration otherwise.
package provisioner
import (
	"encoding/json"
	"time"
	"github.com/pkg/errors"
)
type Duration struct {
	time.Duration
}
func NewDuration(s string) (*Duration, error) {
	d, err := time.ParseDuration(s)
	if err != nil {
		return nil, errors.Wrapf(err, "error parsing %s as duration", s)
	}
	return &Duration{Duration: d}, nil
}
func (d *Duration) MarshalJSON() ([]byte, error) {
	return json.Marshal(d.Duration.String())
}
func (d *Duration) UnmarshalJSON(data []byte) (err error) {
	var (
		s  string
		dd time.Duration
	)
	if d == nil {
		return errors.New("duration cannot be nil")
	}
	if err = json.Unmarshal(data, &s); err != nil {
		return errors.Wrapf(err, "error unmarshaling %s", data)
	}
	if dd, err = time.ParseDuration(s); err != nil {
		return errors.Wrapf(err, "error parsing %s as duration", s)
	}
	d.Duration = dd
	return
}