magic-pocket-cli 0.46.2__tar.gz → 0.48.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/.gitignore +1 -3
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/PKG-INFO +2 -2
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/main_cli.py +2 -2
- magic_pocket_cli-0.48.0/pocket_cli/cli/static_cli.py +32 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/django_cli.py +5 -3
- magic_pocket_cli-0.48.0/pocket_cli/paths.py +24 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/__init__.py +9 -1
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/codebuild.py +4 -3
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/context_check.py +5 -5
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/depot.py +5 -3
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/docker.py +5 -3
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/ecr.py +3 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront.py +18 -3
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/container.py +0 -17
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pyproject.toml +2 -2
- magic_pocket_cli-0.46.2/pocket_cli/cli/runtime_config_cli.py +0 -272
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/__init__.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/__init__.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/aws_auth.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/backup_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/build_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cleanup_deprecated_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_keys_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cloudfront_waf_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/container_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/deploy_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/destroy_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/dsql_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/image_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/inbound_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/interaction.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/migrate_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/neon_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/permissions_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/rds_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/removed_flags.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/resource_helper.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/s3_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/status_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/store_url_helper.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/tidb_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/upstash_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/url_helper.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/vpc_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/waf_cli.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/mediator.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/migrations.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/__init__.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/__init__.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_common.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_legacy.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/dockerignore.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/cloudformation.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/efs.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/iam_roles.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/lambdahandler.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/poll.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/s3_utils.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/stack_backed.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/stage_roles.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/state.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/backup.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_acm.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_keys.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/cloudfront_waf.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/dsql.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound_domain.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound_template.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/neon.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/rds.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/s3.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/sqs_alert.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/tidb.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/upstash.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/vpc.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_api_host.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_basic_auth_prelude.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_cache_control.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_deploy_hash_strip.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_host_redirect_prelude.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_spa_auth.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cf_function_spa_fallback.js +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_acm.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_keys.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/cloudfront_waf.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/container.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/vpc.yaml +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-dotenv.env +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-settings.py +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket.Dockerfile +0 -0
- {magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket_simple.toml +0 -0
|
@@ -34,11 +34,9 @@ forge.local.toml
|
|
|
34
34
|
# Activity Docs (作業ローカルの working doc。公開 repo には出さない)
|
|
35
35
|
/docs/activity/
|
|
36
36
|
|
|
37
|
-
# example deploy 生成物 (pocket が生成:
|
|
38
|
-
/example-neon/pocket.runtime.toml
|
|
37
|
+
# example deploy 生成物 (pocket が生成: collectstatic 出力 / cache)
|
|
39
38
|
/example-neon/pocket_cache/
|
|
40
39
|
/example-neon/staticfiles/
|
|
41
|
-
/example-tidb/pocket.runtime.toml
|
|
42
40
|
/example-tidb/pocket_cache/
|
|
43
41
|
/example-tidb/staticfiles/
|
|
44
42
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: magic-pocket-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.48.0
|
|
4
4
|
Summary: CLI and deploy tools for magic-pocket.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Requires-Dist: awscrt>=0.19.0
|
|
7
7
|
Requires-Dist: click>=8.1.7
|
|
8
8
|
Requires-Dist: deepdiff>=6.7.1
|
|
9
9
|
Requires-Dist: jinja2>=3.1.3
|
|
10
|
-
Requires-Dist: magic-pocket<0.
|
|
10
|
+
Requires-Dist: magic-pocket<0.49,>=0.48.0
|
|
11
11
|
Requires-Dist: pathspec>=1.0.4
|
|
12
12
|
Requires-Dist: python-on-whales>=0.68.0
|
|
13
13
|
Requires-Dist: pyyaml>=6.0.1
|
|
@@ -31,8 +31,8 @@ from pocket_cli.cli import (
|
|
|
31
31
|
neon_cli,
|
|
32
32
|
permissions_cli,
|
|
33
33
|
rds_cli,
|
|
34
|
-
runtime_config_cli,
|
|
35
34
|
s3_cli,
|
|
35
|
+
static_cli,
|
|
36
36
|
status_cli,
|
|
37
37
|
tidb_cli,
|
|
38
38
|
upstash_cli,
|
|
@@ -130,12 +130,12 @@ main.add_command(deploy_cli.promote)
|
|
|
130
130
|
main.add_command(destroy_cli.destroy)
|
|
131
131
|
main.add_command(status_cli.status)
|
|
132
132
|
main.add_command(django_cli.django if django_cli else _django_unavailable_command())
|
|
133
|
-
main.add_command(runtime_config_cli.runtime_config)
|
|
134
133
|
main.add_command(migrate_cli.migrate)
|
|
135
134
|
main.add_command(permissions_cli.permissions)
|
|
136
135
|
main.add_command(waf_cli.waf)
|
|
137
136
|
main.add_command(backup_cli.backup)
|
|
138
137
|
main.add_command(cleanup_deprecated_cli.cleanup_deprecated)
|
|
138
|
+
main.add_command(static_cli.static)
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
@main.group()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""`pocket static ...`: Rust 版 `pocket-rs static` への移行案内だけを出す stub。
|
|
2
|
+
|
|
3
|
+
静的系 (object_hash route の publish / adopt / purge / status / hash generate) は
|
|
4
|
+
Rust 版に一本化した。サブコマンド・オプションは何を渡しても同じ案内を出して
|
|
5
|
+
終了コード 2。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import shlex
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
import click
|
|
14
|
+
|
|
15
|
+
INSTALL_DOCS_URL = "https://worgue.github.io/magic-pocket/guide/cli/#pocket-rs"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@click.command(
|
|
19
|
+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
|
|
20
|
+
add_help_option=False,
|
|
21
|
+
)
|
|
22
|
+
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
|
|
23
|
+
def static(args):
|
|
24
|
+
"""(移行済み) Rust 版 `pocket-rs static` を使ってください。"""
|
|
25
|
+
replacement = shlex.join(("pocket-rs", "static", *args))
|
|
26
|
+
click.echo(
|
|
27
|
+
"`pocket static` は Rust 版 `pocket-rs static` に移りました。\n"
|
|
28
|
+
" 実行: %s\n"
|
|
29
|
+
" 導入: %s" % (replacement, INSTALL_DOCS_URL),
|
|
30
|
+
err=True,
|
|
31
|
+
)
|
|
32
|
+
sys.exit(2)
|
|
@@ -18,6 +18,7 @@ from pocket_cli.cli import interaction
|
|
|
18
18
|
from pocket_cli.cli.build_cli import build
|
|
19
19
|
from pocket_cli.cli.deploy_cli import run_deploy, run_promote
|
|
20
20
|
from pocket_cli.cli.removed_flags import removed_skip_check_existing
|
|
21
|
+
from pocket_cli.paths import project_dir, project_path
|
|
21
22
|
from pocket_cli.resources.container import Container
|
|
22
23
|
from pocket_cli.resources.s3 import S3
|
|
23
24
|
|
|
@@ -305,7 +306,7 @@ def get_deploystatic_local_storage(stage: str):
|
|
|
305
306
|
raise DeploystaticConfigError(
|
|
306
307
|
"BACKEND %s is not supported" % storage["BACKEND"]
|
|
307
308
|
)
|
|
308
|
-
local_build_static_root =
|
|
309
|
+
local_build_static_root = project_dir() / "pocket_cache" / "static_build" / stage
|
|
309
310
|
return {
|
|
310
311
|
"BACKEND": local_backend,
|
|
311
312
|
"OPTIONS": {"location": str(local_build_static_root)},
|
|
@@ -390,8 +391,9 @@ def collectstatic_locally(stage: str, *, link: bool = False):
|
|
|
390
391
|
if link:
|
|
391
392
|
args.append("--link")
|
|
392
393
|
cmd = _build_python_command(args)
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
django_dir = _get_project_dir(stage)
|
|
395
|
+
cwd = project_path(django_dir) if django_dir else project_dir()
|
|
396
|
+
run(cmd, check=True, cwd=cwd, env=_collectstatic_env(stage)) # noqa: S603 shell=False + 制御された引数
|
|
395
397
|
clear_staticfiles_override_env()
|
|
396
398
|
|
|
397
399
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""pocket.toml の相対パスの基準 (project dir)。
|
|
2
|
+
|
|
3
|
+
pocket.toml は cwd から上方向に探すので、下位ディレクトリ (例: `frontend/`) から
|
|
4
|
+
実行しても設定は読める。pocket.toml に書く相対パス (`dockerfile_path` / route の
|
|
5
|
+
`build` / `upload_dir` / `managed_assets` / django の `project_dir`) とビルド
|
|
6
|
+
コンテキストも、cwd ではなく見つけた pocket.toml のディレクトリを基準にする
|
|
7
|
+
(Rust 版 `pocket-rs static` と同じ基準)。
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from pocket.utils import get_toml_path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def project_dir() -> Path:
|
|
18
|
+
"""pocket.toml のあるディレクトリ (絶対パス)"""
|
|
19
|
+
return get_toml_path().resolve().parent
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def project_path(path: str) -> Path:
|
|
23
|
+
"""pocket.toml からの相対パスを絶対パスにする (絶対パスはそのまま)"""
|
|
24
|
+
return project_dir() / path
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/__init__.py
RENAMED
|
@@ -3,6 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import TYPE_CHECKING, Protocol
|
|
4
4
|
|
|
5
5
|
if TYPE_CHECKING:
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
6
8
|
from pocket.context import BuildContext
|
|
7
9
|
|
|
8
10
|
|
|
@@ -11,9 +13,15 @@ class Builder(Protocol):
|
|
|
11
13
|
self,
|
|
12
14
|
*,
|
|
13
15
|
target: str,
|
|
16
|
+
context_dir: Path,
|
|
14
17
|
dockerfile_path: str,
|
|
15
18
|
platform: str,
|
|
16
|
-
) -> None:
|
|
19
|
+
) -> None:
|
|
20
|
+
"""context_dir (= pocket.toml のディレクトリ) を context に build する。
|
|
21
|
+
|
|
22
|
+
dockerfile_path は context_dir からの相対パス。
|
|
23
|
+
"""
|
|
24
|
+
...
|
|
17
25
|
|
|
18
26
|
def delete(self) -> None:
|
|
19
27
|
"""ビルドバックエンドのリソースを削除(不要なら何もしない)"""
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/codebuild.py
RENAMED
|
@@ -87,10 +87,12 @@ class CodeBuildBuilder:
|
|
|
87
87
|
self,
|
|
88
88
|
*,
|
|
89
89
|
target: str,
|
|
90
|
+
context_dir: Path,
|
|
90
91
|
dockerfile_path: str,
|
|
91
92
|
platform: str,
|
|
92
93
|
) -> None:
|
|
93
94
|
print("CodeBuild でイメージをビルドします...")
|
|
95
|
+
print(" context: %s" % context_dir)
|
|
94
96
|
print(" target: %s" % target)
|
|
95
97
|
print(" dockerfile: %s" % dockerfile_path)
|
|
96
98
|
print(" platform: %s" % platform)
|
|
@@ -103,7 +105,7 @@ class CodeBuildBuilder:
|
|
|
103
105
|
# project の serviceRole を新ロールへ付け替えた後なので、旧名ロールは孤児
|
|
104
106
|
if not self.external_roles:
|
|
105
107
|
self._delete_role(self._legacy_role_name)
|
|
106
|
-
self._upload_source(
|
|
108
|
+
self._upload_source(context_dir)
|
|
107
109
|
|
|
108
110
|
build_id = self._start_build(
|
|
109
111
|
target=target,
|
|
@@ -192,11 +194,10 @@ class CodeBuildBuilder:
|
|
|
192
194
|
|
|
193
195
|
# --- ソースアップロード ---
|
|
194
196
|
|
|
195
|
-
def _upload_source(self,
|
|
197
|
+
def _upload_source(self, context_dir: Path) -> None:
|
|
196
198
|
import tempfile
|
|
197
199
|
|
|
198
200
|
print(" ソースをS3にアップロード中...")
|
|
199
|
-
context_dir = Path(".").resolve()
|
|
200
201
|
spec = load_dockerignore(context_dir)
|
|
201
202
|
|
|
202
203
|
# SpooledTemporaryFile: 50MB までメモリ、超えたらディスクへ自動退避
|
|
@@ -5,7 +5,7 @@ Lambda の実行ユーザーは非 root (sbx_user) のため、other-read の無
|
|
|
5
5
|
読めず、全 handler が INIT フェーズで失敗する (wsgi も同居するためサイトごと
|
|
6
6
|
500)。表面のエラーは Runtime.Unknown で原因に辿り着きにくいので、build 前に
|
|
7
7
|
context を走査して legible に警告する。runtime が INIT で読む
|
|
8
|
-
pocket.toml
|
|
8
|
+
pocket.toml はエラーに昇格する。
|
|
9
9
|
|
|
10
10
|
codebuild backend は source zip 作成時に mode を 0644/0755 へ正規化する
|
|
11
11
|
(_add_source_file) ため対象外。docker / depot backend は context を生の
|
|
@@ -33,9 +33,9 @@ _MAX_LISTED = 10
|
|
|
33
33
|
_warned_files: list[str] = []
|
|
34
34
|
|
|
35
35
|
# runtime が INIT フェーズで読む設定ファイル。other-read が無いまま COPY される
|
|
36
|
-
# と確実に INIT 失敗する (Rust runtime
|
|
37
|
-
#
|
|
38
|
-
_INIT_CRITICAL_NAMES = frozenset({"pocket.toml"
|
|
36
|
+
# と確実に INIT 失敗する (Python / Rust の runtime とも pocket.toml を上方探索する)
|
|
37
|
+
# ため、警告でなくエラーに昇格する。
|
|
38
|
+
_INIT_CRITICAL_NAMES = frozenset({"pocket.toml"})
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def find_files_without_world_read(context_dir: Path) -> list[str]:
|
|
@@ -56,7 +56,7 @@ def warn_files_without_world_read(context_dir: Path) -> list[str]:
|
|
|
56
56
|
|
|
57
57
|
一般ファイルを error にしないのは、Dockerfile 側で `COPY --chmod` や
|
|
58
58
|
`RUN chmod` により image 内で正規化している構成では false positive に
|
|
59
|
-
なるため。ただし runtime が INIT で読む pocket.toml
|
|
59
|
+
なるため。ただし runtime が INIT で読む pocket.toml
|
|
60
60
|
(_INIT_CRITICAL_NAMES) は該当 container が確実に INIT で死ぬうえ、非 secret
|
|
61
61
|
の設定ファイルで local を `chmod 644` して困る構成が無いため error とする。
|
|
62
62
|
"""
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/depot.py
RENAMED
|
@@ -31,6 +31,7 @@ class DepotBuilder:
|
|
|
31
31
|
self,
|
|
32
32
|
*,
|
|
33
33
|
target: str,
|
|
34
|
+
context_dir: Path,
|
|
34
35
|
dockerfile_path: str,
|
|
35
36
|
platform: str,
|
|
36
37
|
) -> None:
|
|
@@ -38,22 +39,23 @@ class DepotBuilder:
|
|
|
38
39
|
|
|
39
40
|
# context は生の permission のまま image に入るため build 前に検査する
|
|
40
41
|
# (codebuild backend は zip 時に正規化されるので不要)
|
|
41
|
-
warn_files_without_world_read(
|
|
42
|
+
warn_files_without_world_read(context_dir)
|
|
42
43
|
|
|
43
44
|
print("ECR にログインします...")
|
|
44
45
|
docker.login_ecr(region_name=self.region)
|
|
45
46
|
|
|
46
47
|
print("Depot でイメージをビルドします...")
|
|
47
48
|
print(" target: %s" % target)
|
|
49
|
+
print(" context: %s" % context_dir)
|
|
48
50
|
print(" dockerfile: %s" % dockerfile_path)
|
|
49
51
|
print(" platform: %s" % platform)
|
|
50
52
|
|
|
51
53
|
cmd = [
|
|
52
54
|
"depot",
|
|
53
55
|
"build",
|
|
54
|
-
|
|
56
|
+
str(context_dir),
|
|
55
57
|
"--file",
|
|
56
|
-
dockerfile_path,
|
|
58
|
+
str(context_dir / dockerfile_path),
|
|
57
59
|
"--tag",
|
|
58
60
|
target,
|
|
59
61
|
"--platform",
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/builders/docker.py
RENAMED
|
@@ -17,13 +17,15 @@ class DockerBuilder:
|
|
|
17
17
|
self,
|
|
18
18
|
*,
|
|
19
19
|
target: str,
|
|
20
|
+
context_dir: Path,
|
|
20
21
|
dockerfile_path: str,
|
|
21
22
|
platform: str,
|
|
22
23
|
) -> None:
|
|
23
24
|
# context は生の permission のまま image に入るため build 前に検査する
|
|
24
25
|
# (codebuild backend は zip 時に正規化されるので不要)
|
|
25
|
-
warn_files_without_world_read(
|
|
26
|
+
warn_files_without_world_read(context_dir)
|
|
26
27
|
print("Building docker image...")
|
|
28
|
+
print(" context: %s" % context_dir)
|
|
27
29
|
print(" dockerpath: %s" % dockerfile_path)
|
|
28
30
|
print(" tags: %s" % target)
|
|
29
31
|
print(" platforms: %s" % platform)
|
|
@@ -31,8 +33,8 @@ class DockerBuilder:
|
|
|
31
33
|
docker.login_ecr(region_name=self.region)
|
|
32
34
|
print("Pushing docker image...")
|
|
33
35
|
docker.build(
|
|
34
|
-
|
|
35
|
-
file=str(dockerfile_path),
|
|
36
|
+
str(context_dir),
|
|
37
|
+
file=str(context_dir / dockerfile_path),
|
|
36
38
|
tags=target,
|
|
37
39
|
platforms=[platform],
|
|
38
40
|
provenance=False,
|
|
@@ -6,6 +6,8 @@ from typing import TYPE_CHECKING
|
|
|
6
6
|
import boto3
|
|
7
7
|
from pydantic import BaseModel, Field, computed_field
|
|
8
8
|
|
|
9
|
+
from pocket_cli.paths import project_dir
|
|
10
|
+
|
|
9
11
|
if TYPE_CHECKING:
|
|
10
12
|
from pocket_cli.resources.aws.builders import Builder
|
|
11
13
|
|
|
@@ -108,6 +110,7 @@ class Ecr:
|
|
|
108
110
|
raise ValueError("builder is not configured")
|
|
109
111
|
self._builder.build_and_push(
|
|
110
112
|
target=target,
|
|
113
|
+
context_dir=project_dir(),
|
|
111
114
|
dockerfile_path=self.dockerfile_path,
|
|
112
115
|
platform=self.platform,
|
|
113
116
|
)
|
|
@@ -16,6 +16,7 @@ from pydantic import BaseModel
|
|
|
16
16
|
|
|
17
17
|
from pocket.resources.base import ResourceStatus
|
|
18
18
|
from pocket.utils import echo
|
|
19
|
+
from pocket_cli.paths import project_dir, project_path
|
|
19
20
|
from pocket_cli.resources.aws.cloudformation import CloudFrontStack
|
|
20
21
|
from pocket_cli.resources.aws.s3_utils import delete_bucket_with_contents
|
|
21
22
|
|
|
@@ -243,7 +244,7 @@ class CloudFront:
|
|
|
243
244
|
"""managed_assets のファイルを S3 に同期する (全件 upload + 不要削除)。"""
|
|
244
245
|
if not self.context.managed_assets:
|
|
245
246
|
return
|
|
246
|
-
base =
|
|
247
|
+
base = project_path(self.context.managed_assets)
|
|
247
248
|
stage_dir = base / self.context.stage
|
|
248
249
|
if stage_dir.is_dir():
|
|
249
250
|
asset_dir = stage_dir
|
|
@@ -296,7 +297,13 @@ class CloudFront:
|
|
|
296
297
|
try:
|
|
297
298
|
# route.build_cmd は pocket.toml の build.cmd (設定者 =
|
|
298
299
|
# デプロイ実行者)。意図的な shell 実行のため S602 / semgrep を抑制。
|
|
299
|
-
|
|
300
|
+
# 相対パスは pocket.toml のディレクトリ基準なので cwd もそこにする
|
|
301
|
+
subprocess.run( # noqa: S602
|
|
302
|
+
route.build_cmd,
|
|
303
|
+
shell=True, # nosemgrep
|
|
304
|
+
check=True,
|
|
305
|
+
cwd=project_dir(),
|
|
306
|
+
)
|
|
300
307
|
except subprocess.CalledProcessError as e:
|
|
301
308
|
echo.danger(
|
|
302
309
|
"build コマンドが失敗しました (exit %d): %s"
|
|
@@ -384,7 +391,7 @@ class CloudFront:
|
|
|
384
391
|
"""route の upload_dir 配下のファイルを {S3 key: ローカル path} で返す。"""
|
|
385
392
|
if not route.upload_dir:
|
|
386
393
|
raise RuntimeError("route.upload_dir is not set")
|
|
387
|
-
local_dir =
|
|
394
|
+
local_dir = project_path(route.upload_dir)
|
|
388
395
|
files: dict[str, Path] = {}
|
|
389
396
|
for file in local_dir.rglob("*"):
|
|
390
397
|
if file.is_dir():
|
|
@@ -446,6 +453,14 @@ class CloudFront:
|
|
|
446
453
|
for route in self.context.routes:
|
|
447
454
|
if route.upload_dir:
|
|
448
455
|
continue
|
|
456
|
+
if route.is_object_hash:
|
|
457
|
+
echo.info(
|
|
458
|
+
"%s は object_hash route です。"
|
|
459
|
+
"`pocket-rs static publish --stage %s` で上げてください"
|
|
460
|
+
" (deploy は触りません)"
|
|
461
|
+
% (route.path_pattern or "default", self.context.stage)
|
|
462
|
+
)
|
|
463
|
+
continue
|
|
449
464
|
origin = route.origin_path + route.path_pattern
|
|
450
465
|
echo.warning("Upload files manually to s3://%s%s" % (bucket, origin))
|
|
451
466
|
if route.is_spa:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from pathlib import Path
|
|
4
3
|
from typing import TYPE_CHECKING
|
|
5
4
|
|
|
6
5
|
import boto3
|
|
@@ -8,7 +7,6 @@ import boto3
|
|
|
8
7
|
from pocket import context
|
|
9
8
|
from pocket.resources.base import ResourceStatus
|
|
10
9
|
from pocket.utils import echo
|
|
11
|
-
from pocket_cli.cli.runtime_config_cli import generate_runtime_config
|
|
12
10
|
from pocket_cli.mediator import Mediator
|
|
13
11
|
from pocket_cli.resources.aws.builders import Builder, create_builder
|
|
14
12
|
from pocket_cli.resources.aws.cloudformation import ContainerStack
|
|
@@ -88,10 +86,7 @@ class Container:
|
|
|
88
86
|
"""指定 tag (commit hash 等) で image を build & push する (deploy はしない)。
|
|
89
87
|
|
|
90
88
|
build once 用。`:stage` タグは付けない。昇格は deploy 側で行う。
|
|
91
|
-
pocket.runtime.toml は Dockerfile の COPY で image に焼き込まれるため、
|
|
92
|
-
deploy_init と同様に build 前へ生成する。
|
|
93
89
|
"""
|
|
94
|
-
generate_runtime_config(self._runtime_toml_path())
|
|
95
90
|
ecr = self.ecr
|
|
96
91
|
ecr.ensure_exists()
|
|
97
92
|
ecr.build_and_push(tag=tag)
|
|
@@ -178,23 +173,11 @@ class Container:
|
|
|
178
173
|
# 複数 container が deep merge で共存できるよう container 名で nest する
|
|
179
174
|
return {"ecr": {self.context.name: {"repository_name": self.context.ecr_name}}}
|
|
180
175
|
|
|
181
|
-
def _runtime_toml_path(self) -> Path:
|
|
182
|
-
"""pocket.runtime.toml の出力先を返す。
|
|
183
|
-
|
|
184
|
-
django.project_dir が設定されていればその中に、
|
|
185
|
-
なければ CWD に配置する。
|
|
186
|
-
"""
|
|
187
|
-
if self.context.django and self.context.django.project_dir:
|
|
188
|
-
return Path(self.context.django.project_dir) / "pocket.runtime.toml"
|
|
189
|
-
return Path("pocket.runtime.toml")
|
|
190
|
-
|
|
191
176
|
def deploy_init(self):
|
|
192
177
|
if self.context.promote_commit_hash:
|
|
193
178
|
# 昇格 (promote): 既存 :<hash> image へ :<stage> タグを移す。build しない。
|
|
194
|
-
# runtime config は build 時に image へ焼き込み済みのため生成もしない。
|
|
195
179
|
self.ecr.retag(self.context.promote_commit_hash, self.context.stage)
|
|
196
180
|
else:
|
|
197
|
-
generate_runtime_config(self._runtime_toml_path())
|
|
198
181
|
self.ecr.sync()
|
|
199
182
|
if self.context.vpc and not self.context.vpc.manage:
|
|
200
183
|
vpc_stack = Vpc(self.context.vpc).stack
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "magic-pocket-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.48.0"
|
|
4
4
|
description = "CLI and deploy tools for magic-pocket."
|
|
5
5
|
requires-python = ">=3.10"
|
|
6
6
|
dependencies = [
|
|
7
7
|
# lib は同 minor に束縛する。0.x では minor が breaking の単位のため、
|
|
8
8
|
# 上限なしだと cli を pin した消費者にも lib の破壊的変更が届いてしまう
|
|
9
|
-
"magic-pocket>=0.
|
|
9
|
+
"magic-pocket>=0.48.0,<0.49",
|
|
10
10
|
"click>=8.1.7",
|
|
11
11
|
"jinja2>=3.1.3",
|
|
12
12
|
"python-on-whales>=0.68.0",
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import copy
|
|
4
|
-
import json
|
|
5
|
-
import re
|
|
6
|
-
import sys
|
|
7
|
-
from importlib.metadata import PackageNotFoundError, version
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
import click
|
|
11
|
-
|
|
12
|
-
from pocket.utils import GENERATOR_VERSION_MARKER, get_toml_path
|
|
13
|
-
|
|
14
|
-
if sys.version_info >= (3, 11):
|
|
15
|
-
import tomllib
|
|
16
|
-
else:
|
|
17
|
-
import tomli as tomllib
|
|
18
|
-
|
|
19
|
-
# container.<name> から除外するキー(ビルド時のみ必要)
|
|
20
|
-
# iam (managed_policy_arns / inline_policies) は Lambda execution role を組む
|
|
21
|
-
# provision 専用で runtime は参照しない。IAM Condition のようにキーへ ":" を含む
|
|
22
|
-
# 任意の dict を抱えるため、runtime toml の表面積から外しておく。
|
|
23
|
-
_CONTAINER_REMOVE_KEYS = {
|
|
24
|
-
"platform",
|
|
25
|
-
"build",
|
|
26
|
-
"permissions_boundary",
|
|
27
|
-
"use_vpc",
|
|
28
|
-
"iam",
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# container.<name> でダミー値に置き換えるキー(必須フィールドだが runtime では不要)
|
|
32
|
-
_CONTAINER_DUMMY_VALUES = {
|
|
33
|
-
"dockerfile_path": "__runtime__",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
# cloudfront の各エントリから除外するキー
|
|
37
|
-
_CLOUDFRONT_REMOVE_KEYS = {
|
|
38
|
-
"managed_assets",
|
|
39
|
-
"hosted_zone_id_override",
|
|
40
|
-
"redirect_from",
|
|
41
|
-
"signing_key",
|
|
42
|
-
"token_secret",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# route から除外するキー
|
|
46
|
-
_ROUTE_REMOVE_KEYS = {
|
|
47
|
-
"build",
|
|
48
|
-
"upload_dir",
|
|
49
|
-
"require_token",
|
|
50
|
-
"login_path",
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
# container.<name>.django から除外するキー
|
|
54
|
-
_DJANGO_REMOVE_KEYS = {
|
|
55
|
-
"project_dir",
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# トップレベルから除外するセクション
|
|
59
|
-
_TOPLEVEL_REMOVE_KEYS = {
|
|
60
|
-
"vpc",
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def _remove_keys(d: dict, keys: set[str]) -> None:
|
|
65
|
-
for key in keys:
|
|
66
|
-
d.pop(key, None)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def _clean_cloudfront(cf: dict) -> None:
|
|
70
|
-
_remove_keys(cf, _CLOUDFRONT_REMOVE_KEYS)
|
|
71
|
-
for route in cf.get("routes", []):
|
|
72
|
-
_remove_keys(route, _ROUTE_REMOVE_KEYS)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _clean_section(section: dict) -> None:
|
|
76
|
-
"""container / cloudfront セクションをクリーンアップする"""
|
|
77
|
-
containers = section.get("container")
|
|
78
|
-
if isinstance(containers, dict):
|
|
79
|
-
for c in containers.values():
|
|
80
|
-
if not isinstance(c, dict):
|
|
81
|
-
continue
|
|
82
|
-
_remove_keys(c, _CONTAINER_REMOVE_KEYS)
|
|
83
|
-
for key, value in _CONTAINER_DUMMY_VALUES.items():
|
|
84
|
-
if key in c:
|
|
85
|
-
c[key] = value
|
|
86
|
-
if "django" in c:
|
|
87
|
-
_remove_keys(c["django"], _DJANGO_REMOVE_KEYS)
|
|
88
|
-
if "cloudfront" in section:
|
|
89
|
-
for cf in section["cloudfront"].values():
|
|
90
|
-
_clean_cloudfront(cf)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def _clean_data(data: dict) -> dict:
|
|
94
|
-
"""pocket.toml のデータからランタイムに不要な設定を除外する"""
|
|
95
|
-
result = copy.deepcopy(data)
|
|
96
|
-
_remove_keys(result, _TOPLEVEL_REMOVE_KEYS)
|
|
97
|
-
_clean_section(result)
|
|
98
|
-
for stage in result.get("general", {}).get("stages", []):
|
|
99
|
-
if stage in result:
|
|
100
|
-
_clean_section(result[stage])
|
|
101
|
-
return result
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def _to_toml(data: dict, prefix: str = "") -> str:
|
|
105
|
-
"""dict を TOML 文字列に変換する(簡易実装)"""
|
|
106
|
-
lines: list[str] = []
|
|
107
|
-
# まずスカラー値とリストを出力
|
|
108
|
-
for key, value in data.items():
|
|
109
|
-
if isinstance(value, dict):
|
|
110
|
-
continue
|
|
111
|
-
lines.append(_format_value(key, value))
|
|
112
|
-
|
|
113
|
-
# dict 値をセクションとして出力
|
|
114
|
-
for key, value in data.items():
|
|
115
|
-
if not isinstance(value, dict):
|
|
116
|
-
continue
|
|
117
|
-
section = f"{prefix}{_toml_key(key)}" if prefix else _toml_key(key)
|
|
118
|
-
# dict の中身が全て dict なら、各サブキーをサブセクションに
|
|
119
|
-
if all(isinstance(v, dict) for v in value.values()) and value:
|
|
120
|
-
for sub_key, sub_value in value.items():
|
|
121
|
-
sub_section = f"{section}.{_toml_key(sub_key)}"
|
|
122
|
-
lines.append("")
|
|
123
|
-
lines.append(f"[{sub_section}]")
|
|
124
|
-
lines.append(_to_toml(sub_value, prefix=f"{sub_section}."))
|
|
125
|
-
continue
|
|
126
|
-
lines.append("")
|
|
127
|
-
lines.append(f"[{section}]")
|
|
128
|
-
lines.append(_to_toml(value, prefix=f"{section}."))
|
|
129
|
-
|
|
130
|
-
return "\n".join(lines)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def _toml_string(value: str) -> str:
|
|
134
|
-
"""TOML basic string として安全な表現を返す。
|
|
135
|
-
|
|
136
|
-
エスケープ規則 (\" / \\\\ / 制御文字) は JSON と互換。単純連結だと
|
|
137
|
-
引用符やバックスラッシュを含む値で不正 TOML になり、image に焼き込まれて
|
|
138
|
-
Lambda INIT で初めて落ちる。
|
|
139
|
-
"""
|
|
140
|
-
return json.dumps(value, ensure_ascii=False)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
_BARE_KEY_RE = re.compile(r"\A[A-Za-z0-9_-]+\Z")
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def _toml_key(key: str) -> str:
|
|
147
|
-
"""TOML のキーとして安全な表現を返す。
|
|
148
|
-
|
|
149
|
-
bare key に使える文字は `[A-Za-z0-9_-]` だけ。IAM Condition の
|
|
150
|
-
`"kms:ViaService"` のように ":" や "." を含むキーをそのまま書くと不正 TOML に
|
|
151
|
-
なり、image に焼き込まれて Lambda INIT で初めて落ちる (値側の _toml_string と
|
|
152
|
-
同じ事故がキー側で起きる)。dotted なセクション名は各パートを個別に通すこと。
|
|
153
|
-
"""
|
|
154
|
-
if _BARE_KEY_RE.match(key):
|
|
155
|
-
return key
|
|
156
|
-
return _toml_string(key)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
def _format_value(key: str, value) -> str:
|
|
160
|
-
if isinstance(value, list):
|
|
161
|
-
return f"{_toml_key(key)} = {_format_list(value)}"
|
|
162
|
-
return f"{_toml_key(key)} = {_format_inline_value(value)}"
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
def _format_list(items: list) -> str:
|
|
166
|
-
if not items:
|
|
167
|
-
return "[]"
|
|
168
|
-
if all(isinstance(i, dict) for i in items):
|
|
169
|
-
parts = [_format_inline_table(item) for item in items]
|
|
170
|
-
return "[\n %s,\n]" % ",\n ".join(parts)
|
|
171
|
-
return "[%s]" % ", ".join(_format_inline_value(i) for i in items)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def _format_inline_table(table: dict) -> str:
|
|
175
|
-
if not table:
|
|
176
|
-
return "{}"
|
|
177
|
-
kvs = ", ".join(
|
|
178
|
-
f"{_toml_key(k)} = {_format_inline_value(v)}" for k, v in table.items()
|
|
179
|
-
)
|
|
180
|
-
return "{ %s }" % kvs
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
def _format_inline_value(value) -> str:
|
|
184
|
-
if isinstance(value, bool):
|
|
185
|
-
return "true" if value else "false"
|
|
186
|
-
if isinstance(value, int):
|
|
187
|
-
return str(value)
|
|
188
|
-
if isinstance(value, str):
|
|
189
|
-
return _toml_string(value)
|
|
190
|
-
# inline table / 配列は再帰。IAM の Condition のようにネストした dict を
|
|
191
|
-
# repr() で吐くと Python 表記 ({'k': 'v'}) になり不正 TOML になる。
|
|
192
|
-
if isinstance(value, dict):
|
|
193
|
-
return _format_inline_table(value)
|
|
194
|
-
if isinstance(value, list):
|
|
195
|
-
return _format_list(value)
|
|
196
|
-
return repr(value)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
def _generator_version() -> str | None:
|
|
200
|
-
"""生成元 (magic-pocket-cli) のバージョン。取得できなければ None (刻印しない)。"""
|
|
201
|
-
try:
|
|
202
|
-
return version("magic-pocket-cli")
|
|
203
|
-
except PackageNotFoundError:
|
|
204
|
-
return None
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
class RuntimeConfigGenerationError(Exception):
|
|
208
|
-
"""生成した pocket.runtime.toml が不正な TOML だった。"""
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def _check_valid_toml(toml_str: str) -> None:
|
|
212
|
-
"""生成物を自己検証する (fail-loud)。
|
|
213
|
-
|
|
214
|
-
自前 dumper が取りこぼした値/キーがあっても、ここで落ちれば build/deploy 時に
|
|
215
|
-
分かる。素通しすると不正な toml が image に焼かれ、Lambda INIT の
|
|
216
|
-
TOMLDecodeError として全 handler が死ぬまで気づけない。
|
|
217
|
-
"""
|
|
218
|
-
try:
|
|
219
|
-
tomllib.loads(toml_str)
|
|
220
|
-
except tomllib.TOMLDecodeError as e:
|
|
221
|
-
raise RuntimeConfigGenerationError(
|
|
222
|
-
"生成した pocket.runtime.toml が不正な TOML です: %s\n"
|
|
223
|
-
"pocket.toml の値/キーが自前 dumper の想定外の可能性があります。\n"
|
|
224
|
-
"--- 生成結果 ---\n%s" % (e, toml_str)
|
|
225
|
-
) from e
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
def _runtime_config_str() -> str:
|
|
229
|
-
"""pocket.runtime.toml の内容を生成する (stdout / ファイル出力の共通実装)。
|
|
230
|
-
|
|
231
|
-
生成元 (CLI) バージョンを先頭コメントに刻む。旧 runtime (tomllib) は無視するので
|
|
232
|
-
後方互換を壊さず、新 runtime だけが読んで版突合 (Settings.check_generator_version)
|
|
233
|
-
に使う。CLI 版 > runtime 版のとき legible error にリフレーミングされる (層2)。
|
|
234
|
-
stdout 経由 (`pocket runtime-config > pocket.runtime.toml`) でもマーカーが
|
|
235
|
-
欠けないよう、生成は本関数に一本化する。
|
|
236
|
-
"""
|
|
237
|
-
toml_path = get_toml_path()
|
|
238
|
-
data = tomllib.loads(toml_path.read_text())
|
|
239
|
-
cleaned = _clean_data(data)
|
|
240
|
-
toml_str = _to_toml(cleaned).strip() + "\n"
|
|
241
|
-
generator_version = _generator_version()
|
|
242
|
-
if generator_version:
|
|
243
|
-
toml_str = "%s %s\n%s" % (GENERATOR_VERSION_MARKER, generator_version, toml_str)
|
|
244
|
-
_check_valid_toml(toml_str)
|
|
245
|
-
return toml_str
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def generate_runtime_config(output_path: Path) -> None:
|
|
249
|
-
"""pocket.runtime.toml を生成する(プログラムから呼び出し用)
|
|
250
|
-
|
|
251
|
-
runtime が INIT で読むファイルのため、strict な umask 環境でも
|
|
252
|
-
other-read を保証する (context_check がエラーにする条件を自ら作らない)。
|
|
253
|
-
"""
|
|
254
|
-
output_path.write_text(_runtime_config_str())
|
|
255
|
-
output_path.chmod(0o644)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
@click.command("runtime-config")
|
|
259
|
-
@click.argument("output", default="-")
|
|
260
|
-
def runtime_config(output: str):
|
|
261
|
-
"""Lambda ランタイム用の pocket.toml を生成する
|
|
262
|
-
|
|
263
|
-
ビルド時のみ必要な設定(dockerfile_path, managed_assets 等)を
|
|
264
|
-
除外した pocket.toml を出力する。Dockerfile 内で使用する。
|
|
265
|
-
|
|
266
|
-
OUTPUT: 出力先ファイルパス(省略時は標準出力)
|
|
267
|
-
"""
|
|
268
|
-
if output == "-":
|
|
269
|
-
click.echo(_runtime_config_str(), nl=False)
|
|
270
|
-
else:
|
|
271
|
-
generate_runtime_config(Path(output))
|
|
272
|
-
click.echo("runtime-config を出力しました: %s" % output)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/cli/cleanup_deprecated_cli.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_common.py
RENAMED
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/backup_legacy.py
RENAMED
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/cloudformation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/lambdahandler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/aws/stack_backed.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/resources/inbound_template.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/cloudformation/vpc.yaml
RENAMED
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-dotenv.env
RENAMED
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/django-settings.py
RENAMED
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket.Dockerfile
RENAMED
|
File without changes
|
{magic_pocket_cli-0.46.2 → magic_pocket_cli-0.48.0}/pocket_cli/templates/init/pocket_simple.toml
RENAMED
|
File without changes
|