Skip to content

Commit

Permalink
[v1.1.x] Move recovery hostname to cloud-config-defaults (#2047)
Browse files Browse the repository at this point in the history
* Move recovery hostname to cloud-config-defaults

Setting recovery hostname is mostly a nice-to-have and can be
destructive so move it to cloud-config-defaults feature.

Signed-off-by: Fredrik Lönnegren <[email protected]>

* Fix lints

Signed-off-by: Fredrik Lönnegren <[email protected]>

---------

Signed-off-by: Fredrik Lönnegren <[email protected]>
  • Loading branch information
frelon authored Apr 17, 2024
1 parent bc91df2 commit c20fa28
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/build-disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewBuildDisk(root *cobra.Command, addCheckRoot bool) *cobra.Command {
Use: "build-disk image",
Short: "Build a disk image using the given image (experimental and subject to change)",
Args: cobra.MaximumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewBuildISO(root *cobra.Command, addCheckRoot bool) *cobra.Command {
" * <sourceType> - might be [\"dir\", \"file\", \"oci\", \"docker\", \"channel\"], as default is \"docker\"\n" +
" * <sourceName> - is path to file or directory, image name with tag version or channel name",
Args: cobra.MaximumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloud-init.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewCloudInitCmd(root *cobra.Command) *cobra.Command {
Use: "cloud-init",
Short: "Run cloud-init",
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlags(cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func ReadConfigRun(configDir string, flags *pflag.FlagSet, mounter mount.Interfa
cfgExtra := filepath.Join(configDir, "config.d")
if exists, _ := utils.Exists(cfg.Fs, cfgExtra); exists {
viper.AddConfigPath(cfgExtra)
err := filepath.WalkDir(cfgExtra, func(path string, d fs.DirEntry, err error) error {
err := filepath.WalkDir(cfgExtra, func(_ string, d fs.DirEntry, _ error) error {
if !d.IsDir() && filepath.Ext(d.Name()) == ".yaml" {
viper.SetConfigType("yaml")
viper.SetConfigName(strings.TrimSuffix(d.Name(), ".yaml"))
Expand Down
2 changes: 1 addition & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewInstallCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
Use: "install DEVICE",
Short: "Elemental installer",
Args: cobra.MaximumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pull-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewPullImageCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
Use: "pull-image IMAGE DESTINATION",
Short: "Pull remote image to local file",
Args: cobra.ExactArgs(2),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func NewResetCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
Use: "reset",
Short: "Reset OS",
Args: cobra.ExactArgs(0),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
path, err := exec.LookPath("mount")
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/run-stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewRunStage(root *cobra.Command) *cobra.Command {
Use: "run-stage STAGE",
Short: "Run stage from cloud-init",
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
PreRun: func(_ *cobra.Command, _ []string) {

},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ func NewUpgradeCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
Use: "upgrade",
Short: "Upgrade the system",
Args: cobra.ExactArgs(0),
PreRunE: func(cmd *cobra.Command, args []string) error {
PreRunE: func(_ *cobra.Command, _ []string) error {
if addCheckRoot {
return CheckRoot()
}
return nil
},

RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
path, err := exec.LookPath("mount")
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewVersionCmd(root *cobra.Command) *cobra.Command {
Use: "version",
Args: cobra.ExactArgs(0),
Short: "Print the version",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
v := version.Get()
commit := v.GitCommit
if len(commit) > 7 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ stages:
permissions: 0644
owner: 0
group: 0
boot:
- name: "Recovery"
if: '[ -f "/run/cos/recovery_mode" ]'
hostname: "recovery"

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ stages:
boot:
- name: "Recovery"
if: '[ -f "/run/cos/recovery_mode" ]'
hostname: "recovery"
commands:
- |
source /etc/os-release
Expand Down

0 comments on commit c20fa28

Please sign in to comment.