`COPY`/`ADD` JSON form is rewritten to shell form even when paths contain spaces

オープン 初心者向け
#71 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, go
領域
devtools

調査の方向性

まず、JSON形式のCOPYおよびADD命令を書き換えるコードを見つけ、空白を含む引数をどのように処理するか確認してください。issueにある再現用Dockerfileを使い、パスにスペースが含まれる場合もフォーマッターがJSON形式を維持することを検証してください。フォーマット後も命令が指定するソースファイルや宛先が変わらなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

COPY and ADD in JSON (exec) form get rewritten to the space-separated form even when a path contains spaces. The JSON form exists for exactly that case, so the rewrite changes which files are copied and where.

Reproduce
FROM alpine
COPY ["my file.txt", "/app dir/"]
ADD ["src dir", "/opt/x y/"]
dockerfmt Dockerfile
Actual
FROM alpine
COPY my file.txt /app dir/
ADD src dir /opt/x y/

COPY my file.txt /app dir/ now names the sources my, file.txt and /app and the destination dir/. With a file called my file.txt in the context, the original builds and the output fails:

failed to compute cache key: failed to calculate checksum of ref ...: "/my": not found
Expected

Keep the JSON form when any argument contains whitespace, or don't convert COPY/ADD at all:

COPY ["my file.txt", "/app dir/"]
ADD ["src dir", "/opt/x y/"]

Reproduced with v0.5.4 and with main at a5868c2.

主要言語
Go
スター
626
フォーク
23
平均マージ
6日 23時間
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

reteps/dockerfmt のほかの issue

reteps/dockerfmt の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。