mirror of
				https://github.com/siderolabs/talos.git
				synced 2025-10-31 08:21:25 +01:00 
			
		
		
		
	This implements a simple way to upgrade Talos node running in maintenance mode (only if Talos is installed, i.e. if `STATE` and `EPHEMERAL` partitions are wiped). Upgrade is only available over SideroLink for security reasons. Upgrade in maintenance mode doesn't support any options, and it works without machine configuration, so proxy environment variables are not available, registry mirrors can't be used, and extensions are not installed. Fixes #6224 Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
		
			
				
	
	
		
			90 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // This Source Code Form is subject to the terms of the Mozilla Public
 | |
| // License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
| // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 | |
| 
 | |
| package install
 | |
| 
 | |
| // Option is a functional option.
 | |
| type Option func(o *Options) error
 | |
| 
 | |
| // Options describes the install options.
 | |
| type Options struct {
 | |
| 	Pull            bool
 | |
| 	Force           bool
 | |
| 	Upgrade         bool
 | |
| 	Zero            bool
 | |
| 	ExtraKernelArgs []string
 | |
| }
 | |
| 
 | |
| // DefaultInstallOptions returns default options.
 | |
| func DefaultInstallOptions() Options {
 | |
| 	return Options{
 | |
| 		Pull: true,
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // Apply list of Option.
 | |
| func (o *Options) Apply(opts ...Option) error {
 | |
| 	for _, opt := range opts {
 | |
| 		if err := opt(o); err != nil {
 | |
| 			return err
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // WithOptions sets Options as a whole.
 | |
| func WithOptions(opts Options) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		*o = opts
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // WithPull sets the pull option.
 | |
| func WithPull(b bool) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		o.Pull = b
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // WithForce sets the force option.
 | |
| func WithForce(b bool) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		o.Force = b
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // WithUpgrade sets the upgrade option.
 | |
| func WithUpgrade(b bool) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		o.Upgrade = b
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // WithZero sets the zero option.
 | |
| func WithZero(b bool) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		o.Zero = b
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // WithExtraKernelArgs sets the extra args.
 | |
| func WithExtraKernelArgs(s []string) Option {
 | |
| 	return func(o *Options) error {
 | |
| 		o.ExtraKernelArgs = s
 | |
| 
 | |
| 		return nil
 | |
| 	}
 | |
| }
 |