Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
DobbyStartState.h
1 /*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2016 Sky UK
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19 /*
20  * File: DobbyStartState.h
21  *
22  */
23 #ifndef DOBBYSTARTSTATE_H
24 #define DOBBYSTARTSTATE_H
25 
26 #include <ContainerId.h>
27 #include <IDobbyStartState.h>
28 
29 #include <list>
30 #include <memory>
31 #include <mutex>
32 #include <string>
33 
34 class DobbyConfig;
35 
36 // -----------------------------------------------------------------------------
49 {
50 public:
51  DobbyStartState(const std::shared_ptr<DobbyConfig>& config,
52  const std::list<int>& files);
53  ~DobbyStartState() final;
54 
55 public:
56  bool isValid() const;
57 
58 public:
59  int addFileDescriptor(const std::string& pluginName, int fd) override;
60 
61  bool addEnvironmentVariable(const std::string& envVar) override;
62 
63  bool addMount(const std::string& source,
64  const std::string& target,
65  const std::string& fsType,
66  unsigned long mountFlags,
67  const std::list<std::string>& mountOptions) override;
68 
69  std::list<int> files() const override;
70 
71  std::list<int> files(const std::string& pluginName) const override;
72 
73 private:
74  const std::shared_ptr<DobbyConfig> mConfig;
75  std::list<std::pair<std::string, int>> mFiles;
76  bool mValid;
77  mutable std::mutex mLock;
78 };
79 
80 
81 #endif // !defined(DOBBYSTARTSTATE_H)
Interface that configuration file parser classes have to implement.
Definition: DobbyConfig.h:66
Stores the start state of the container.
Definition: DobbyStartState.h:49
bool addMount(const std::string &source, const std::string &target, const std::string &fsType, unsigned long mountFlags, const std::list< std::string > &mountOptions) override
Adds a new mount to the container.
Definition: DobbyStartState.cpp:221
bool addEnvironmentVariable(const std::string &envVar) override
Adds an environment variable to the container.
Definition: DobbyStartState.cpp:196
int addFileDescriptor(const std::string &pluginName, int fd) override
Adds another file descriptor to be passed into the container.
Definition: DobbyStartState.cpp:155
std::list< int > files() const override
Gets all file descriptor registered by any client.
Definition: DobbyStartState.cpp:91
Utility interface passed in at the post-construction phase, to allow some final tweaking of the conta...
Definition: IDobbyStartState.h:40