utils

package
v0.6.169 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorEnabled bool

Functions

func CleanupWorkDir

func CleanupWorkDir(fs afero.Fs, path string)

CleanupWorkDir removes all files in a directory Eat any errors so we can call it from defer

func CreateWorkDir

func CreateWorkDir(fs afero.Fs) (string, error)

CreateWorkDir creates the working directory in tmp and some subdirectories

func Experimental

func Experimental() bool

detect if the EC_EXPERIMENTAL env var is set to enable experimental features

func FS

func FS(ctx context.Context) afero.Fs

func HasJsonOrYamlExt

func HasJsonOrYamlExt(str string) bool

func HasSuffix

func HasSuffix(str string, extensions []string) bool

func IsFile

func IsFile(ctx context.Context, path string) (bool, error)

func IsJson

func IsJson(data string) bool

detect if the string is json

func IsOpaEnabled added in v0.6.165

func IsOpaEnabled() bool

func IsYamlMap

func IsYamlMap(data string) bool

detect if the string is yamlMap

func RenderFromTemplatesWithGlob added in v0.4.54

func RenderFromTemplatesWithGlob(input any, main string, glob []string, efs embed.FS) ([]byte, error)

func RenderFromTemplatesWithMain added in v0.4.54

func RenderFromTemplatesWithMain(input any, main string, efs embed.FS) ([]byte, error)

func SetColorEnabled added in v0.4.54

func SetColorEnabled(flagNoColor, flagForceColor bool)

func SetupTemplate added in v0.4.55

func SetupTemplate(efs embed.FS) (*template.Template, error)

Here we assume the caller will do the Execute or ExecuteTemplate themselves

func SetupTemplateWithGlob added in v0.4.55

func SetupTemplateWithGlob(glob []string, efs embed.FS) (*template.Template, error)

func WithFS

func WithFS(ctx context.Context, fs afero.Fs) context.Context

func WriteTempFile

func WriteTempFile(ctx context.Context, data, prefix string) (string, error)

create a file in a temp dir with contents of data

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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