utils

package
v0.0.0-...-6477f42 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils bring global functions

Index

Constants

This section is empty.

Variables

View Source
var LogFatal = log.Fatal

LogFatal is the log.Fatal go built-in function by default. Permit to change the behaviour of that variable in order to test the EnsureOrFatal function

View Source
var LogFatalf = log.Fatalf

LogFatalf is the log.Fatalf go built-in function by default. Permit to change the behaviour of that variable in order to test EnsureProgramInstalled function

Functions

func Contains

func Contains(list []string, string string) bool

Contains check if a list contains a given string

func EnsureOrFatal

func EnsureOrFatal(err error)

EnsureOrFatal ensures the error in nil or uses LogFatal

func EnsureProgramInstalled

func EnsureProgramInstalled(programName string) bool

EnsureProgramInstalled check if the given program is installed in the system. For example, check if terraform is installed. If not, will crash the program.

func FileExists

func FileExists(path string) bool

FileExists return true is the given file exists, else false

func NoDiagsOrFatal

func NoDiagsOrFatal(diags hcl.Diagnostics)

NoDiagsOrFatal ensure that the diag slice is empty or uses LogFatal

func OkOrFatal

func OkOrFatal(ok bool, message string)

OkOrFatal ensures the answer was ok or fatal

func RunSystemCommand

func RunSystemCommand(name string, arg ...string) (string, string, bool)

RunSystemCommand permit to run a system command. It returns the stdout, the stderr and a boolean that define if the command succeeded ... or not

Types

This section is empty.

Jump to

Keyboard shortcuts

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