rcds.challenge — Challenges¶
-
class
rcds.ChallengeLoader(project: rcds.Project)[source]¶ Class for loading a
Challengewithin the context of arcds.Project-
load(root: pathlib.Path)[source]¶ Load a challenge by path
The challenge must be within the project associated with this loader.
- Parameters
root (pathlib.Path) – Path to challenge root
-
-
class
rcds.Challenge(project: Project, root: pathlib.Path, config: dict)[source]¶ A challenge within a given
rcds.ProjectThis class is not meant to be constructed directly, use a
ChallengeLoaderto load a challenge.-
create_transaction() → AssetManagerTransaction[source]¶ Get a transaction to update this challenge’s assets
-
get_relative_path() → pathlib.Path[source]¶ Utiity function to get this challenge’s path relative to the project root
-
rcds.challenge.config - Config loading¶
-
class
rcds.challenge.config.ConfigLoader(project: Project)[source]¶ Object that manages loading challenge config files
-
check_config(config_file: pathlib.Path) → Tuple[Optional[Dict[str, Any]], Optional[Iterable[rcds.errors.ValidationError]]][source]¶ Load and validate a config file, returning any errors encountered.
If the config file is valid, the tuple returned contains the loaded config as the first element, and the second element is None. Otherwise, the second element is an iterable of errors that occurred during validation
This method wraps
parse_config().- Parameters
config_file (pathlib.Path) – The challenge config to load
-
load_config(config_file: pathlib.Path) → Dict[str, Any][source]¶ Loads a config file, or throw an exception if it is not valid
This method wraps
check_config(), and throws the first error returned if there are any errors.- Parameters
config_file (pathlib.Path) – The challenge config to load
- Returns
The loaded config
-
parse_config(config_file: pathlib.Path) → Iterable[Union[rcds.errors.ValidationError, Dict[str, Any]]][source]¶ Load and validate a config file, returning both the config and any errors encountered.
- Parameters
config_file (pathlib.Path) – The challenge config to load
- Returns
Iterable containing any errors (all instances of
rcds.errors.ValidationError) and the parsed config. The config will always be last.
-
-
exception
rcds.challenge.config.TargetFileNotFoundError(message: str, target: pathlib.Path)[source]¶
rcds.challenge.docker - Docker containers¶
-
rcds.challenge.docker.get_context_files(root: pathlib.Path) → Iterator[pathlib.Path][source]¶ Generate a list of all files in the build context of the specified Dockerfile
- Parameters
root (pathlib.Path) – Path to the containing directory of the Dockerfile to analyze
-
rcds.challenge.docker.generate_sum(root: pathlib.Path) → str[source]¶ Generate a checksum of all files in the build context of the specified directory
- Parameters
root (pathlib.Path) – Path to the containing directory of the Dockerfile to analyze
-
class
rcds.challenge.docker.ContainerManager(challenge: Challenge)[source]¶ Object managing all containers defined by a given
rcds.Challenge-
__init__(challenge: Challenge)[source]¶ - Parameters
challenge (rcds.Challenge) – The challenge that this ContainerManager belongs to
-
-
class
rcds.challenge.docker.Container(*, container_manager: rcds.challenge.docker.ContainerManager, name: str)[source]¶ A single container
-
build(force: bool = False) → None[source]¶ Build the challenge if applicable and necessary.
For challenges that are not buildable (
IS_BUILDABLEis False), this method is a no-op- Parameters
force (bool) – Force a rebuild of this container even if it is up-to-date
-
get_full_tag() → str[source]¶ Get the full image tag (e.g.
k8s.gcr.io/etcd:3.4.3-0) for this container- Returns
The image tag
-
is_built() → bool[source]¶ If the container is buildable (
IS_BUILDABLEis True), this method returns whether or not the container is already built (and up-to-date). For non-buildable containers, this method always returns True.- Returns
Whether or not the container is built
-
-
class
rcds.challenge.docker.BuildableContainer(**kwargs)[source]¶ A container that is built from source
-
build(force: bool = False) → None[source]¶ Build the challenge if applicable and necessary.
For challenges that are not buildable (
IS_BUILDABLEis False), this method is a no-op- Parameters
force (bool) – Force a rebuild of this container even if it is up-to-date
-