master
h 90 lines 2.29 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 WSLCGuestVolume.h
8
9 Abstract:
10
11 Volume implementation that delegates storage to docker's built-in "local"
12 volume driver. The volume lives on the session storage VHD at
13 /var/lib/docker/volumes/<name>/_data inside the guest VM. No host-side
14 artifacts (no extra VHD file, no disk attach).
15
16 --*/
17
18 #pragma once
19
20 #include "IWSLCVolume.h"
21 #include "WSLCVolumeMetadata.h"
22 #include "wslc.h"
23 #include <map>
24 #include <memory>
25 #include <string>
26
27 namespace wsl::windows::common::docker_schema {
28 struct Volume;
29 }
30
31 namespace wsl::windows::service::wslc {
32
33 class DockerHTTPClient;
34
35 class WSLCGuestVolumeImpl : public IWSLCVolume
36 {
37 public:
38 NON_COPYABLE(WSLCGuestVolumeImpl);
39 NON_MOVABLE(WSLCGuestVolumeImpl);
40
41 WSLCGuestVolumeImpl(
42 std::string&& Name,
43 std::string&& CreatedAt,
44 std::string&& Mountpoint,
45 std::map<std::string, std::string>&& DriverOpts,
46 std::map<std::string, std::string>&& Labels,
47 DockerHTTPClient& DockerClient);
48
49 ~WSLCGuestVolumeImpl() = default;
50
51 static std::unique_ptr<WSLCGuestVolumeImpl> Create(
52 _In_opt_ LPCSTR Name,
53 _In_ std::map<std::string, std::string>&& DriverOpts,
54 _In_ std::map<std::string, std::string>&& Labels,
55 _In_ DockerHTTPClient& DockerClient);
56
57 static std::unique_ptr<WSLCGuestVolumeImpl> Open(_In_ const wsl::windows::common::docker_schema::Volume& Volume, _In_ DockerHTTPClient& DockerClient);
58
59 // IWSLCVolume
60 const std::string& Name() const noexcept override
61 {
62 return m_name;
63 }
64 const char* Driver() const noexcept override
65 {
66 return WSLCGuestVolumeDriver;
67 }
68 const std::map<std::string, std::string>& Labels() const noexcept override
69 {
70 return m_labels;
71 }
72 const std::string& Mountpoint() const noexcept override
73 {
74 return m_mountpoint;
75 }
76
77 void Delete() override;
78 std::string Inspect() const override;
79 WSLCVolumeInformation GetVolumeInformation() const override;
80
81 private:
82 std::string m_name;
83 std::string m_createdAt;
84 std::string m_mountpoint;
85 std::map<std::string, std::string> m_driverOpts;
86 std::map<std::string, std::string> m_labels;
87 DockerHTTPClient& m_dockerClient;
88 };
89
90 } // namespace wsl::windows::service::wslc