mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
- use minikube v1.26.1 across all github actions workflows - bring all go module dependencies up to date with openebs/lvm-localpv - replace github.com/golang/protobuf with google.golang.org/protobuf - remove go mod vendor Makefile target Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
82 lines
2.6 KiB
Go
82 lines
2.6 KiB
Go
/*
|
|
Copyright © 2020 The OpenEBS Authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package v1alpha1
|
|
|
|
import (
|
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
|
timestamp "google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
// CreateSnapshotResponseBuilder helps building an
|
|
// instance of csi CreateVolumeResponse
|
|
type CreateSnapshotResponseBuilder struct {
|
|
response *csi.CreateSnapshotResponse
|
|
}
|
|
|
|
// NewCreateSnapshotResponseBuilder returns a new
|
|
// instance of CreateSnapshotResponseBuilder
|
|
func NewCreateSnapshotResponseBuilder() *CreateSnapshotResponseBuilder {
|
|
return &CreateSnapshotResponseBuilder{
|
|
response: &csi.CreateSnapshotResponse{
|
|
Snapshot: &csi.Snapshot{},
|
|
},
|
|
}
|
|
}
|
|
|
|
// WithSize sets the size against the
|
|
// CreateSnapshotResponse instance
|
|
func (b *CreateSnapshotResponseBuilder) WithSize(size int64) *CreateSnapshotResponseBuilder {
|
|
b.response.Snapshot.SizeBytes = size
|
|
return b
|
|
}
|
|
|
|
// WithSnapshotID sets the snapshotID against the
|
|
// CreateSnapshotResponse instance
|
|
func (b *CreateSnapshotResponseBuilder) WithSnapshotID(snapshotID string) *CreateSnapshotResponseBuilder {
|
|
b.response.Snapshot.SnapshotId = snapshotID
|
|
return b
|
|
}
|
|
|
|
// WithSourceVolumeID sets the sourceVolumeID against the
|
|
// CreateSnapshotResponse instance
|
|
func (b *CreateSnapshotResponseBuilder) WithSourceVolumeID(volumeID string) *CreateSnapshotResponseBuilder {
|
|
b.response.Snapshot.SourceVolumeId = volumeID
|
|
return b
|
|
}
|
|
|
|
// WithCreationTime sets the creationTime against the
|
|
// CreateSnapshotResponse instance
|
|
func (b *CreateSnapshotResponseBuilder) WithCreationTime(tsec, tnsec int64) *CreateSnapshotResponseBuilder {
|
|
b.response.Snapshot.CreationTime = ×tamp.Timestamp{
|
|
Seconds: tsec,
|
|
Nanos: int32(tnsec),
|
|
}
|
|
return b
|
|
}
|
|
|
|
// WithReadyToUse sets the readyToUse feild against the
|
|
// CreateSnapshotResponse instance
|
|
func (b *CreateSnapshotResponseBuilder) WithReadyToUse(readyToUse bool) *CreateSnapshotResponseBuilder {
|
|
b.response.Snapshot.ReadyToUse = readyToUse
|
|
return b
|
|
}
|
|
|
|
// Build returns the constructed instance
|
|
// of csi CreateSnapshotResponse
|
|
func (b *CreateSnapshotResponseBuilder) Build() *csi.CreateSnapshotResponse {
|
|
return b.response
|
|
}
|