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 6, 2024
1 parent 5e5dfca commit fa5568e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 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
22 changes: 21 additions & 1 deletion subcommands/config/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,27 @@ in a device group. When run without options, prints out the current configuratio
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`,
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 docker 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 docker apps to a system default (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 system default :
# 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
21 changes: 20 additions & 1 deletion subcommands/devices/config_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ currently configured and reporting.`,
# Set the docker 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 docker 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 docker apps to a system default (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 system default :
# 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 fa5568e

Please sign in to comment.