Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyasdf committed Jul 24, 2023
1 parent c53ee06 commit 976f52a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ quay.io/coreos:
2. 源镜像 url 不包含 tag 和 digest 时,代表同步源镜像 repository 中的所有镜像 tag
3. 源镜像 url 可以包含一个或多个 tag,多个 tag 之间用英文逗号分隔,代表同步源镜像 repository 中的多个指定镜像 tag
4. 源镜像 url 可以但最多只能包含一个 digest,此时如果目标镜像 url 包含 digest,digest 必须一致
5. 目标镜像 url 可以不包含 tag 和 digest,表示所有需同步的镜像保持其镜像 tag 或者 digest 不变
6. 目标镜像 url 可以包含多个 tag 或者 digest,数量必须与源镜像 url 中的 tag 数量相同,此时,同步后的镜像 tag 会被修改成目标镜像 url 中指定的镜像 tag(按照从左到右顺序对应)
5. 源镜像 url 的 "tag" 可以是一个正则表达式,需要额外在首尾加上 `/` 字符作为标识,源镜像 repository 中所有匹配正则表达式的镜像 tag 会被同步,不支持多个正则表达式
6. 目标镜像 url 可以不包含 tag 和 digest,表示所有需同步的镜像保持其镜像 tag 或者 digest 不变
7. 目标镜像 url 可以包含多个 tag 或者 digest,数量必须与源镜像 url 中的 tag 数量相同,此时,同步后的镜像 tag 会被修改成目标镜像 url 中指定的镜像 tag(按照从左到右顺序对应)
8. 支持同时指定多个目标镜像 url,此时 "目标镜像 url" 为数组的形式,数组的每个元素(字符串)都需要满足前面的规则

镜像同步规则文件通过 `--images` 参数传入,具体文件样例可以参考 [images.yaml](examples/images.yaml) 和 [images.json](examples/images.json),这里以 [images.yaml](examples/images.yaml) 为例。 示例如下:
Expand All @@ -104,6 +105,7 @@ quay.io/coreos/kube-rbac-proxy@sha256:14b267eb38aa85fd12d0e168fffa2d8a6187ac53a1
quay.io/coreos/kube-rbac-proxy:v1.1:
- quay.io/ruohe/kube-rbac-proxy1
- quay.io/ruohe/kube-rbac-proxy2
quay.io/coreos/kube-rbac-proxy:/a+/: quay.io/ruohe/kube-rbac-proxy
```

### 更多参数
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ in `docker pull/push` commands, but still something different in the "tags and d
1. Neither of the source images url and the destination images url should be empty.
2. If the source images url contains no tags or digest, all the tags of source repository will be synced.
3. The source images url can have more than one tags, which should be seperated by comma, only the specified tags will be synced.
4. The source images url can at most one digest, and the destination images url should only have no digest or the same digest at the same time.
5. If the destination images url has no digest or tags, it means the source images will keep the same tags or digest after being synced.
6. The destination images url can have more than one tags, the number of which must be the same with the tags in the source images url, then all the source images' tags will be changed to a new one (correspond from left to right).
7. The "destination images url" can also be an array, each of which follows the rules above.
4. The source images url can have at most one digest, and the destination images url should only have no digest or the same digest at the same time.
5. The "tags" part of source images url can be a regular expression which needs to have an additional prefix and suffix string `/`. All the tags of source repository that matches the regular expression will be synced. Multiple regular expressions is not supported.
6. If the destination images url has no digest or tags, it means the source images will keep the same tags or digest after being synced.
7. The destination images url can have more than one tags, the number of which must be the same with the tags in the source images url, then all the source images' tags will be changed to a new one (correspond from left to right).
8. The "destination images url" can also be an array, each of which follows the rules above.

You can find the example in [images.yaml](examples/images.yaml) and [images.json](examples/images.json), here we use [images.yaml](examples/images.yaml) for explaination:

Expand All @@ -103,6 +104,7 @@ quay.io/coreos/kube-rbac-proxy@sha256:14b267eb38aa85fd12d0e168fffa2d8a6187ac53a1
quay.io/coreos/kube-rbac-proxy:v1.1:
- quay.io/ruohe/kube-rbac-proxy1
- quay.io/ruohe/kube-rbac-proxy2
quay.io/coreos/kube-rbac-proxy:/a+/: quay.io/ruohe/kube-rbac-proxy
```

### Parameters
Expand Down
3 changes: 2 additions & 1 deletion examples/images.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"quay.io/coreos/kube-rbac-proxy": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.0": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.0,v2.0": "quay.io/ruohe/kube-rbac-proxy",
"quay.io/coreos/kube-rbac-proxy:v1.1": ["quay.io/ruohe/kube-rbac-proxy1", "quay.io/ruohe/kube-rbac-proxy2"]
"quay.io/coreos/kube-rbac-proxy:v1.1": ["quay.io/ruohe/kube-rbac-proxy1", "quay.io/ruohe/kube-rbac-proxy2"],
"quay.io/coreos/kube-rbac-proxy:/a+/": "quay.io/ruohe/kube-rbac-proxy"
}
3 changes: 2 additions & 1 deletion examples/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ quay.io/coreos/kube-rbac-proxy:v1.0,v2.0: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy@sha256:14b267eb38aa85fd12d0e168fffa2d8a6187ac53a14a0212b0d4fce8d729598c: quay.io/ruohe/kube-rbac-proxy
quay.io/coreos/kube-rbac-proxy:v1.1:
- quay.io/ruohe/kube-rbac-proxy1
- quay.io/ruohe/kube-rbac-proxy2
- quay.io/ruohe/kube-rbac-proxy2
quay.io/coreos/kube-rbac-proxy:/a+/: quay.io/ruohe/kube-rbac-proxy
1 change: 1 addition & 0 deletions pkg/task/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (r *RuleTask) Run() ([]Task, string, error) {
return nil, "", fmt.Errorf("source url %s format error: %v", r.source, err)
}

// TODO: remove duplicated sourceURL and destinationURL pair?
if err = checkSourceAndDestinationURLs(sourceURLs, destinationURLs); err != nil {
return nil, "", fmt.Errorf("failed to check source and destination urls for %s:%s: %v",
r.source, r.destination, err)
Expand Down

0 comments on commit 976f52a

Please sign in to comment.