mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
chore(volumes): add client methods for volume management, e2e test
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ type ImageClient interface {
|
||||
|
||||
type MachineClient interface {
|
||||
InspectMachine(ctx context.Context, id string) (*pb.MachineMember, error)
|
||||
ListMachines(ctx context.Context) ([]*pb.MachineMember, error)
|
||||
ListMachines(ctx context.Context) (MachineMembersList, error)
|
||||
}
|
||||
|
||||
type ServiceClient interface {
|
||||
|
||||
@@ -110,11 +110,6 @@ type ServiceContainer struct {
|
||||
ServiceSpec ServiceSpec
|
||||
}
|
||||
|
||||
type MachineContainer struct {
|
||||
MachineID string
|
||||
Container Container
|
||||
}
|
||||
|
||||
// ServiceID returns the ID of the service this container belongs to.
|
||||
func (c *ServiceContainer) ServiceID() string {
|
||||
return c.Config.Labels[LabelServiceID]
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package api
|
||||
|
||||
import "github.com/psviderski/uncloud/internal/machine/api/pb"
|
||||
|
||||
type MachineMembersList []*pb.MachineMember
|
||||
|
||||
func (m MachineMembersList) FindByManagementIP(ip string) *pb.MachineMember {
|
||||
for _, machine := range m {
|
||||
addr, err := machine.Machine.Network.ManagementIp.ToAddr()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if addr.String() == ip {
|
||||
return machine
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -43,6 +44,8 @@ type BindOptions struct {
|
||||
// VolumeOptions represents options for a managed volume.
|
||||
type VolumeOptions struct {
|
||||
// Driver specifies the volume driver and its options for volume creation.
|
||||
// TODO: It seems we don't really need Driver and Labels if we only support externally managed volumes.
|
||||
// However we may need them in the future if we add support for isolated container-scoped volumes.
|
||||
Driver *mount.Driver `json:",omitempty"`
|
||||
// Labels are key-value metadata to apply to the volume if creating a new volume.
|
||||
Labels map[string]string `json:",omitempty"`
|
||||
@@ -182,3 +185,13 @@ func sortVolumeMounts(mounts []VolumeMount) {
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
// MachineVolume represents a volume on a specific machine.
|
||||
type MachineVolume struct {
|
||||
// MachineID is the ID of the machine where the volume exists.
|
||||
MachineID string
|
||||
// MachineName is the name of the machine where the volume exists.
|
||||
MachineName string
|
||||
// Volume is the Docker volume model.
|
||||
Volume volume.Volume
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user