Skip to content

Commit 2829636

Browse files
committed
Merge branch 'main' into docs-publish
2 parents f652721 + d215bdb commit 2829636

Some content is hidden

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

52 files changed

+1408
-398
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ RUN mkdir -p /root/.docker && echo "{}" > /root/.docker/config.json
4242
# Maintain SSH_AUTH_SOCK env var when using sudo
4343
RUN mkdir -p /etc/sudoers.d && echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/ssh_auth_sock
4444

45+
# Add vscode user to clab_admins group so that it can run sudo-less clab commands
46+
# the group is created when clab is installed via the installation script
47+
RUN usermod -aG clab_admins vscode
48+
4549
# Switch to the vscode user provided by the base image
4650
USER vscode
4751

.devcontainer/docker-in-docker/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
"yzhang.markdown-all-in-one",
5353
"davidanson.vscode-markdownlint",
5454
// proto
55-
"zxh404.vscode-proto3"
55+
"zxh404.vscode-proto3",
56+
// containerlab
57+
"srl-labs.vscode-containerlab"
5658
]
5759
}
5860
},

.devcontainer/docker-in-docker_slim/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"redhat.vscode-yaml",
4040
// markdown
4141
"yzhang.markdown-all-in-one",
42-
"davidanson.vscode-markdownlint"
42+
"davidanson.vscode-markdownlint",
43+
// containerlab
44+
"srl-labs.vscode-containerlab"
4345
]
4446
}
4547
},

.devcontainer/docker-outside-of-docker/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
"yzhang.markdown-all-in-one",
5959
"davidanson.vscode-markdownlint",
6060
// proto
61-
"zxh404.vscode-proto3"
61+
"zxh404.vscode-proto3",
62+
// containerlab
63+
"srl-labs.vscode-containerlab"
6264
]
6365
}
6466
},

.devcontainer/docker-outside-of-docker_slim/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
"redhat.vscode-yaml",
4949
// markdown
5050
"yzhang.markdown-all-in-one",
51-
"davidanson.vscode-markdownlint"
51+
"davidanson.vscode-markdownlint",
52+
// containerlab
53+
"srl-labs.vscode-containerlab"
5254
]
5355
}
5456
},

.devcontainer/slim.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ RUN mkdir -p /root/.docker && echo "{}" > /root/.docker/config.json
3838
# Maintain SSH_AUTH_SOCK env var when using sudo
3939
RUN mkdir -p /etc/sudoers.d && echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/ssh_auth_sock
4040

41+
# Add vscode user to clab_admins group so that it can run sudo-less clab commands
42+
# the group is created when clab is installed via the installation script
43+
RUN usermod -aG clab_admins vscode
44+
4145
# Switch to the vscode user provided by the base image
4246
USER vscode
4347

.github/workflows/cicd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ on:
1111
workflow_dispatch:
1212

1313
env:
14-
GO_VER: "1.22.6"
14+
GO_VER: "1.22.11"
1515
CGO_ENABLED: 0
16-
MKDOCS_INS_VER: 9.5.9-insiders-4.52.2-hellt
16+
MKDOCS_INS_VER: 9.6.1-insiders-4.53.15-hellt
1717
GORELEASER_VER: v2.6.1
1818
PY_VER: "3.10"
1919

.github/workflows/force-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
# make sure those env vars are aligned with the ones in ci-cd.yml workflow
99
env:
10-
GO_VER: "1.22.6"
10+
GO_VER: "1.22.11"
1111
CGO_ENABLED: 0
1212
MKDOCS_INS_VER: 9.5.9-insiders-4.52.2-hellt
1313
GORELEASER_VER: v2.0.1

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ tests/out
4646

4747

4848
# readd test labDir files
49-
!clab/test_data/clab-*
49+
!clab/test_data/clab-*
50+
__pycache__

Makefile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
BIN_DIR = $(CURDIR)/bin
22
BINARY = $(BIN_DIR)/containerlab
3-
MKDOCS_VER = 9.5.9
3+
MKDOCS_VER = 9.6.1
44
# insiders version/tag https://github.com/srl-labs/mkdocs-material-insiders/pkgs/container/mkdocs-material-insiders
55
# make sure to also change the mkdocs version in actions' cicd.yml and force-build.yml files
6-
MKDOCS_INS_VER = 9.5.9-insiders-4.52.2-hellt
6+
MKDOCS_INS_VER = 9.6.1-insiders-4.53.15-hellt
77

