Skip to content

Commit 6bee3ef

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feature/add-init-to-service
* upstream/master: chore: Replace git-chglog with git-cliff (kreuzwerker#904) feat: Implement docker registry image tags data source (kreuzwerker#903) Fix flaky `docker_container` destroy by disabling link removal during delete (kreuzwerker#902) Normalize `docker_service` `max_failure_ratio` diffs to prevent `0` vs `0.0` drift (kreuzwerker#901) Fix `docker_container.container_logs` to return demultiplexed log content (kreuzwerker#899) feat: Add docker import action (kreuzwerker#900) docs: add missing docker_exec/buildx examples and align action name to docker_exec (kreuzwerker#898) feat: Expose attached container network addresses in `docker_network` data source (kreuzwerker#897) chore: Prepare release 4.1.0 (kreuzwerker#896) Prevent `docker_container` read panic with CDI `device_requests` by hardening device flattening (kreuzwerker#895) Add Plugin Framework `docker_containers` data source for Docker container enumeration (kreuzwerker#893) Fix `docker_service` platform flattening hash to prevent platform list drift on updates (kreuzwerker#892) fix: Make container deletion idempotent for missing containers (kreuzwerker#891) fix(deps): update module github.com/containerd/platforms to v1.0.0-rc.4 (kreuzwerker#889) Avoid `docker_container` replacement when only daemon default `log_opts` are present (kreuzwerker#888) Add `platform` support to `docker_container` for cross-architecture emulation (kreuzwerker#886) Allow `docker_registry_image.auth_config` to mirror provider `registry_auth` optional credentials (kreuzwerker#887) feat: Implement docker_exec action (kreuzwerker#885) chore: Prepare 4.0.0 release (kreuzwerker#884) feat: add selinux_relabel attribute to docker_container volumes (kreuzwerker#883)
2 parents f67f445 + fee32c9 commit 6bee3ef

61 files changed

Lines changed: 4849 additions & 591 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copilot Instructions
2+
3+
When Go code is touched, run:
4+
5+
```bash
6+
make fmt
7+
```
8+
9+
before finalizing changes.
10+
11+
When documentation-related schemas or generated provider/resource/data-source docs are impacted, run:
12+
13+
```bash
14+
make website-generation
15+
```
16+
17+
before finalizing changes, and include the generated documentation updates in the same PR.
18+
19+
Further instructions:
20+
* commit messages should be in the format of `<type>(<scope>): <subject>`, where:
21+
* `<type>` is one of `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`
22+
* `<scope>` is optional and can be the name of the package or module being changed
23+
* `<subject>` is a brief description of the change, ideally less than 50 characters

.github/workflows/acc-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ jobs:
229229
env:
230230
TF_LOG: INFO
231231
TF_ACC: 1
232-
run: DOCKER_HOST=${{ steps.setup-docker.outputs.sock}} go test -v ./internal/provider -timeout ${{ env.TESTSUITE_TIMEOUT }} -run ${{ matrix.resource_type }}
232+
run: DOCKER_HOST=${{ steps.setup-docker.outputs.sock}} go test -v ./internal/... -timeout ${{ env.TESTSUITE_TIMEOUT }} -run ${{ matrix.resource_type }}
233233
- name: Cleanup acceptance tests
234234
run: make testacc_cleanup
235235
if: ${{ matrix.registry }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Semantic PR Title
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- reopened
9+
- synchronize
10+
- ready_for_review
11+
12+
jobs:
13+
validate-title:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate PR title
17+
env:
18+
TITLE: ${{ github.event.pull_request.title }}
19+
run: |
20+
if ! printf '%s\n' "$TITLE" | grep -Eq '^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\([^)]+\))?(!)?:[[:space:]].+'; then
21+
cat <<'EOF'
22+
PR title must follow Conventional Commits, for example:
23+
feat: add registry image tags data source
24+
fix(provider): handle missing auth config
25+
EOF
26+
exit 1
27+
fi

CHANGELOG.md

Lines changed: 2024 additions & 488 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ Please use issue templates as much as possible.
2424

2525
Prerequisites:
2626

27-
- `make`, `git`, `bash`
27+
- `make`, `git`, `bash`, `brew`
2828
- [Go 1.22+](https://golang.org/doc/install)
2929
- [Docker](https://www.docker.com/)
3030
- [Terraform 0.12+](https://terraform.io/)
31-
- [git-chglog](https://github.com/git-chglog/git-chglog)
3231
- [svu](https://github.com/caarlos0/svu)
3332

3433
Clone `terraform-provider-docker` anywhere:
@@ -196,5 +195,5 @@ make major
196195

197196
Those commands will automatically:
198197
- Replace all occurrences of the latest release, e.g. `2.11.0` with the new one, e.g. `2.12.0`: ``
199-
- Generate the `CHANGELOG.md`
198+
- Generate the `CHANGELOG.md` with `git cliff`
200199
- Regenerate the website (`make website-generation`)

GNUmakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ setup:
3030
go install github.com/katbyte/terrafmt
3131
go install github.com/client9/misspell/cmd/misspell
3232
go install github.com/golangci/golangci-lint/cmd/golangci-lint
33+
brew install git-cliff
3334
rm -f .git/hooks/commit-msg \
3435
&& curl --fail -o .git/hooks/commit-msg https://raw.githubusercontent.com/hazcod/semantic-commit-hook/master/commit-msg \
3536
&& chmod 500 .git/hooks/commit-msg
@@ -107,7 +108,7 @@ website-lint-fix:
107108

108109
chlog-%:
109110
@echo "Generating CHANGELOG.md"
110-
git-chglog --next-tag $* -o CHANGELOG.md
111+
git cliff --config cliff.toml --tag $* --output CHANGELOG.md
111112
@echo "Version updated to $*!"
112113
@echo
113114
@echo "Review the changes made by this script then execute the following:"

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kreuzwerker/terraform-provider-docker/blob/main/LICENSE)
1414
[![Go Status](https://github.com/kreuzwerker/terraform-provider-docker/workflows/Acc%20Tests/badge.svg)](https://github.com/kreuzwerker/terraform-provider-docker/actions)
1515
[![Lint Status](https://github.com/kreuzwerker/terraform-provider-docker/workflows/golangci-lint/badge.svg)](https://github.com/kreuzwerker/terraform-provider-docker/actions)
16-
[![Go Report Card](https://goreportcard.com/badge/github.com/kreuzwerker/terraform-provider-docker)](https://goreportcard.com/report/github.com/kreuzwerker/terraform-provider-docker)
16+
[![Go Report Card](https://goreportcard.com/badge/github.com/kreuzwerker/terraform-provider-docker)](https://goreportcard.com/report/github.com/kreuzwerker/terraform-provider-docker)
17+
18+
Sponsored by [Coder](https://coder.com/)
1719

1820
## Documentation
1921

@@ -26,7 +28,7 @@ Migration guides:
2628

2729
## Example usage
2830

29-
Take a look at the examples in the [documentation](https://registry.terraform.io/providers/kreuzwerker/docker/3.9.0/docs) of the registry
31+
Take a look at the examples in the [documentation](https://registry.terraform.io/providers/kreuzwerker/docker/4.1.0/docs) of the registry
3032
or use the following example:
3133

3234

@@ -38,7 +40,9 @@ terraform {
3840
# since new versions are released frequently
3941
docker = {
4042
source = "kreuzwerker/docker"
41-
version = "3.9.0"
43+
# or if you want to pull from opentfu
44+
source = "registry.opentofu.org/kreuzwerker/docker"
45+
version = "4.1.0"
4246
}
4347
}
4448
}
@@ -115,3 +119,7 @@ The Terraform Provider Docker is available to everyone under the terms of the Mo
115119
## Stargazers over time
116120

117121
[![Stargazers over time](https://starchart.cc/kreuzwerker/terraform-provider-docker.svg)](https://starchart.cc/kreuzwerker/terraform-provider-docker)
122+
123+
## Sponsors
124+
125+
[![Coder](https://avatars.githubusercontent.com/u/95932066?s=100&v=2)](https://coder.com/)

cliff.toml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[changelog]
2+
header = "Changelog"
3+
body = """
4+
{% if version %}
5+
<a name="{{ version }}"></a>
6+
## {% if previous %}[{{ version }}](https://github.com/kreuzwerker/terraform-provider-docker/compare/{{ previous.version }}...{{ version }}){% else %}{{ version }}{% endif %} ({{ timestamp | date(format="%Y-%m-%d") }})
7+
8+
{% endif %}
9+
{% for group, commits in commits | group_by(attribute="group") %}
10+
### {{ group }}
11+
{% for commit in commits %}
12+
* {{ commit.message
13+
| split(pat="\n")
14+
| first }}{% if commit.links %} ({% for link in commit.links %}[{{ link.text }}]({{ link.href }}){% if not loop.last %} {% endif %}{% endfor %}){% endif %}
15+
{% endfor %}
16+
{% endfor %}
17+
"""
18+
footer = ""
19+
trim = true
20+
render_always = false
21+
output = "CHANGELOG.md"
22+
23+
[git]
24+
conventional_commits = true
25+
filter_unconventional = false
26+
tag_pattern = "^v?\\d+\\.\\d+\\.\\d+(-rc\\.\\d+)?$"
27+
link_parsers = [
28+
{ pattern = "#(\\d+)", href = "https://github.com/kreuzwerker/terraform-provider-docker/issues/$1" },
29+
]
30+
commit_parsers = [
31+
{ message = "^feat", group = "Feat" },
32+
{ message = "^Feat", group = "Feat" },
33+
{ message = "^Add", group = "Feat" },
34+
{ message = "^Allow", group = "Feat" },
35+
{ message = "^fix", group = "Fix" },
36+
{ message = "^Fix", group = "Fix" },
37+
{ message = "^Normalize", group = "Fix" },
38+
{ message = "^docs?", group = "Docs" },
39+
{ message = "^refactor", group = "Refactor" },
40+
{ message = "^perf", group = "Perf" },
41+
{ message = "^test", group = "Test" },
42+
{ message = "^chore", group = "Chore" },
43+
{ message = "^build", group = "Build" },
44+
{ message = "^ci", group = "Ci" },
45+
{ message = "^revert", skip = true },
46+
{ message = ".*", group = "Other", default_scope = "other" },
47+
]

docs/actions/exec.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "docker_exec Action - terraform-provider-docker"
4+
subcategory: ""
5+
description: |-
6+
Run a command in an existing container, similar to docker container exec. Please note that due to the nature of actions, we cannot have an computed output attribute that contains the command output.
7+
---
8+
9+
# docker_exec (Action)
10+
11+
Run a command in an existing container, similar to `docker container exec`. Please note that due to the nature of actions, we cannot have an computed `output` attribute that contains the command output.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "docker_image" "busybox" {
17+
name = "busybox:1.35.0"
18+
}
19+
20+
resource "docker_container" "target" {
21+
name = "docker-exec-example"
22+
image = docker_image.busybox.image_id
23+
must_run = true
24+
command = ["sh", "-c", "sleep 300"]
25+
26+
lifecycle {
27+
action_trigger {
28+
events = [after_create]
29+
actions = [action.docker_exec.create_file]
30+
}
31+
}
32+
}
33+
34+
action "docker_exec" "create_file" {
35+
config {
36+
container = docker_container.target.name
37+
command = ["sh", "-c", "touch /tmp/created-by-action"]
38+
}
39+
}
40+
```
41+
42+
<!-- action schema generated by tfplugindocs -->
43+
## Schema
44+
45+
### Required
46+
47+
- `command` (List of String) Command and arguments to execute inside the container.
48+
- `container` (String) Container name or ID where the command is executed.
49+
50+
### Optional
51+
52+
- `detach` (Boolean) Run command in the background.
53+
- `env` (List of String) Set environment variables for the command (`KEY=value` or `KEY`).
54+
- `env_file` (List of String) Read in environment variables from files.
55+
- `privileged` (Boolean) Give extended privileges to the command.
56+
- `tty` (Boolean) Allocate a pseudo-TTY.
57+
- `user` (String) Username or UID (format: `<name|uid>[:<group|gid>]`).
58+
- `workdir` (String) Working directory inside the container.

docs/actions/image_import.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "docker_image_import Action - terraform-provider-docker"
4+
subcategory: ""
5+
description: |-
6+
Import a tar archive or URL as a Docker image, similar to docker image import.
7+
---
8+
9+
# docker_image_import (Action)
10+
11+
Import a tar archive or URL as a Docker image, similar to `docker image import`.
12+
13+
## Example Usage
14+
15+
```terraform
16+
## The following code performs an `docker image import` whenever the `import.tar` file changes
17+
18+
resource "terraform_data" "bootstrap" {
19+
triggers_replace = [
20+
filesha512("./import.tar")
21+
]
22+
23+
lifecycle {
24+
action_trigger {
25+
events = [after_update]
26+
actions = [action.docker_image_import.import_export]
27+
}
28+
}
29+
}
30+
31+
32+
action "docker_image_import" "import_export" {
33+
config {
34+
source = pathexpand("./import.tar")
35+
reference = "example-imported-image:latest"
36+
message = "imported from a tar archive"
37+
changes = ["CMD [\"sh\"]"]
38+
platform = "linux/amd64"
39+
}
40+
}
41+
```
42+
43+
<!-- action schema generated by tfplugindocs -->
44+
## Schema
45+
46+
### Required
47+
48+
- `reference` (String) Image name and optional tag to apply to the imported image, for example `my-image:latest`.
49+
- `source` (String) Path to a local tar archive or an http(s) URL containing the filesystem to import.
50+
51+
### Optional
52+
53+
- `changes` (List of String) Raw Dockerfile instructions to apply to the imported image.
54+
- `message` (String) Optional message to store with the imported image.
55+
- `platform` (String) Platform to assign to the imported image.

0 commit comments

Comments
 (0)