Skip to content

Instantly share code, notes, and snippets.

@bergwolf
Created November 1, 2017 01:43
Show Gist options
  • Save bergwolf/c1dab2956a422dac4831d5dd9e3c3587 to your computer and use it in GitHub Desktop.
Save bergwolf/c1dab2956a422dac4831d5dd9e3c3587 to your computer and use it in GitHub Desktop.
  1. spec.proto
syntax = "proto3";

package specs;

message Spec {
        string Version = 1;
        Process Process = 2;
        string Hostname = 4;
        map<string, string> Annotations = 7;
        Linux Linux = 8;
        Solaris Solaris = 9;
}

message Process {
        bool Terminal = 1;
        repeated string Args = 4;
        repeated string Env = 5;
        string Cwd = 6;
        LinuxCapabilities Capabilities = 7;
}

// LinuxCapabilities specifies the whitelist of capabilities that are kept for a process.
// http://man7.org/linux/man-pages/man7/capabilities.7.html
message LinuxCapabilities {
        // Bounding is the set of capabilities checked by the kernel.
        repeated string Bounding = 1;
        // Effective is the set of capabilities checked by the kernel.
        repeated string Effective = 2;
        // Inheritable is the capabilities preserved across execve.
        repeated string Inheritable = 3;
        // Permitted is the limiting superset for effective capabilities.
        repeated string Permitted = 4;
        // Ambient is the ambient set of capabilities that are kept.
        repeated string Ambient = 5;
}

// Linux contains platform-specific configuration for Linux based containers.
message Linux {
        // Sysctl are a set of key value pairs that are set for the container on start
        map<string, string> Sysctl = 1;
}
// Solaris contains platform-specific configuration for Solaris application containers.
message Solaris {
        // SMF FMRI which should go "online" before we start the container process.
        string Milestone = 1;
        // Maximum set of privileges any process in this container can obtain.
        string LimitPriv = 2;
        // The maximum amount of shared memory allowed for this container.
        string MaxShmMemory = 3;
        // Specification for automatic creation of network resources for this container.
        repeated SolarisAnet Anet = 4;
        // Set limit on the amount of CPU time that can be used by container.
        SolarisCappedCPU CappedCPU = 5;
        // The physical and swap caps on the memory that can be used by this container.
        SolarisCappedMemory CappedMemory = 6;
}

// SolarisCappedCPU allows users to set limit on the amount of CPU time that can be used by container.
message SolarisCappedCPU {
        string Ncpus = 1;
}

// SolarisCappedMemory allows users to set the physical and swap caps on the memory that can be used by this container.
message SolarisCappedMemory {
        string Physical = 1;
        string Swap = 2;
}

// SolarisAnet provides the specification for automatic creation of network resources for this container.
message SolarisAnet {
        // Specify a name for the automatically created VNIC datalink.
        string Linkname = 1;
}
  1. go-grpc generated spec.pb.go:
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: spec.proto

/*
Package specs is a generated protocol buffer package.

It is generated from these files:
        spec.proto

It has these top-level messages:
        Spec
        Process
        LinuxCapabilities
        Linux
        Solaris
        SolarisCappedCPU
        SolarisCappedMemory
        SolarisAnet
*/
package specs

import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package

type Spec struct {
        Version     string            `protobuf:"bytes,1,opt,name=Version" json:"Version,omitempty"`
        Process     *Process          `protobuf:"bytes,2,opt,name=Process" json:"Process,omitempty"`
        Hostname    string            `protobuf:"bytes,4,opt,name=Hostname" json:"Hostname,omitempty"`
        Annotations map[string]string `protobuf:"bytes,7,rep,name=Annotations" json:"Annotations,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
        Linux       *Linux            `protobuf:"bytes,8,opt,name=Linux" json:"Linux,omitempty"`
        Solaris     *Solaris          `protobuf:"bytes,9,opt,name=Solaris" json:"Solaris,omitempty"`
}

<rests snipped>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment