Repository: mesos
Updated Branches:
  refs/heads/master 974581bdb -> 25f4feae4


Add protobuf messages for OCI image spec.

Review: https://reviews.apache.org/r/52349/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6726cd19
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6726cd19
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6726cd19

Branch: refs/heads/master
Commit: 6726cd19cad23480d68f92fe3b6019b9452ab1e7
Parents: 974581b
Author: Qian Zhang <zhq527...@gmail.com>
Authored: Tue Feb 7 16:54:24 2017 +0800
Committer: Qian Zhang <zhq527...@gmail.com>
Committed: Tue Feb 7 16:54:24 2017 +0800

----------------------------------------------------------------------
 include/mesos/oci/spec.hpp   |  34 +++++++++
 include/mesos/oci/spec.proto | 156 ++++++++++++++++++++++++++++++++++++++
 src/Makefile.am              |  13 ++++
 3 files changed, 203 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6726cd19/include/mesos/oci/spec.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/oci/spec.hpp b/include/mesos/oci/spec.hpp
new file mode 100644
index 0000000..ac0b063
--- /dev/null
+++ b/include/mesos/oci/spec.hpp
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.
+
+#ifndef __MESOS_OCI_SPEC_HPP__
+#define __MESOS_OCI_SPEC_HPP__
+
+#include <mesos/oci/spec.pb.h>
+
+namespace oci {
+namespace spec {
+namespace image {
+namespace v1 {
+
+// TODO(qianzhang): Add methods to parse OCI image spec
+
+} // namespace v1 {
+} // namespace image {
+} // namespace spec {
+} // namespace oci {
+
+#endif // __MESOS_OCI_SPEC_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/6726cd19/include/mesos/oci/spec.proto
----------------------------------------------------------------------
diff --git a/include/mesos/oci/spec.proto b/include/mesos/oci/spec.proto
new file mode 100644
index 0000000..f3083dd
--- /dev/null
+++ b/include/mesos/oci/spec.proto
@@ -0,0 +1,156 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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 oci.spec.image.v1;
+
+/**
+ * Protobuf for the OCI content descriptor JSON schema:
+ * https://github.com/opencontainers/image-spec/blob/master/descriptor.md
+ */
+message Descriptor {
+  // Media types identify their referenced resources, see more details in:
+  // https://github.com/opencontainers/image-spec/blob/master/media-types.md
+  required string mediaType = 1;
+  required string digest = 2;
+  required int64 size = 3;
+  repeated string urls = 4;
+}
+
+
+message Platform {
+  required string architecture = 1;
+  required string os = 2;
+
+  // NOTE: The actual field names in OCI spec are 'os.version' and 
'os.features',
+  // but we can not use them in protobuf message since "." is not allowed in
+  // field name, so these two fields will be handled manually during parsing.
+  optional string os_version = 3;
+  repeated string os_features = 4;
+  optional string variant = 5;
+  repeated string features = 6;
+}
+
+
+message ManifestDescriptor {
+  required string mediaType = 1;
+  required string digest = 2;
+  required int64 size = 3;
+  required Platform platform = 4;
+  repeated string urls = 5;
+}
+
+
+/**
+ * Protobuf for the string-string map field entry.
+ */
+message Label {
+  required string key = 1;
+  required string value = 2;
+}
+
+
+/**
+ * Protobuf for the OCI image manifest list JSON schema:
+ * https://github.com/opencontainers/image-spec/blob/master/manifest-list.md
+ *
+ * The OCI MIME type of this message is:
+ *   application/vnd.oci.image.manifest.list.v1+json
+ */
+message ManifestList {
+  required int64 schemaVersion = 1;
+  repeated ManifestDescriptor manifests = 2;
+
+  // NOTE: We cannot use 'annotations' here because otherwise,
+  // json->protobuf parsing will fail. 'Annotations' is manually
+  // set during parsing.
+  repeated Label Annotations = 3;
+}
+
+
+/**
+ * Protobuf for the OCI image manifest JSON schema:
+ * https://github.com/opencontainers/image-spec/blob/master/manifest.md
+ *
+ * The OCI MIME type of this message is:
+ *   application/vnd.oci.image.manifest.v1+json
+ */
+message Manifest {
+  required int64 schemaVersion = 1;
+  required Descriptor config = 2;
+  repeated Descriptor layers = 3;
+
+  // NOTE: We cannot use 'annotations' here because otherwise,
+  // json->protobuf parsing will fail. 'Annotations' is manually
+  // set during parsing.
+  repeated Label Annotations = 4;
+}
+
+
+/**
+ * Protobuf for the OCI image configuration JSON schema:
+ * https://github.com/opencontainers/image-spec/blob/master/config.md
+ *
+ * The OCI MIME type of this message is:
+ *   application/vnd.oci.image.config.v1+json
+ */
+message Configuration {
+  required string architecture = 1;
+  required string os = 2;
+
+  message Rootfs {
+    required string type = 1;
+    repeated string diff_ids = 2;
+  }
+
+  required Rootfs rootfs = 3;
+  optional string created = 4;
+  optional string author = 5;
+
+  message Config {
+    optional string User = 1;
+
+    // NOTE: We cannot use 'ExposedPorts' here because otherwise,
+    // json->protobuf parsing will fail. 'exposedPorts' is manually
+    // set during parsing.
+    repeated string exposedPorts = 2;
+    repeated string Env = 3;
+    repeated string Entrypoint = 4;
+    repeated string Cmd = 5;
+
+    // NOTE: We cannot use 'Volumes' here because otherwise,
+    // json->protobuf parsing will fail. 'volumes' is manually
+    // set during parsing.
+    repeated string volumes = 6;
+    optional string WorkingDir = 7;
+
+    // NOTE: We cannot use 'Labels' here because otherwise,
+    // json->protobuf parsing will fail. 'labels' is manually
+    // set during parsing.
+    repeated Label labels = 8;
+  }
+
+  optional Config config = 6;
+
+  message History {
+    optional string created = 1;
+    optional string author = 2;
+    optional string created_by = 3;
+    optional string comment = 4;
+    optional bool empty_layer = 5;
+  }
+
+  repeated History history = 7;
+}

