util

package
v2.38.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package util contains utility functions used by various commands.

Index

Constants

View Source
const (
	ActionsCodegenOrg     string = "hasura/codegen-assets"
	ActionsCodegenRepoURI string = "https://github.com/hasura/codegen-assets.git"
	ActionsCodegenDirName string = "actions-codegen-assets"
)

Default Codegen Assets constants

View Source
const (
	LEVEL_0 = iota
	LEVEL_1
	LEVEL_2
	LEVEL_3
)
View Source
const ViperEnvPrefix = "HASURA_GRAPHQL"

ViperEnvPrefix - Env prefix to be used in viper

Variables

View Source
var ViperEnvReplacer = strings.NewReplacer(".", "_")

ViperEnvReplacer - Env replacer to be used in viper

Functions

func BindPFlag

func BindPFlag(v *viper.Viper, key string, f *pflag.Flag)

BindPFlag - binds flag with viper along with env usage

func CopyDir

func CopyDir(src string, dst string) error

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyDirAfero

func CopyDirAfero(afs afero.Fs, src string, dst string) error

CopyDir but with afero

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func CopyFileAfero

func CopyFileAfero(fs afero.Fs, src, dst string) error

CopyFile but with Afero

func FSCheckIfDirPathExists

func FSCheckIfDirPathExists(path string) error

func FSCopyDir

func FSCopyDir(src string, dst string) error

func FSCopyFile

func FSCopyFile(src, dst string) error

func GetFSPathPrompt

func GetFSPathPrompt(message string, def string) (input string, err error)

func GetInputPrompt

func GetInputPrompt(message string) (input string, err error)

func GetInputPromptWithDefault

func GetInputPromptWithDefault(message string, def string) (input string, err error)

func GetSelectPrompt

func GetSelectPrompt(message string, options []string) (selection string, err error)

func GetServerStatus

func GetServerStatus(versionEndpoint string, httpClient *httpc.Client) (err error)

func GetYesNoPrompt

func GetYesNoPrompt(message string) (promptResp bool, err error)

func NewTableWriter

func NewTableWriter(w io.Writer) *tablewriter.Table

func Unzip

func Unzip(archive, target string) error

Unzip unzips the archive to target. Both archive and target should be paths in the filesystem. target is created if it doesn't exist already.

Types

type GitUtil

type GitUtil struct {
	URI  string
	Path string

	// Optional
	ReferenceName        plumbing.ReferenceName
	DisableCloneOrUpdate bool
	Logger               *logrus.Logger
}

func NewGitUtil

func NewGitUtil(uri string, path string, refName string) *GitUtil

func (*GitUtil) EnsureCloned

func (g *GitUtil) EnsureCloned() error

func (*GitUtil) EnsureUpdated

func (g *GitUtil) EnsureUpdated() error

EnsureUpdated will ensure the destination path exists and is up to date.

func (*GitUtil) IsGitCloned

func (g *GitUtil) IsGitCloned() (bool, error)

type PrefixWriter

type PrefixWriter interface {
	// Write writes text with the specified indentation level.
	Write(level int, format string, a ...interface{})
	// WriteLine writes an entire line with no indentation level.
	WriteLine(a ...interface{})
	// Flush forces indendation to be reset.
	Flush()
}

PrefixWriter can write text at various indentation levels.

func NewPrefixWriter

func NewPrefixWriter(out io.Writer) PrefixWriter

NewPrefixWriter creates a new PrefixWriter.

type ServerState

type ServerState struct {
	UUID     string
	CLIState map[string]interface{}
}

ServerState is the state of Hasura stored on the server.

func GetServerState

func GetServerState(client *httpc.Client, endpoint string, hasMetadataV3 bool, log *logrus.Logger) *ServerState

GetServerState queries a server for the state.

type VersionFlag

type VersionFlag struct {
	Version *semver.Version
}

func NewVersionFlagValue

func NewVersionFlagValue(p *VersionFlag) *VersionFlag

NewVersionFlagValue returns ConfigVersion set with default value

func (*VersionFlag) Set

func (c *VersionFlag) Set(s string) error

Set sets the value of the named command-line flag.

func (*VersionFlag) String

func (c *VersionFlag) String() string

func (*VersionFlag) Type

func (c *VersionFlag) Type() string

Type returns a string that uniquely represents this flag's type.

Jump to

Keyboard shortcuts

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