Skip to content

Commit 2e72261

Browse files
authored
Merge pull request #1732 from nanjj/instancetypes
Support disabling download of instance type definitions
2 parents 36701b9 + 92b5fcd commit 2e72261

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cmd/incusd/instance_instance_types.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,19 @@ func instanceRefreshTypes(ctx context.Context, s *state.State) error {
153153

154154
// Set an initial value from the cache
155155
if instanceTypes == nil {
156-
_ = instanceLoadCache()
156+
instanceTypes = map[string]map[string]*instanceType{}
157+
}
158+
159+
if len(instanceTypes) == 0 {
160+
err := instanceLoadCache()
161+
if err != nil {
162+
return err
163+
}
164+
}
165+
166+
// Allow disabling instance type download.
167+
if util.IsTrue(os.Getenv("INCUS_SKIP_INSTANCE_TYPES")) {
168+
return nil
157169
}
158170

159171
// Get the list of instance type sources

doc/environment.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ Name | Description
1919
Name | Description
2020
:--- | :----
2121
`EDITOR` | What text editor to use
22-
`VISUAL` | What text editor to use (if `EDITOR` isn't set)
2322
`INCUS_CONF` | Path to the client configuration directory
2423
`INCUS_GLOBAL_CONF` | Path to the global client configuration directory
25-
`INCUS_REMOTE` | Name of the remote to use (overrides configured default remote)
2624
`INCUS_PROJECT` | Name of the project to use (overrides configured default project)
25+
`INCUS_REMOTE` | Name of the remote to use (overrides configured default remote)
26+
`VISUAL` | What text editor to use (if `EDITOR` isn't set)
2727

2828
## Server environment variable
2929

@@ -33,10 +33,11 @@ Name | Description
3333
`INCUS_CLUSTER_UPDATE` | Script to call on a cluster update
3434
`INCUS_DEVMONITOR_DIR` | Path to be monitored by the device monitor. This is primarily for testing
3535
`INCUS_DOCUMENTATION` | Path to the documentation to serve through the web server
36+
`INCUS_EDK2_PATH` | Path to EDK2 firmware build including `*_CODE.fd` and `*_VARS.fd`
3637
`INCUS_EXEC_PATH` | Full path to the Incus binary (used when forking subcommands)
3738
`INCUS_IDMAPPED_MOUNTS_DISABLE` | Disable idmapped mounts support (useful when testing traditional UID shifting)
3839
`INCUS_LXC_TEMPLATE_CONFIG` | Path to the LXC template configuration directory
39-
`INCUS_EDK2_PATH` | Path to EDK2 firmware build including `*_CODE.fd` and `*_VARS.fd`
4040
`INCUS_SECURITY_APPARMOR` | If set to `false`, forces AppArmor off
41+
`INCUS_SKIP_INSTANCE_TYPES` | If set to `true`, skip downloading instance type definitions
4142
`INCUS_UI` | Path to the web UI to serve through the web server
4243
`INCUS_USBIDS_PATH` | Path to the hwdata `usb.ids` file

0 commit comments

Comments
 (0)