88
DATE := $(shell date)
99
COMMIT_HASH := $(shell git rev-parse --short HEAD)
@@ -17,36 +17,52 @@ all: build
1717
build:
1818
mkdir -p $(BIN_DIR)
1919
CGO_ENABLED=0 go build -o $(BINARY) -ldflags="$(LDFLAGS)" main.go
20+
sudo chown root:root $(BINARY)
21+
sudo chmod 4755 $(BINARY)
2022

2123
build-linux-arm64:
2224
mkdir -p $(BIN_DIR)
2325
GOOS=linux GOARCH=arm64 go build -o $(BINARY) -ldflags="$(LDFLAGS)" main.go
26+
sudo chown root:root $(BINARY)
27+
sudo chmod 4755 $(BINARY)
2428

2529
build-linux-amd64:
2630
mkdir -p $(BIN_DIR)
2731
GOOS=linux GOARCH=amd64 go build -o $(BINARY) -ldflags="$(LDFLAGS)" main.go
32+
sudo chown root:root $(BINARY)
33+
sudo chmod 4755 $(BINARY)
2834

2935
build-with-cover:
3036
mkdir -p $(BIN_DIR)
3137
go build -cover -o $(BINARY) -ldflags="$(LDFLAGS)" main.go
38+
sudo chown root:root $(BINARY)
39+
sudo chmod 4755 $(BINARY)
3240

3341
build-debug:
3442
mkdir -p $(BIN_DIR)
3543
go build -o $(BINARY) -gcflags=all="-N -l" -race -cover main.go
44+
sudo chown root:root $(BINARY)
45+
sudo chmod 4755 $(BINARY)
3646

3747
build-dlv-debug:
3848
mkdir -p $(BIN_DIR)
3949
go build -o $(BINARY) -gcflags=all="-N -l" main.go
50+
sudo chown root:root $(BINARY)
51+
sudo chmod 4755 $(BINARY)
4052

4153

4254
build-with-podman:
4355
mkdir -p $(BIN_DIR)
4456
CGO_ENABLED=0 go build -o $(BINARY) -ldflags="$(LDFLAGS)" -trimpath -tags "podman exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper exclude_graphdriver_overlay containers_image_openpgp" main.go
4557
chmod a+x $(BINARY)
58+
sudo chown root:root $(BINARY)
59+
sudo chmod 4755 $(BINARY)
4660

4761
build-with-podman-debug:
4862
mkdir -p $(BIN_DIR)
4963
CGO_ENABLED=1 go build -o $(BINARY) -gcflags=all="-N -l" -race -cover -trimpath -tags "podman exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper exclude_graphdriver_overlay containers_image_openpgp" main.go
64+
sudo chown root:root $(BINARY)
65+
sudo chmod 4755 $(BINARY)
5066

5167
convert-coverage:
5268
go tool covdata textfmt -i=/tmp/clab-tests/coverage -o coverage.out
@@ -128,20 +144,20 @@ htmltest:
128144
.PHONY: oci-push
129145
oci-push: build-with-podman
130146
@echo
131-
@echo "With the following pull command you get a containerlab binary at your working directory. To use this downloaded binary - ./containerlab deploy.... Make sure not forget to add ./ prefix in order to use the downloaded binary and not the globally installed containerlab!"
132-
@echo 'If https proxy is configured in your environment, pass the proxies via --env HTTPS_PROXY="<proxy-address>" flag of the docker run command.'
133147
# push to ttl.sh
134148
# docker run --rm -v $(CURDIR)/bin:/workspace ghcr.io/oras-project/oras:v1.1.0 push ttl.sh/clab-$(COMMIT_HASH):1d ./containerlab
135149
# @echo "download with: docker run --rm -v \$$(pwd):/workspace ghcr.io/oras-project/oras:v1.1.0 pull ttl.sh/clab-$(COMMIT_HASH):1d"
136150
# push to ghcr.io
137151
@echo ""
138152
docker run --rm -v $(CURDIR)/bin:/workspace -v $${HOME}/.docker/config.json:/root/.docker/config.json ghcr.io/oras-project/oras:v1.1.0 push ghcr.io/srl-labs/clab-oci:$(COMMIT_HASH) ./containerlab
153+
@echo "With the following pull command you get a containerlab binary at your working directory. To use this downloaded binary - ./containerlab deploy.... Make sure not forget to add ./ prefix in order to use the downloaded binary and not the globally installed containerlab!"
154+
@echo 'If https proxy is configured in your environment, pass the proxies via --env HTTPS_PROXY="<proxy-address>" flag of the docker run command.'
139155
@echo "download with: sudo docker run --rm -v \$$(pwd):/workspace ghcr.io/oras-project/oras:v1.1.0 pull ghcr.io/srl-labs/clab-oci:$(COMMIT_HASH)"
140156

