diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-06 13:07:52 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-06 13:07:52 -0500 |
commit | 0b85e832aa2b050b91b9a3d948dff1984554bcd8 (patch) | |
tree | d640941d335bfcdf25381d214e9b60b34a6b7819 | |
parent | 128c67fd16af66219a98470265a1ff842c345041 (diff) | |
download | horizon-0b85e832aa2b050b91b9a3d948dff1984554bcd8.tar.gz horizon-0b85e832aa2b050b91b9a3d948dff1984554bcd8.tar.bz2 horizon-0b85e832aa2b050b91b9a3d948dff1984554bcd8.tar.xz horizon-0b85e832aa2b050b91b9a3d948dff1984554bcd8.zip |
More API stuff
-rw-r--r-- | hscript/disk.hh | 5 | ||||
-rw-r--r-- | hscript/key.hh | 19 | ||||
-rw-r--r-- | hscript/meta.hh | 8 | ||||
-rw-r--r-- | hscript/network.hh | 11 | ||||
-rw-r--r-- | hscript/script.cc | 19 | ||||
-rw-r--r-- | hscript/script.hh | 28 | ||||
-rw-r--r-- | hscript/user.hh | 11 |
7 files changed, 83 insertions, 18 deletions
diff --git a/hscript/disk.hh b/hscript/disk.hh index cddbb10..560e30a 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -10,6 +10,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_DISK_HH_ +#define __HSCRIPT_DISK_HH_ + #include "key.hh" namespace Horizon { @@ -32,3 +35,5 @@ class Mount : public Key { } } + +#endif /* !__HSCRIPT_DISK_HH_ */ diff --git a/hscript/key.hh b/hscript/key.hh index cce1460..6a18466 100644 --- a/hscript/key.hh +++ b/hscript/key.hh @@ -10,6 +10,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_KEY_HH_ +#define __HSCRIPT_KEY_HH_ + #include <string> namespace Horizon { @@ -21,17 +24,23 @@ namespace Keys { */ class Key { public: - /*! Set the data associated with the Key. */ - void setData(std::string data); + virtual ~Key(); + + /*! Create the Key object with the specified data as the entire value. + * @returns nullptr if data is unparsable, otherwise a pointer to a Key. + */ + static Key *parseFromData(std::string) { return nullptr; } /*! Determines if the data associated with the Key is valid. */ - bool validate(); + virtual bool validate() = 0; /*! Executes the action associated with this Key. - * Will always return `false` if `validate` is `false`. + * @note Will always return `false` if `validate` is `false`. */ - bool execute(); + virtual bool execute() = 0; }; } } + +#endif diff --git a/hscript/meta.hh b/hscript/meta.hh index c1eba90..0446274 100644 --- a/hscript/meta.hh +++ b/hscript/meta.hh @@ -10,12 +10,18 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_META_HH_ +#define __HSCRIPT_META_HH_ + #include "key.hh" namespace Horizon { namespace Keys { - +class Hostname : public Key { +}; } } + +#endif /* !__HSCRIPT_META_HH_ */ diff --git a/hscript/network.hh b/hscript/network.hh index 4c21155..68132c7 100644 --- a/hscript/network.hh +++ b/hscript/network.hh @@ -10,11 +10,20 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_NETWORK_HH_ +#define __HSCRIPT_NETWORK_HH_ + #include "key.hh" namespace Horizon { namespace Keys { +class Network : public Key { +public: + /*! Determine if networking is enabled. */ + bool enabled(); +}; + class NetAddress : public Key { }; @@ -23,3 +32,5 @@ class NetSSID : public Key { } } + +#endif /* !__HSCRIPT_NETWORK_HH */ diff --git a/hscript/script.cc b/hscript/script.cc index 72f9dd8..876efa4 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -12,18 +12,21 @@ #include "script.hh" #include "disk.hh" +#include "meta.hh" +#include "network.hh" +#include "user.hh" namespace Horizon { struct Script::ScriptPrivate { /*! Determines whether or not to enable networking. */ - bool network; + std::unique_ptr<Horizon::Keys::Network> network; /*! The target system's hostname. */ - std::string hostname; + std::unique_ptr<Horizon::Keys::Hostname> hostname; /*! The packages to install to the target system. */ std::vector<std::string> packages; /*! The root shadow line. */ - std::string rootpw; + std::unique_ptr<Horizon::Keys::RootPassphrase> rootpw; /*! Target system's mountpoints. */ std::vector< std::unique_ptr<Horizon::Keys::Mount> > mounts; }; @@ -31,16 +34,16 @@ struct Script::ScriptPrivate { Script::Script() { } -bool Script::load(std::string path) { +const Script *Script::load(std::string, ScriptOptions) { + return nullptr; } -bool Script::load(std::istream &stream) { -} - -bool Script::parse() { +const Script *Script::load(std::istream &, ScriptOptions) { + return nullptr; } bool Script::validate() { + return false; } } diff --git a/hscript/script.hh b/hscript/script.hh index 2abadd9..a2c2551 100644 --- a/hscript/script.hh +++ b/hscript/script.hh @@ -10,12 +10,30 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_SCRIPT_HH_ +#define __HSCRIPT_SCRIPT_HH_ + #include <string> #include <vector> #include <memory> namespace Horizon { +/**** Script option flags ****/ + +/*! Don't stop after the first error. */ +#define SCRIPT_KEEP_GOING 0x0001 +/*! Ensure network resources are available. */ +#define SCRIPT_USE_NETWORK 0x0002 +/*! Treat warnings as errors. */ +#define SCRIPT_STRICT_MODE 0x0004 +/*! This is an Installation Environment - validate more keys */ +#define SCRIPT_INSTALL_ENV 0x0008 + + +typedef uint32_t ScriptOptions; + + /*! Defines the Script class, which represents a HorizonScript. */ class Script { public: @@ -24,17 +42,17 @@ public: /*! Load a HorizonScript from the specified path. * @param path The path to load from. + * @param options Options to use for parsing, validation, and execution. * @return true if the Script could be loaded; false otherwise. */ - bool load(std::string path); + static const Script *load(std::string path, ScriptOptions options = 0); /*! Load a HorizonScript from the specified stream. * @param stream The stream to load from. + * @param options Options to use for parsing, validation, and execution. * @return true if the Script could be loaded; false otherwise. */ - bool load(std::istream &stream); + static const Script *load(std::istream &stream, ScriptOptions options = 0); - /*! Parses the HorizonScript. */ - bool parse(); /*! Determines if the HorizonScript is valid. */ bool validate(); @@ -45,3 +63,5 @@ private: }; } + +#endif /* !__HSCRIPT_SCRIPT_HH_ */ diff --git a/hscript/user.hh b/hscript/user.hh index af42519..39a3eea 100644 --- a/hscript/user.hh +++ b/hscript/user.hh @@ -10,11 +10,20 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#ifndef __HSCRIPT_USER_HH_ +#define __HSCRIPT_USER_HH_ + #include "key.hh" namespace Horizon { namespace Keys { +class RootPassphrase : public Key { +}; + +class Username : public Key { +}; + class UserAlias : public Key { }; @@ -29,3 +38,5 @@ class UserGroups : public Key { } } + +#endif /* !__HSCRIPT_USER_HH_ */ |