17 #ifndef __TEST_DOCKER_ARCHIVE_HPP__ 18 #define __TEST_DOCKER_ARCHIVE_HPP__ 59 const std::string& directory,
60 const std::string&
name,
61 const std::string& entrypoint =
"null",
62 const std::string& cmd =
"null",
64 {
"LD_LIBRARY_PATH=invalid"},
65 {
"LIBPROCESS_IP=invalid"},
66 {
"LIBPROCESS_PORT=invalid"}})
70 return Failure(
"Failed to create '" + directory +
"': " + mkdir.
error());
73 const std::string imagePath =
path::join(directory, name);
77 return Failure(
"Failed to create docker test image directory '" +
78 imagePath +
"': " + mkdir.
error());
81 const std::string layerId =
82 "815b809d588c80fd6ddf4d6ac244ad1c01ae4cbe0f91cc7480e306671ee9c346";
84 const std::string layerPath =
path::join(imagePath, layerId);
95 layerId).get()).get();
102 return Failure(
"Failed to save docker test image 'repositories': " +
107 if (mkdir.isError()) {
108 return Failure(
"Failed to create docker test image layer '" +
109 layerId +
"': " + mkdir.error());
115 "id": "815b809d588c80fd6ddf4d6ac244ad1c01ae4cbe0f91cc7480e306671ee9c346", 116 "created": "2016-03-02T17:16:00.167415955Z", 117 "container": "eb53609036555d26c39bdccfa9850426934bdfde96111d099041689b2251a377", 118 "container_config": { 119 "Hostname": "eb5360903655", 122 "AttachStdin": false, 123 "AttachStdout": false, 124 "AttachStderr": false, 132 "#(nop) ADD file:81ba6f20bdb99e6c13c434a577069860b6656908031162083b1ac9c02c71dd9f in /" 141 "docker_version": "1.9.1", 143 "Hostname": "eb5360903655", 146 "AttachStdin": false, 147 "AttachStdout": false, 148 "AttachStderr": false, 161 "architecture": "amd64", 166 entrypoint).get()).get();
173 return Failure(
"Failed to save docker test image layer '" + layerId +
174 "': " + write.
error());
177 const std::string rootfsDir =
path::join(layerPath,
"layer");
180 if (mkdir.isError()) {
181 return Failure(
"Failed to create layer rootfs directory '" +
182 rootfsDir +
"': " + mkdir.error());
187 if (rootfs.isError()) {
188 return Failure(
"Failed to create docker test image rootfs: " +
199 if (!tarRootfs.isReady()) {
201 "Failed to tar root filesystem: " +
202 (tarRootfs.isFailed() ? tarRootfs.failure() :
"discarded"));
207 return Failure(
"Failed to remove layer rootfs directory: " +
215 if (write.isError()) {
216 return Failure(
"Failed to save layer version: " + write.error());
226 if (!tarImage.isReady()) {
228 "Failed to tar docker test image: " +
229 (tarImage.isFailed() ? tarImage.failure() :
"discarded"));
234 return Failure(
"Failed to remove image directory: " +
246 #endif // __TEST_DOCKER_ARCHIVE_HPP__
Try< Nothing > rmdir(const std::string &directory, bool recursive=true, bool removeRoot=true, bool continueOnError=false)
Definition: rmdir.hpp:42
Definition: nothing.hpp:16
ssize_t write(const int_fd &fd, const void *data, size_t size)
Definition: write.hpp:72
Definition: future.hpp:668
URI manifest(const std::string &repository, const std::string &reference, const std::string ®istry, const Option< std::string > &scheme=None(), const Option< int > &port=None())
Definition: docker.hpp:47
std::string join(const std::string &path1, const std::string &path2, const char _separator=os::PATH_SEPARATOR)
Definition: path.hpp:116
static Future< Nothing > create(const std::string &directory, const std::string &name, const std::string &entrypoint="null", const std::string &cmd="null", const std::vector< std::string > &environment={{"LD_LIBRARY_PATH=invalid"},{"LIBPROCESS_IP=invalid"},{"LIBPROCESS_PORT=invalid"}})
Definition: docker_archive.hpp:58
process::Future< Nothing > tar(const Path &input, const Path &output, const Option< Path > &directory=None(), const Option< Compression > &compression=None())
Tar(archive) the file/directory to produce output file.
Environment * environment
Try< Nothing > mkdir(const std::string &directory, bool recursive=true, bool sync=false)
Definition: mkdir.hpp:42
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
Try< Value > parse(const std::string &s)
Returns the OCI v1 descriptor, image index, image manifest and image configuration from the given str...
Definition: json.hpp:978
static Try error(const E &e)
Definition: try.hpp:43
JSON::Proxy jsonify(const T &)
Definition: jsonify.hpp:702
Definition: docker_archive.hpp:46
Definition: attributes.hpp:24
bool isError() const
Definition: try.hpp:78
Protocol< WriteRequest, WriteResponse > write
static Try< process::Owned< Rootfs > > create(const std::string &root)
Try< std::string > format(const std::string &s, const T &...t)
Definition: format.hpp:58
std::string stringify(int flags)
constexpr const char * name
Definition: shell.hpp:41
Definition: future.hpp:58