Skip to content

Commit

Permalink
Merge pull request #75 from shanejbrown/main
Browse files Browse the repository at this point in the history
Update config validation
  • Loading branch information
shanejbrown authored Sep 20, 2023
2 parents 2a8c802 + 9ac5bf4 commit d285214
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ within service container configuration:
- 8.8.4.4
# A custom dns search path to use in the service container.
dns-search: mydomain.com
dns_search: mydomain.com
# Add entries to the hosts file
# The keys are the hostnames. The values can be either
Expand Down
2 changes: 1 addition & 1 deletion buildrunner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def load_config(self, cfg_file, ctx=None, log_file=True):

errors = validate_config(**config)
if errors:
raise BuildRunnerConfigurationError(f'Invalid configuration - {errors.count()} errors found:'
raise BuildRunnerConfigurationError(f'Invalid configuration, {errors.count()} error(s) found:'
f'\n{errors}')

return config
Expand Down
5 changes: 2 additions & 3 deletions buildrunner/validation/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class RunAndServicesBase(BaseModel):
dns: Optional[List[str]]
dns_search: Optional[str]
extra_hosts: Optional[Dict[str, str]]
env: Optional[Dict[str, str]]
env: Optional[Dict[str, Optional[str]]]
files: Optional[Dict[str, str]]
volumes_from: Optional[List[str]]
ports: Optional[Dict[str, str]]
ports: Optional[Dict[int, Optional[Union[int, None]]]]
pull: Optional[bool]
systemd: Optional[bool]
containers: Optional[List[str]]
Expand All @@ -68,7 +68,6 @@ class RunAndServicesBase(BaseModel):
class Service(RunAndServicesBase, extra='forbid'):
""" Service model """
build: Optional[Union[StepBuild, str]]
dns_search: Optional[str] = Field(alias='dns-search')
wait_for: Optional[List[Any]]
inject_ssh_agent: Optional[bool] = Field(alias='inject-ssh-agent')
# Not sure if this is valid, but it is in a test file
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config_validation/test_validation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_multiple_errors():
assert errors.count() == 2


def test_doc_confg():
def test_doc_config():
# Tests the documentation example with minimal changes to make valid yaml
config_yaml = """
version: 2.0
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_doc_confg():
# A map specifying ports to expose, this is only used when the
# --publish-ports parameter is passed to buildrunner
ports:
<container port>: <host port>
5458: 8080
# A list specifying service containers (see below) whose exposed
# volumes should be mapped into the run container's file system.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config_validation/test_validation_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_services():
- 8.8.4.4
# A custom dns search path to use in the service container.
dns-search: mydomain.com
dns_search: mydomain.com
# Add entries to the hosts file
# The keys are the hostnames. The values can be either
Expand Down Expand Up @@ -372,7 +372,7 @@ def test_services():
# A map specifying ports to expose and link within other containers
# within the step.
ports:
<container port>: <host port>
8081: 8080
# Whether or not to pull the image from upstream prior to running
# the step. This is almost always desirable, as it ensures the
Expand Down

0 comments on commit d285214

Please sign in to comment.