MCPcopy
hub / github.com/lxc/incus / run

Method run

cmd/incus/admin_init.go:66–158  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

64}
65
66func (c *cmdAdminInit) run(cmd *cobra.Command, args []string) error {
67 parsed, err := c.global.Parse(cmdAdminInitUsage, cmd, args)
68 if err != nil {
69 return err
70 }
71
72 // Quick checks.
73 if c.flagAuto && c.flagPreseed {
74 return errors.New(i18n.G("Can't use --auto and --preseed together"))
75 }
76
77 if c.flagMinimal && c.flagPreseed {
78 return errors.New(i18n.G("Can't use --minimal and --preseed together"))
79 }
80
81 if c.flagMinimal && c.flagAuto {
82 return errors.New(i18n.G("Can't use --minimal and --auto together"))
83 }
84
85 if !c.flagAuto && (c.flagNetworkAddress != "" || c.flagNetworkPort != -1 ||
86 c.flagStorageBackend != "" || c.flagStorageDevice != "" ||
87 c.flagStorageLoopSize != -1 || c.flagStoragePool != "") {
88 return errors.New(i18n.G("Configuration flags require --auto"))
89 }
90
91 if c.flagDump && (c.flagAuto || c.flagMinimal ||
92 c.flagPreseed || c.flagNetworkAddress != "" ||
93 c.flagNetworkPort != -1 || c.flagStorageBackend != "" ||
94 c.flagStorageDevice != "" || c.flagStorageLoopSize != -1 ||
95 c.flagStoragePool != "") {
96 return errors.New(i18n.G("Can't use --dump with other flags"))
97 }
98
99 // Connect to the daemon
100 d, err := incus.ConnectIncusUnix("", nil)
101 if err != nil {
102 return fmt.Errorf(i18n.G("Failed to connect to local daemon: %w"), err)
103 }
104
105 server, _, err := d.GetServer()
106 if err != nil {
107 return fmt.Errorf(i18n.G("Failed to connect to get server info: %w"), err)
108 }
109
110 // Dump mode
111 if c.flagDump {
112 err := c.runDump(d)
113 if err != nil {
114 return err
115 }
116
117 return nil
118 }
119
120 // Prepare the input data
121 var config *api.InitPreseed
122
123 switch {

Callers

nothing calls this directly

Calls 11

runDumpMethod · 0.95
runPreseedMethod · 0.95
runAutoMethod · 0.95
runInteractiveMethod · 0.95
GFunction · 0.92
fillClusterConfigFunction · 0.85
updateClusterFunction · 0.85
ErrorfMethod · 0.80
ParseMethod · 0.65
GetServerMethod · 0.65
ApplyServerPreseedMethod · 0.65

Tested by

no test coverage detected