func (d *driver) specFromOpts(Opts map[string]string) *api.VolumeSpec { var spec api.VolumeSpec for k, v := range Opts { switch k { case api.SpecEphemeral: spec.Ephemeral, _ = strconv.ParseBool(v) case api.SpecSize: spec.Size, _ = strconv.ParseUint(v, 10, 64) case api.SpecFilesystem: spec.Format = api.Filesystem(v) case api.SpecBlockSize: blockSize, _ := strconv.ParseInt(v, 10, 64) spec.BlockSize = int(blockSize) case api.SpecHaLevel: haLevel, _ := strconv.ParseInt(v, 10, 64) spec.HALevel = int(haLevel) case api.SpecCos: cos, _ := strconv.ParseInt(v, 10, 64) spec.Cos = api.VolumeCos(cos) case api.SpecDedupe: spec.Dedupe, _ = strconv.ParseBool(v) case api.SpecSnapshotInterval: snapshotInterval, _ := strconv.ParseInt(v, 10, 64) spec.SnapshotInterval = int(snapshotInterval) } } return &spec }
func (d *driver) specFromOpts(Opts map[string]string) *api.VolumeSpec { spec := api.VolumeSpec{ VolumeLabels: make(map[string]string), Format: api.FSType_FS_TYPE_EXT4, } for k, v := range Opts { switch k { case api.SpecEphemeral: spec.Ephemeral, _ = strconv.ParseBool(v) case api.SpecSize: sizeMulti := uint64(1024 * 1024 * 1024) if strings.HasSuffix(v, "G") || strings.HasSuffix(v, "g") { sizeMulti = 1024 * 1024 * 1024 last := len(v) - 1 v = v[:last] } size, _ := strconv.ParseUint(v, 10, 64) spec.Size = size * sizeMulti case api.SpecFilesystem: value, _ := api.FSTypeSimpleValueOf(v) spec.Format = value case api.SpecBlockSize: blockSize, _ := strconv.ParseInt(v, 10, 64) spec.BlockSize = blockSize case api.SpecHaLevel: haLevel, _ := strconv.ParseInt(v, 10, 64) spec.HaLevel = haLevel case api.SpecCos: value, _ := strconv.ParseUint(v, 10, 32) spec.Cos = uint32(value) case api.SpecDedupe: spec.Dedupe, _ = strconv.ParseBool(v) case api.SpecSnapshotInterval: snapshotInterval, _ := strconv.ParseUint(v, 10, 32) spec.SnapshotInterval = uint32(snapshotInterval) default: spec.VolumeLabels[k] = v } } return &spec }