141157
oci-arm-push: build-linux-arm64
142158
@echo
143-
@echo "With the following pull command you get a containerlab binary at your working directory. To use this downloaded binary - do `chmod +x ./containerlab` and then `./containerlab deploy`. Make sure not forget to add ./ prefix in order to use the downloaded binary and not the globally installed containerlab!"
144-
@echo 'If https proxy is configured in your environment, pass the proxies via --env HTTPS_PROXY="<proxy-address>" flag of the docker run command.'
145159
@echo ""
146160
docker run --rm -v $(CURDIR)/bin:/workspace -v $${HOME}/.docker/config.json:/root/.docker/config.json ghcr.io/oras-project/oras:v1.1.0 push ghcr.io/srl-labs/clab-oci:$(COMMIT_HASH) ./containerlab
161+
@echo "With the following pull command you get a containerlab binary at your working directory. To use this downloaded binary - do `chmod +x ./containerlab` and then `./containerlab deploy`. Make sure not forget to add ./ prefix in order to use the downloaded binary and not the globally installed containerlab!"
162+
@echo 'If https proxy is configured in your environment, pass the proxies via --env HTTPS_PROXY="<proxy-address>" flag of the docker run command.'
147163
@echo "download with: sudo docker run --rm -v \$$(pwd):/workspace ghcr.io/oras-project/oras:v1.1.0 pull ghcr.io/srl-labs/clab-oci:$(COMMIT_HASH)"

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
[![github release](https://img.shields.io/github/release/srl-labs/containerlab.svg?style=flat-square&color=00c9ff&labelColor=bec8d2)](https://github.com/srl-labs/containerlab/releases/)
44
[![Github all releases](https://img.shields.io/github/downloads/srl-labs/containerlab/total.svg?style=flat-square&color=00c9ff&labelColor=bec8d2)](https://github.com/srl-labs/containerlab/releases/)
55
[![Doc](https://img.shields.io/badge/Docs-containerlab.dev-blue?style=flat-square&color=00c9ff&labelColor=bec8d2)](https://containerlab.dev)
6-
[![Twitter](https://img.shields.io/badge/follow-%40go_containerlab-1DA1F2?logo=twitter&style=flat-square&color=00c9ff&labelColor=bec8d2)](https://twitter.com/go_containerlab)
6+
[![Bluesky](https://img.shields.io/badge/follow-containerlab-1DA1F2?logo=bluesky&style=flat-square&color=00c9ff&labelColor=bec8d2)](https://bsky.app/profile/containerlab.dev)
77
[![Discord](https://img.shields.io/discord/860500297297821756?style=flat-square&label=discord&logo=discord&color=00c9ff&labelColor=bec8d2)](https://discord.gg/vAyddtaEV9)
8-
[![Go Report](https://img.shields.io/badge/go%20report-A%2B-blue?style=flat-square&color=00c9ff&labelColor=bec8d2)](https://goreportcard.com/report/github.com/srl-labs/containerlab)
98

109
---
1110

clab/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ func (c *CLab) addDefaultLabels(n nodes.Node) {
557557

558558
cfg.Labels[labels.Containerlab] = c.Config.Name
559559
cfg.Labels[labels.NodeName] = cfg.ShortName
560+
cfg.Labels[labels.LongName] = cfg.LongName
560561
cfg.Labels[labels.NodeKind] = cfg.Kind
561562
cfg.Labels[labels.NodeType] = cfg.NodeType
562563
cfg.Labels[labels.NodeGroup] = cfg.Group

clab/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ func TestLabelsInit(t *testing.T) {
364364
want: map[string]string{
365365
labels.Containerlab: "topo1",
366366
labels.NodeName: "node1",
367+
labels.LongName: "clab-topo1-node1",
367368
labels.NodeKind: "nokia_srlinux",
368369
labels.NodeType: "ixrd2l",
369370
labels.NodeGroup: "",
@@ -378,6 +379,7 @@ func TestLabelsInit(t *testing.T) {
378379
want: map[string]string{
379380
labels.Containerlab: "topo1",
380381
labels.NodeName: "node2",
382+
labels.LongName: "clab-topo1-node2",
381383
labels.NodeKind: "nokia_srlinux",
382384
labels.NodeType: "ixrd2l",
383385
labels.NodeGroup: "",
@@ -394,6 +396,7 @@ func TestLabelsInit(t *testing.T) {
394396
want: map[string]string{
395397
labels.Containerlab: "topo2",
396398
labels.NodeName: "node1",
399+
labels.LongName: "clab-topo2-node1",
397400
labels.NodeKind: "nokia_srlinux",
398401
labels.NodeType: "ixrd2l",
399402
labels.NodeGroup: "",
@@ -409,6 +412,7 @@ func TestLabelsInit(t *testing.T) {
409412
want: map[string]string{
410413
labels.Containerlab: "topo3",
411414
labels.NodeName: "node2",
415+
labels.LongName: "clab-topo3-node2",
412416
labels.NodeKind: "nokia_srlinux",
413417
labels.NodeType: "ixrd2l",
414418
labels.NodeGroup: "",

cmd/common/common.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package common
2+
3+
import (
4+
"time"
5+
)
6+
7+
var (
8+
Debug bool
9+
Timeout time.Duration
10+
)
11+
12+
// path to the topology file.
13+
var Topo string
14+
15+
var (
16+
VarsFile string
17+
Graph bool
18+
Runtime string
19+
)
20+
21+
// subset of nodes to work with.
22+
var NodeFilter []string
23+
24+
// lab Name.
25+
var Name string
26+
27+
// Use graceful shutdown.
28+
var Graceful bool

cmd/common/sudo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func CheckAndGetRootPrivs(_ *cobra.Command, _ []string) error {
4848
}
4949

5050
if !slices.Contains(effUserGroupIDs, clabGroup.Gid) {
51-
return fmt.Errorf("user '%v' is not part of containerlab admin group 'clab_admins' (GID %v), which is required to execute this command.\nTo add yourself to this group, run the following command:\n\t$ sudo gpasswd -a %v clab_admins",
51+
return fmt.Errorf("user '%v' is not part of containerlab admin group 'clab_admins' (GID %v), which is required to execute this command.\nTo add yourself to this group, run the following command:\n\t$ sudo usermod -aG clab_admins %v",
5252
currentEffUser.Username, clabGroup.Gid, currentEffUser.Username)
5353
}
5454

cmd/config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/srl-labs/containerlab/clab"
1010
"github.com/srl-labs/containerlab/clab/config"
1111
"github.com/srl-labs/containerlab/clab/config/transport"
12+
"github.com/srl-labs/containerlab/cmd/common"
1213
"github.com/srl-labs/containerlab/nodes"
1314

1415
log "github.com/sirupsen/logrus"
@@ -59,10 +60,10 @@ func configRun(_ *cobra.Command, args []string) error {
5960
config.DebugCount = debugCount
6061

6162
c, err := clab.NewContainerLab(
62-
clab.WithTimeout(timeout),
63-
clab.WithTopoPath(topo, varsFile),
64-
clab.WithNodeFilter(nodeFilter),
65-
clab.WithDebug(debug),
63+
clab.WithTimeout(common.Timeout),
64+
clab.WithTopoPath(common.Topo, common.VarsFile),
65+
clab.WithNodeFilter(common.NodeFilter),
66+
clab.WithDebug(common.Debug),
6667
)
6768
if err != nil {
6869
return err
@@ -156,7 +157,7 @@ func init() {
156157
"comma separated list of nodes to include")
157158
configCmd.Flags().SortFlags = false
158159

159-
configCmd.Flags().StringSliceVarP(&nodeFilter, "node-filter", "", []string{},
160+
configCmd.Flags().StringSliceVarP(&common.NodeFilter, "node-filter", "", []string{},
160161
"comma separated list of nodes to include")
161162

162163
configCmd.AddCommand(configSendCmd)

cmd/config_template.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/spf13/cobra"
55
"github.com/srl-labs/containerlab/clab"
66
"github.com/srl-labs/containerlab/clab/config"
7+
"github.com/srl-labs/containerlab/cmd/common"
78
)
89

910
// Show the template variable s.
@@ -22,9 +23,9 @@ var configTemplateCmd = &cobra.Command{
2223
config.DebugCount = debugCount
2324

2425
c, err := clab.NewContainerLab(
25-
clab.WithTimeout(timeout),
26-
clab.WithTopoPath(topo, varsFile),
27-
clab.WithDebug(debug),
26+
clab.WithTimeout(common.Timeout),
27+
clab.WithTopoPath(common.Topo, common.VarsFile),
28+
clab.WithDebug(common.Debug),
2829
)
2930
if err != nil {
3031
return err

0 commit comments

Comments
 (0)