MCPcopy Create free account
hub / github.com/apache/mesos / getContainerInfo

Function getContainerInfo

src/cli/execute.cpp:788–915  ·  view source on GitHub ↗

TODO(jojy): Consider breaking down the method for each 'containerizer'.

Source from the content-addressed store, hash-verified

786
787// TODO(jojy): Consider breaking down the method for each 'containerizer'.
788static Result<ContainerInfo> getContainerInfo(
789 const string& containerizer,
790 const Option<vector<Volume>>& volumes,
791 const Option<string>& networks,
792 const Option<string>& appcImage,
793 const Option<string>& dockerImage,
794 const Option<CapabilityInfo>& effective_capabilities,
795 const Option<CapabilityInfo>& bounding_capabilities,
796 const Option<RLimitInfo>& rlimits,
797 const bool tty)
798{
799 if (containerizer.empty()) {
800 return None();
801 }
802
803 ContainerInfo containerInfo;
804
805 if (volumes.isSome()) {
806 foreach (const Volume& volume, volumes.get()) {
807 containerInfo.add_volumes()->CopyFrom(volume);
808 }
809 }
810
811 // Mesos containerizer supports 'appc' and 'docker' images.
812 if (containerizer == "mesos") {
813 if (!tty &&
814 appcImage.isNone() &&
815 dockerImage.isNone() &&
816 effective_capabilities.isNone() &&
817 bounding_capabilities.isNone() &&
818 rlimits.isNone() &&
819 (networks.isNone() || networks->empty()) &&
820 (volumes.isNone() || volumes->empty())) {
821 return None();
822 }
823
824 containerInfo.set_type(ContainerInfo::MESOS);
825
826 if (dockerImage.isSome()) {
827 Image* image = containerInfo.mutable_mesos()->mutable_image();
828 image->set_type(Image::DOCKER);
829 image->mutable_docker()->set_name(dockerImage.get());
830 } else if (appcImage.isSome()) {
831 Image::Appc appc;
832
833 appc.set_name(appcImage.get());
834
835 // TODO(jojy): Labels are hard coded right now. Consider
836 // adding label flags for customization.
837 Label arch;
838 arch.set_key("arch");
839 arch.set_value("amd64");
840
841 Label os;
842 os.set_key("os");
843 os.set_value("linux");
844
845 Labels labels;

Callers 3

mainFunction · 0.85
foreachFunction · 0.85
getEndpointMethod · 0.85

Calls 9

NoneClass · 0.85
tokenizeFunction · 0.85
CopyFromMethod · 0.80
ErrorFunction · 0.50
emptyMethod · 0.45
isSomeMethod · 0.45
isNoneMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected