Skip to content

Commit

Permalink
fix kind get clusters via nerdctl
Browse files Browse the repository at this point in the history
Now raising errors when using nerdctl for the provider

```console
> ./kind --version
kind version 0.26.0-alpha
> nerdctl --version
nerdctl version 2.0.1
> ./kind get clusters
ERROR: failed to list clusters: command "nerdctl ps -a --filter label=io.x-k8s.kind.cluster --format '{{index .Labels "io.x-k8s.kind.cluster"}}'" failed with error: exit status 1
Command Output: time="2024-12-09T18:01:03+09:00" level=fatal msg="template: :1:2: executing \"\" at <index .Labels \"io.x-k8s.kind.cluster\">: error calling index: cannot index slice/array with type string"
```

nerdctl fixed the `.Label` behavior in v1.7.0.
containerd/nerdctl@2af4cef
However `index .Labels` syntax is not yet supported at least in v2.0.1.
(The style is also used for podman provider, and it is available)

This commit follows up #3429

Signed-off-by: Kenichi Kamiya <[email protected]>
  • Loading branch information
kachick committed Dec 9, 2024
1 parent 74acdf7 commit 836f3df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cluster/internal/providers/nerdctl/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (p *provider) ListClusters() ([]string, error) {
// filter for nodes with the cluster label
"--filter", "label="+clusterLabelKey,
// format to include the cluster name
"--format", fmt.Sprintf(`{{index .Labels "%s"}}`, clusterLabelKey),
"--format", fmt.Sprintf(`{{.Label "%s"}}`, clusterLabelKey),
)
lines, err := exec.OutputLines(cmd)
if err != nil {
Expand Down

0 comments on commit 836f3df

Please sign in to comment.