Skip to content

Commit

Permalink
feat(config): make it so you can revert override of apps
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Bode <[email protected]>
  • Loading branch information
StealthyCoder committed Nov 12, 2024
1 parent 5e5dfca commit c3d393d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
27 changes: 22 additions & 5 deletions subcommands/common_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,19 @@ func SetUpdatesConfig(opts *SetUpdatesConfigOptions, reportedTag string, reporte
if reportedApps != nil {
fmt.Printf("Apps reported as installed on device: [%s]\n", strings.Join(reportedApps, ","))
}
fmt.Printf("Setting apps to [%s]\n", opts.UpdateApps)
sota.Set("pacman.docker_apps", opts.UpdateApps)
sota.Set("pacman.compose_apps", opts.UpdateApps)
if strings.TrimSpace(opts.UpdateApps) == "-" {
fmt.Printf("Setting apps to system default.\n")
if sota.Has("pacman.docker_apps") {
DieNotNil(sota.Delete("pacman.docker_apps"))
}
if sota.Has("pacman.compose_apps") {
DieNotNil(sota.Delete("pacman.compose_apps"))
}
} else {
fmt.Printf("Setting apps to [%s]\n", opts.UpdateApps)
sota.Set("pacman.docker_apps", opts.UpdateApps)
sota.Set("pacman.compose_apps", opts.UpdateApps)
}
changed = true
}
if opts.UpdateTag != "" && configuredTag != opts.UpdateTag {
Expand All @@ -245,8 +255,15 @@ func SetUpdatesConfig(opts *SetUpdatesConfigOptions, reportedTag string, reporte
if len(reportedTag) > 0 {
fmt.Printf("Tag reported by device: %s\n", reportedTag)
}
fmt.Printf("Setting tag to %s\n", opts.UpdateTag)
sota.Set("pacman.tags", opts.UpdateTag)
if strings.TrimSpace(opts.UpdateTag) == "-" {
fmt.Printf("Setting tag to system default.\n")
if sota.Has("pacman.tags") {
DieNotNil(sota.Delete("pacman.tags"))
}
} else {
fmt.Printf("Setting tag to %s\n", opts.UpdateTag)
sota.Set("pacman.tags", opts.UpdateTag)
}
changed = true
}

Expand Down
26 changes: 23 additions & 3 deletions subcommands/config/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,31 @@ in a device group. When run without options, prints out the current configuratio
# Make devices start taking updates from Targets tagged with "devel":
fioctl config updates --group beta --tag devel
# Set the docker apps that devices will run:
# Set the Compose apps that devices will run:
fioctl config updates --group beta --apps shellhttpd
# Set the docker apps and the tag for devices:
fioctl config updates --group beta --apps shellhttpd --tag master`,
# Set the Compose apps and the tag for devices:
fioctl config updates --group beta --apps shellhttpd --tag master
# There are two special characters: "," and "-"
# The following explains what happens if you provide a ","
# Set the Compose apps to none for devices, this will make the device run no apps:
fioctl config updates --apps ,
# The following explains what happens if you provide a "-"
# Set the Compose apps to preset-apps (all apps on most devices):
# The system will look in the following locations in order to get the complete config:
- /usr/lib/sota/conf.d/
- /var/sota/sota.toml
- /etc/sota/conf.d/
fioctl config updates --apps -
# Set the device tag to a preset-tag :
# The system will look in the following locations in order to get the complete config:
- /usr/lib/sota/conf.d/
- /var/sota/sota.toml
- /etc/sota/conf.d/
fioctl config updates --tag -`,
}
cmd.AddCommand(configUpdatesCmd)
configUpdatesCmd.Flags().StringP("group", "g", "", "Device group to use")
Expand Down
25 changes: 22 additions & 3 deletions subcommands/devices/config_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,31 @@ currently configured and reporting.`,
# Make a device start taking updates from Targets tagged with "devel"
fioctl devices config updates <device> --tag devel
# Set the docker apps a device will run:
# Set the Compose apps a device will run:
fioctl devices config updates <device> --apps shellhttpd
# Set the docker apps and the tag:
# Set the Compose apps and the tag:
fioctl devices config updates <device> --apps shellhttpd --tag master
`,
# There are two special characters: "," and "-"
# The following explains what happens if you provide a ","
# Set the Compose apps to none, meaning it will run no apps:
fioctl devices config updates <device> --apps ,
# The following explains what happens if you provide a "-"
# Set the Compose apps to preset-apps (all apps on most devices):
# The system will look in the following locations in order to get the complete config:
- /usr/lib/sota/conf.d/
- /var/sota/sota.toml
- /etc/sota/conf.d/
fioctl devices config updates <device> --apps -
# Set the device tag to a preset-tag :
# The system will look in the following locations in order to get the complete config:
- /usr/lib/sota/conf.d/
- /var/sota/sota.toml
- /etc/sota/conf.d/
fioctl devices config updates <device> --tag -`,
}
configCmd.AddCommand(configUpdatesCmd)
configUpdatesCmd.Flags().StringP("tag", "", "", "Target tag for device to follow")
Expand Down

0 comments on commit c3d393d

Please sign in to comment.