Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): make it so you can revert override of apps #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Comment on lines +29 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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:
# There are two special characters: "," and "-".
# Providing a "," sets 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:
Comment on lines +34 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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:
# Providing a "-" sets the Compose apps to "preset-apps" (all apps on most devices).
# The system looks in the following locations 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:
Comment on lines +42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set the device tag to a preset-tag :
# The system will look in the following locations in order to get the complete config:
# Set the device tag to a "preset-tag",
# and the system will look in the following locations to get the complete config:

- /usr/lib/sota/conf.d/
- /var/sota/sota.toml
- /etc/sota/conf.d/
fioctl config updates --tag -`,
Comment on lines +29 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An indentation here seems rather weird.
Maybe, @kprosise can help with it?

At the least, these two sentences should be indented at the same level:

# The following explains what happens if you provide a ","
# The following explains what happens if you provide a "-"

The same applies to these three sentences (about indentation):

# Set the Compose apps to none for devices, this will make the device run no apps:
# Set the Compose apps to preset-apps (all apps on most devices):
# Set the device tag to a preset-tag :

Also, as sentences in these paragraphs are user-facing, they deserve a proper punctuation at their ends, like . or : (and proper spacing, like e.g. no space before a colon).

}
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:
Comment on lines +30 to +32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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:
# There are two special characters: "," and "-".
# Providing a "," sets 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:
Comment on lines +35 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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:
# Providing a "-" sets the Compose apps to "preset-apps" (all apps on most devices).
# The system looks in the following locations 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:
Comment on lines +43 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Set the device tag to a preset-tag :
# The system will look in the following locations in order to get the complete config:
# Set the device tag to a "preset-tag",
# and the system will look in the following locations 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
Loading