http://git-wip-us.apache.org/repos/asf/mesos/blob/6726cd19/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 78d55d8..f432571 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -240,6 +240,7 @@ MAINTENANCE_PROTO = 
$(top_srcdir)/include/mesos/maintenance/maintenance.proto
 MASTER_PROTO = $(top_srcdir)/include/mesos/master/master.proto
 MESOS_PROTO = $(top_srcdir)/include/mesos/mesos.proto
 MODULE_PROTO = $(top_srcdir)/include/mesos/module/module.proto
+OCI_SPEC_PROTO = $(top_srcdir)/include/mesos/oci/spec.proto
 QUOTA_PROTO = $(top_srcdir)/include/mesos/quota/quota.proto
 SCHEDULER_PROTO = $(top_srcdir)/include/mesos/scheduler/scheduler.proto
 STATE_PROTO = $(top_srcdir)/include/mesos/state/state.proto
@@ -288,6 +289,8 @@ CXX_PROTOS =                                                
                \
   ../include/mesos/module/hook.pb.h                                    \
   ../include/mesos/module/module.pb.cc                                 \
   ../include/mesos/module/module.pb.h                                  \
+  ../include/mesos/oci/spec.pb.cc                                      \
+  ../include/mesos/oci/spec.pb.h                                       \
   ../include/mesos/quota/quota.pb.cc                                   \
   ../include/mesos/quota/quota.pb.h                                    \
   ../include/mesos/scheduler/scheduler.pb.cc                           \
@@ -656,6 +659,15 @@ nodist_module_HEADERS =                                    
                \
   ../include/mesos/module/hook.pb.h                                    \
   ../include/mesos/module/module.pb.h
 
+ocidir = $(pkgincludedir)/oci
+
+oci_HEADERS =                                                          \
+  $(top_srcdir)/include/mesos/oci/spec.hpp                             \
+  $(top_srcdir)/include/mesos/oci/spec.proto
+
+nodist_oci_HEADERS =                                                   \
+  ../include/mesos/oci/spec.pb.h
+
 quotadir = $(pkgincludedir)/quota
 
 quota_HEADERS =                                                                
\
@@ -1386,6 +1398,7 @@ libmesos_la_SOURCES =                                     
                \
   $(MASTER_PROTO)                                                      \
   $(MESOS_PROTO)                                                       \
   $(MODULE_PROTO)                                                      \
+  $(OCI_SPEC_PROTO)                                                    \
   $(OVERSUBSCRIPTION_PROTO)                                            \
   $(QUOTA_PROTO)                                                       \
   $(SCHEDULER_PROTO)                                                   \

Reply via email to