Debian Codegraph @

examples/config/config.go

raw symbols SCIP
1 // Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved.
2 // Use of this source code is governed by a LGPLv2.1
3 // license that can be found in the LICENSE file.
4
5 //go:build linux && cgo
6 // +build linux,cgo
7
8 package mainscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/
9
10 import (
11 "flagscip-go gomod github.com/golang/go/src go1.20 flag/"
12 "logscip-go gomod github.com/golang/go/src go1.20 log/"
13
14 "github.com/lxc/go-lxcscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/"
15 )
16
17 var (
18 lxcpathscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/lxcpath. string
19 namescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/name. string
20 hostnamescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/hostname. string
21 )
22
23 func initscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/init().() {
24 flagscip-go gomod github.com/golang/go/src go1.20 flag/.StringVarscip-go gomod github.com/golang/go/src go1.20 flag/StringVar().(&lxcpathscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/lxcpath., "lxcpath", lxcscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/.DefaultConfigPathscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/DefaultConfigPath().(), "Use specified container path")
25 flagscip-go gomod github.com/golang/go/src go1.20 flag/.StringVarscip-go gomod github.com/golang/go/src go1.20 flag/StringVar().(&namescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/name., "name", "rubik", "Name of the container")
26 flagscip-go gomod github.com/golang/go/src go1.20 flag/.StringVarscip-go gomod github.com/golang/go/src go1.20 flag/StringVar().(&hostnamescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/hostname., "hostname", "rubik-host1", "Hostname of the container")
27 flagscip-go gomod github.com/golang/go/src go1.20 flag/.Parsescip-go gomod github.com/golang/go/src go1.20 flag/Parse().()
28 }
29
30 func mainscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/main().() {
31 c, err := lxcscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/.NewContainerscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/NewContainer().(namescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/name., lxcpathscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/lxcpath.)
32 if err != nil {
33 logscip-go gomod github.com/golang/go/src go1.20 log/.Fatalfscip-go gomod github.com/golang/go/src go1.20 log/Fatalf().("ERROR: %s\n", err.Error())
34 }
35 defer c.Releasescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/Container#Release().()
36
37 //setting hostname
38 err = c.SetConfigItemscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/Container#SetConfigItem().("lxc.utsname", hostnamescip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc/examples/config`/hostname.)
39 if err != nil {
40 logscip-go gomod github.com/golang/go/src go1.20 log/.Fatalfscip-go gomod github.com/golang/go/src go1.20 log/Fatalf().("ERROR: %s\n", err.Error())
41 }
42
43 // fetching rootfs location
44 rootfs := c.ConfigItemscip-go gomod github.com/lxc/go-lxc . `github.com/lxc/go-lxc`/Container#ConfigItem().("lxc.rootfs")[0]
45 logscip-go gomod github.com/golang/go/src go1.20 log/.Printfscip-go gomod github.com/golang/go/src go1.20 log/Printf().("Root FS: %s\n", rootfs)
46
47 }