Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.0
current_version = 1.0.0
commit = True
tag = True

Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- Add `setup` feature for modules
- Add build profiles to control the generation of the bakefile(s)
- Add duplicate name check to config file validation
- Upgrade to pydantic 2.x
- Unit tests
- Integration (CLI) tests
2 changes: 1 addition & 1 deletion docker_printer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Composer for dockerfiles"""

__version__ = "0.4.0"
__version__ = "1.0.0"
24 changes: 11 additions & 13 deletions docker_printer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Dict, Hashable, Iterable, List, Optional, Set, Union

import jinja2
from pydantic import BaseModel, PrivateAttr, validator
from pydantic import BaseModel, PrivateAttr, RootModel, field_validator
from rich import print
from rich.tree import Tree

Expand Down Expand Up @@ -91,7 +91,8 @@ def __init__(self, **kwargs):
def __hash__(self):
return hash(self.name)

@validator("image_args", pre=True)
@field_validator("image_args", mode="before")
@classmethod
def ensure_is_dictionary(cls, v):
if isinstance(v, (list, tuple)):
return {k: None for k in v}
Expand Down Expand Up @@ -199,12 +200,10 @@ def __str__(self):
return self.name


class TargetCollection(BaseModel):
__root__: Set[Target]

class TargetCollection(RootModel[Set[Target]]):
@property
def targets(self):
return [t for t in self.__root__ if not t.exclude]
return [t for t in self.root if not t.exclude]

# def __getitem__(self, item: str) -> Target:
# try:
Expand Down Expand Up @@ -275,12 +274,13 @@ def visit_node(
class BuildConfig(BaseModel):
name: str
image: List[str]
tag_prefix: Optional[str]
tag_postfix: Optional[str]
tag_prefix: Optional[str] = None
tag_postfix: Optional[str] = None
build_args: Dict[str, Any] = {"load": True}
limit_tags: List[str] = []

@validator("image", pre=True)
@field_validator("image", mode="before")
@classmethod
def ensure_image_is_list(cls, v):
if not isinstance(v, list):
return [v]
Expand Down Expand Up @@ -331,9 +331,7 @@ def build_command(self):
return f"docker buildx bake -f docker-bake.{self.name}.json"


class BuildConfigCollection(BaseModel):
__root__: List[BuildConfig]

class BuildConfigCollection(RootModel[List[BuildConfig]]):
@property
def configs(self):
return [t for t in self.__root__]
return list(self.root)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = "docker-printer"
copyright = "2022, David Maxson"
author = "David Maxson"
release = "0.4.0"
release = "1.0.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
"pyyaml",
"jinja2",
"click",
"pydantic==1.*",
"pydantic==2.*",
"typer",
"rich"
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pyyaml
jinja2
click
pydantic==1.*
pydantic==2.*
typer
rich