Task createTask( const TaskInfo& task, const TaskState& state, const FrameworkID& frameworkId) { Task t; t.mutable_framework_id()->MergeFrom(frameworkId); t.set_state(state); t.set_name(task.name()); t.mutable_task_id()->MergeFrom(task.task_id()); t.mutable_slave_id()->MergeFrom(task.slave_id()); t.mutable_resources()->MergeFrom(task.resources()); if (task.has_executor()) { t.mutable_executor_id()->CopyFrom(task.executor().executor_id()); } t.mutable_labels()->MergeFrom(task.labels()); if (task.has_discovery()) { t.mutable_discovery()->MergeFrom(task.discovery()); } return t; }
Task createTask( const TaskInfo& task, const TaskState& state, const FrameworkID& frameworkId) { Task t; t.mutable_framework_id()->CopyFrom(frameworkId); t.set_state(state); t.set_name(task.name()); t.mutable_task_id()->CopyFrom(task.task_id()); t.mutable_slave_id()->CopyFrom(task.slave_id()); t.mutable_resources()->CopyFrom(task.resources()); if (task.has_executor()) { t.mutable_executor_id()->CopyFrom(task.executor().executor_id()); } if (task.has_labels()) { t.mutable_labels()->CopyFrom(task.labels()); } if (task.has_discovery()) { t.mutable_discovery()->CopyFrom(task.discovery()); } if (task.has_container()) { t.mutable_container()->CopyFrom(task.container()); } // Copy `user` if set. if (task.has_command() && task.command().has_user()) { t.set_user(task.command().user()); } else if (task.has_executor() && task.executor().command().has_user()) { t.set_user(task.executor().command().user()); } return t; }