File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ package clab
2
2
3
3
import (
4
4
"os"
5
+ "path"
5
6
"text/template"
6
7
8
+ log "github.com/sirupsen/logrus"
7
9
"github.com/srl-labs/containerlab/types"
8
10
"github.com/srl-labs/containerlab/utils"
9
11
)
@@ -46,6 +48,12 @@ func (c *CLab) RemoveSSHConfig(topoPaths *types.TopoPaths) error {
46
48
47
49
// AddSSHConfig adds the lab specific ssh config file.
48
50
func (c * CLab ) AddSSHConfig () error {
51
+ sshConfigDir := path .Dir (c .TopoPaths .SSHConfigPath ())
52
+ if ! utils .FileOrDirExists (sshConfigDir ) {
53
+ log .Debugf ("ssh config directory %s does not exist, skipping ssh config generation" , sshConfigDir )
54
+ return nil
55
+ }
56
+
49
57
tmpl := & SSHConfigTmpl {
50
58
TopologyName : c .Config .Name ,
51
59
Nodes : make ([]SSHConfigNodeTmpl , 0 , len (c .Nodes )),
@@ -68,7 +76,7 @@ func (c *CLab) AddSSHConfig() error {
68
76
return err
69
77
}
70
78
71
- f , err := utils . CreateFileWithPath (c .TopoPaths .SSHConfigPath ())
79
+ f , err := os . Create (c .TopoPaths .SSHConfigPath ())
72
80
if err != nil {
73
81
return err
74
82
}
Original file line number Diff line number Diff line change @@ -2678,10 +2678,6 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
2678
2678
github.com/spf13/viper v1.13.0 /go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw =
2679
2679
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 h1:lIOOHPEbXzO3vnmx2gok1Tfs31Q8GQqKLc8vVqyQq/I =
2680
2680
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 /go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8 =
2681
- github.com/steiler/acls v0.0.0-20231106135104-9c34ae82c793 h1:lY8SggLL0JyttzcNEIRzbywKiKcIlVlF7ZPwTthG9eA =
2682
- github.com/steiler/acls v0.0.0-20231106135104-9c34ae82c793 /go.mod h1:kS9/GuHDS4t2YmY2ijbaK3m1iU4+BgRZS7GoDTC9BfY =
2683
- github.com/steiler/acls v0.0.0-20231106152733-bb3d5d7b05c8 h1:RqP82h2DREJxj7AJbT0k7z2Jye6lweij5s14PUHic1o =
2684
- github.com/steiler/acls v0.0.0-20231106152733-bb3d5d7b05c8 /go.mod h1:kS9/GuHDS4t2YmY2ijbaK3m1iU4+BgRZS7GoDTC9BfY =
2685
2681
github.com/steiler/acls v0.1.0 h1:fKVnEJ7ebghq2Ed5N1cU9fZrCCRj4xVRPrP7OswaRX8 =
2686
2682
github.com/steiler/acls v0.1.0 /go.mod h1:kS9/GuHDS4t2YmY2ijbaK3m1iU4+BgRZS7GoDTC9BfY =
2687
2683
github.com/stoewer/go-strcase v1.2.0 /go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8 =
Original file line number Diff line number Diff line change @@ -407,16 +407,3 @@ func AdjustFileACLs(fsPath string) error {
407
407
408
408
return a .Apply (fsPath , acls .PosixACLDefault )
409
409
}
410
-
411
- // CreateFileWithPath creates a file by the given path
412
- // and creates the directories if needed.
413
- func CreateFileWithPath (path string ) (* os.File , error ) {
414
- // create directories if needed, since we promise to create the file
415
- // if it doesn't exist
416
- err := os .MkdirAll (filepath .Dir (path ), 0754 )
417
- if err != nil {
418
- return nil , err
419
- }
420
-
421
- return os .Create (path )
422
- }
You can’t perform that action at this time.
0 commit comments