upgrade

package
v0.0.0-...-76c2fa8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAFile = errors.New("not a file")

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

func NewCmd

func NewCmd(git GitServer, opts ...CmdOption) *Cmd

func (*Cmd) UpgradePlugin

func (c *Cmd) UpgradePlugin(ctx context.Context, currentVersion string) error

UpgradePlugin upgrade OS binary based on the latest version

type CmdConfig

type CmdConfig struct {
	Log    logrus.FieldLogger
	Out    io.Writer
	Writer Writer
	Reader *bufio.Reader

	BinaryName string
	Org        string
	Repo       string
}

func (*CmdConfig) Default

func (c *CmdConfig) Default()

func (*CmdConfig) Option

func (c *CmdConfig) Option(opts ...CmdOption)

type CmdOption

type CmdOption interface {
	ConfigureCmd(*CmdConfig)
}

type GitServer

type GitServer interface {
	GetLatestVersion(ctx context.Context) (Release, error)
	GetReleaseArchive(ctx context.Context, release Release) ([]byte, error)
}

GitServer defines generic functions for getting the latest release and archive

type Release

type Release struct {
	TagName string         `json:"tag_name"`
	Assets  []ReleaseAsset `json:"assets"`
}

Release type defines the tag and its assets

type ReleaseAsset

type ReleaseAsset struct {
	Name        string `json:"name"`
	DownloadURL string `json:"browser_download_url"`
}

ReleaseAsset defines the name and download url

type SafeWriter

type SafeWriter struct {
	// contains filtered or unexported fields
}

func NewSafeWriter

func NewSafeWriter(opts ...SafeWriterOption) *SafeWriter

func (*SafeWriter) Write

func (w *SafeWriter) Write(path string, data []byte) error

type SafeWriterConfig

type SafeWriterConfig struct {
	Log logrus.FieldLogger
}

func (*SafeWriterConfig) Default

func (c *SafeWriterConfig) Default()

func (*SafeWriterConfig) Option

func (c *SafeWriterConfig) Option(opts ...SafeWriterOption)

type SafeWriterOption

type SafeWriterOption interface {
	ConfigureSafeWriter(*SafeWriterConfig)
}

type WithBinaryName

type WithBinaryName string

func (WithBinaryName) ConfigureCmd

func (w WithBinaryName) ConfigureCmd(c *CmdConfig)

type WithLog

type WithLog struct{ Log logrus.FieldLogger }

func (WithLog) ConfigureCmd

func (w WithLog) ConfigureCmd(c *CmdConfig)

func (WithLog) ConfigureSafeWriter

func (w WithLog) ConfigureSafeWriter(c *SafeWriterConfig)

type WithOrg

type WithOrg string

func (WithOrg) ConfigureCmd

func (w WithOrg) ConfigureCmd(c *CmdConfig)

type WithOut

type WithOut struct{ Out io.Writer }

func (WithOut) ConfigureCmd

func (w WithOut) ConfigureCmd(c *CmdConfig)

type WithRepo

type WithRepo string

func (WithRepo) ConfigureCmd

func (w WithRepo) ConfigureCmd(c *CmdConfig)

type WithWriter

type WithWriter struct{ Writer Writer }

func (WithWriter) ConfigureCmd

func (w WithWriter) ConfigureCmd(c *CmdConfig)

type Writer

type Writer interface {
	Write(path string, data []byte) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL