utils

package
v0.0.0-...-7b190fc Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentReleaseTag

func GetCurrentReleaseTag(repo string) (string, error)

func GetLatestReleaseTag

func GetLatestReleaseTag(repoURL string) (string, error)

func IsFarmUpdateRequired

func IsFarmUpdateRequired(cmd *cobra.Command, args []string)

func OutFormatForList

func OutFormatForList(out io.Writer) *tablewriter.Table

OutFormatForList This configures the table format for the List commands

func SetCurrentFarmVersion

func SetCurrentFarmVersion(version *db.FarmRelease)

SetCurrentVersion sets the current version of farm repo in DB

Types

type OutputFormatter

type OutputFormatter[T1, T2 any] struct {
	Writer     io.Writer         // Writer to write the output to
	Data       T1                // Data to be formatted
	RowHeaders []string          // Headers for table rows
	Array      func(T1) []T2     // Function to convert Data into an array of T2
	Row        func(T2) []string // Function to convert each T2 into a row of strings
}

OutputFormatter is a generic struct that takes two types T1 and T2. It is used for formatting output data either as JSON or as a table.

func (OutputFormatter[T1, T2]) WriteJson

func (f OutputFormatter[T1, T2]) WriteJson() error

WriteJson formats the Data as JSON and writes it to the Writer.

func (OutputFormatter[T1, T2]) WriteJsonOrTable

func (f OutputFormatter[T1, T2]) WriteJsonOrTable(isJson bool) error

WriteJsonOrTable decides whether to write Data as JSON or as a table based on the isJson flag.

func (OutputFormatter[T1, T2]) WriteTable

func (f OutputFormatter[T1, T2]) WriteTable() error

WriteTable formats the Data as a table and writes it to the Writer.

type Release

type Release struct {
	TagName string `json:"tag_name"`
}

type UpdateInfo

type UpdateInfo struct {
	UpdateRequired       bool
	CurrentVersion       string
	LatestReleaseVersion string
}

Jump to

Keyboard shortcuts

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