Skip to content

Commit 4a651b3

Browse files
committed
Merge branches 'w/132.0/improvement/add-crl-operator' and 'q/w/4692/131.0/improvement/add-crl-operator' into tmp/octopus/q/132.0
3 parents 4d24864 + 2b0c9da + ae91bcb commit 4a651b3

File tree

19 files changed

+1038
-32
lines changed

19 files changed

+1038
-32
lines changed

.devcontainer/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,10 @@ RUN curl --fail -L -o /tmp/skopeo.tar.gz https://github.com/containers/skopeo/ar
111111
sudo mv bin/skopeo /usr/local/bin/ && \
112112
cd && \
113113
rm -rf /tmp/skopeo.tar.gz /tmp/skopeo-${SKOPEO_VERSION}
114+
115+
# Install kustomize
116+
ARG KUSTOMIZE_VERSION=5.7.1
117+
118+
RUN curl --fail -L -o /tmp/kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz && \
119+
sudo tar -xzf /tmp/kustomize.tar.gz -C /usr/local/bin/ kustomize && \
120+
rm -rf /tmp/kustomize.tar.gz

.pylint-dict

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ cp
1919
checksum
2020
checksums
2121
containerd
22+
CRL
23+
crl
2224
dataset
2325
de
2426
debuild
@@ -37,6 +39,7 @@ getitem
3739
globals
3840
gofmt
3941
Kube
42+
kustomize
4043
html
4144
init
4245
io
@@ -52,6 +55,7 @@ metadata
5255
mkdir
5356
mkisofs
5457
mypy
58+
namespace
5559
nginx
5660
observability
5761
pdf

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313
## Release 131.0.2 (in development)
1414

15+
### Enhancements
16+
17+
- Install [crl-operator](https://github.com/scality/crl-operator) version
18+
[v1.0.0](https://github.com/scality/crl-operator/releases/tag/v1.0.0) by default
19+
(PR[#4692](https://github.com/scality/metalk8s/pull/4692))
20+
1521
## Release 131.0.1
1622

1723
## Release 131.0.0

buildchain/buildchain/codegen.py

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,16 @@
55

66

77
import shlex
8-
from typing import Callable, Iterator, Tuple
8+
from typing import Callable, Iterator, Tuple, Dict
99

1010
import doit # type: ignore
1111

1212
from buildchain import constants
13+
from buildchain import targets
1314
from buildchain import types
1415
from buildchain import utils
1516

1617

17-
def get_task_information() -> types.TaskDict:
18-
"""Retrieve all the task information from codegen"""
19-
result: types.TaskDict = {
20-
"actions": [],
21-
"task_dep": [],
22-
"file_dep": [],
23-
}
24-
for task_fun in CODEGEN:
25-
task = task_fun()
26-
for key, value in result.items():
27-
value.extend(task.get(key, []))
28-
29-
return result
30-
31-
3218
def task_codegen() -> Iterator[types.TaskDict]:
3319
"""Run the code generation tools."""
3420
for create_codegen_task in CODEGEN:
@@ -333,6 +319,65 @@ def codegen_chart_cert_manager() -> types.TaskDict:
333319
}
334320

335321

322+
def task_get_codegen_kustomize_crl_operator() -> types.TaskDict:
323+
"""Generate the kustomize manifests output for the CRL Operator."""
324+
kustomize_dir = constants.ROOT / "kustomizes/crl-operator"
325+
326+
cmd = f"kustomize build {kustomize_dir}"
327+
328+
return {
329+
"doc": task_get_codegen_kustomize_crl_operator.__doc__,
330+
"actions": [doit.action.CmdAction(cmd, cwd=constants.ROOT, save_out="stdout")],
331+
"file_dep": list(utils.git_ls(kustomize_dir)),
332+
"task_dep": ["check_for:kustomize"],
333+
}
334+
335+
336+
def task_transform_codegen_kustomize_crl_operator() -> types.TaskDict:
337+
"""Transform the kustomize manifests output for the CRL Operator."""
338+
339+
def _transform(stdout: str) -> Dict[str, str]:
340+
"""Transform the kustomize output."""
341+
# Note: We have to replace the namespace 'crl-operator-system' by
342+
# 'metalk8s-certs' as kustomize does not allow easily to patch every
343+
# occurrence in "custom resources fields" like Certificate dnsNames.
344+
return {
345+
"output": stdout.strip().replace("crl-operator-system", "metalk8s-certs")
346+
}
347+
348+
return {
349+
"doc": task_transform_codegen_kustomize_crl_operator.__doc__,
350+
"actions": [_transform],
351+
"task_dep": ["get_codegen_kustomize_crl_operator"],
352+
"getargs": {
353+
"stdout": ("get_codegen_kustomize_crl_operator", "stdout"),
354+
},
355+
}
356+
357+
358+
def codegen_kustomize_crl_operator() -> types.TaskDict:
359+
"""Generate the SLS file for the CRL Operator."""
360+
target_sls = constants.ROOT / "salt/metalk8s/addons/crl-operator/deployed/chart.sls"
361+
template_file = constants.ROOT / "kustomizes/template.sls.in"
362+
363+
tpl_task = targets.TemplateFile(
364+
task_name="kustomize_crl-operator",
365+
source=template_file,
366+
destination=target_sls,
367+
)
368+
tpl_task_dict = tpl_task.task
369+
tpl_task_dict.update(
370+
{
371+
"title": utils.title_with_subtask_name("CODEGEN"),
372+
"task_dep": ["transform_codegen_kustomize_crl_operator"],
373+
"getargs": {
374+
"Manifests": ("transform_codegen_kustomize_crl_operator", "output"),
375+
},
376+
}
377+
)
378+
return tpl_task_dict
379+
380+
336381
# List of available code generation tasks.
337382
CODEGEN: Tuple[Callable[[], types.TaskDict], ...] = (
338383
codegen_storage_operator,
@@ -345,6 +390,7 @@ def codegen_chart_cert_manager() -> types.TaskDict:
345390
codegen_chart_prometheus_adapter,
346391
codegen_chart_thanos,
347392
codegen_chart_cert_manager,
393+
codegen_kustomize_crl_operator,
348394
)
349395

350396

buildchain/buildchain/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ExtCommand(enum.Enum):
6565
SKOPEO = os.getenv("SKOPEO_BIN", "skopeo")
6666
TOX = os.getenv("TOX_BIN", "tox")
6767
VAGRANT = os.getenv("VAGRANT_BIN", "vagrant")
68+
KUSTOMIZE = os.getenv("KUSTOMIZE_BIN", "kustomize")
6869

6970
@property
7071
def command_name(self) -> str:

buildchain/buildchain/image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def _local_image(name: str, **kwargs: Any) -> targets.LocalImage:
219219
],
220220
constants.SCALITY_REPOSITORY: [
221221
"ui-operator",
222+
"crl-operator",
222223
],
223224
}
224225

buildchain/buildchain/lint.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from buildchain import constants
4242
from buildchain import types
4343
from buildchain import utils
44-
from buildchain import codegen
4544

4645

4746
def task_lint() -> Iterator[types.TaskDict]:
@@ -195,16 +194,13 @@ def lint_codegen() -> types.TaskDict:
195194
git_diff = [config.ExtCommand.GIT.value, "diff"]
196195
base = subprocess.check_output(git_diff)
197196

198-
task = codegen.get_task_information()
199-
task["actions"].append(lambda: check_diff_codegen(base))
200-
task.update(
201-
{
202-
"name": "codegen",
203-
"title": utils.title_with_subtask_name("LINT"),
204-
"doc": lint_codegen.__doc__,
205-
}
206-
)
207-
return task
197+
return {
198+
"name": "codegen",
199+
"title": utils.title_with_subtask_name("LINT"),
200+
"doc": lint_codegen.__doc__,
201+
"actions": [lambda: check_diff_codegen(base)],
202+
"task_dep": ["codegen"],
203+
}
208204

209205

210206
# }}}

buildchain/buildchain/salt_tree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ def _download_ui_operator_crds() -> str:
292292
Path("salt/metalk8s/addons/cert-manager/deployed/chart.sls"),
293293
Path("salt/metalk8s/addons/cert-manager/deployed/init.sls"),
294294
Path("salt/metalk8s/addons/cert-manager/deployed/namespace.sls"),
295+
Path("salt/metalk8s/addons/crl-operator/deployed/chart.sls"),
296+
Path("salt/metalk8s/addons/crl-operator/deployed/init.sls"),
295297
Path("salt/metalk8s/addons/dex/ca/init.sls"),
296298
Path("salt/metalk8s/addons/dex/ca/installed.sls"),
297299
Path("salt/metalk8s/addons/dex/ca/advertised.sls"),

buildchain/buildchain/targets/template.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import shutil
88
import string
9-
from typing import Any, Dict
9+
from typing import Any, Dict, Optional
1010
from pathlib import Path
1111

1212
from buildchain import types
@@ -28,7 +28,11 @@ class TemplateFile(base.AtomicTarget):
2828
"""Create a new file from a template file."""
2929

3030
def __init__(
31-
self, source: Path, destination: Path, context: Dict[str, Any], **kwargs: Any
31+
self,
32+
source: Path,
33+
destination: Path,
34+
context: Optional[Dict[str, Any]] = None,
35+
**kwargs: Any,
3236
):
3337
"""Configure a template rendering task.
3438
@@ -46,7 +50,7 @@ def __init__(
4650
super().__init__(**kwargs)
4751
self._src = source
4852
self._dst = destination
49-
self._ctx = context
53+
self._ctx = context or {}
5054

5155
@property
5256
def task(self) -> types.TaskDict:
@@ -60,10 +64,10 @@ def task(self) -> types.TaskDict:
6064
)
6165
return task
6266

63-
def _run(self) -> None:
67+
def _run(self, **extra_ctx: Any) -> None:
6468
"""Render the template."""
6569
template = self._src.read_text(encoding="utf-8")
66-
rendered = CustomTemplate(template).substitute(**self._ctx)
70+
rendered = CustomTemplate(template).substitute(**self._ctx, **extra_ctx)
6771
self._dst.write_text(rendered, encoding="utf-8")
6872
# Preserve the permission bits.
6973
shutil.copymode(self._src, self._dst)

buildchain/buildchain/versions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
302302
version=_version_prefix(CERT_MANAGER_VERSION),
303303
digest="sha256:a076f72f33a22dfd3a23727f1e1a069817819406b39e5b0fd9cb97d3338cb8d8",
304304
),
305+
Image(
306+
name="crl-operator",
307+
version="v1.0.0",
308+
digest="sha256:86b4198036c1f83f1d9363a1e2ae78015482ca4fe60cd706939b8730c179ac8a",
309+
),
305310
)
306311

307312
CONTAINER_IMAGES_MAP = {image.name: image for image in CONTAINER_IMAGES}

0 commit comments

Comments
 (0)