syslutil

package
v0.632.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Method_GET    = sysl.Endpoint_RestParams_GET.String()
	Method_PUT    = sysl.Endpoint_RestParams_PUT.String()
	Method_POST   = sysl.Endpoint_RestParams_POST.String()
	Method_DELETE = sysl.Endpoint_RestParams_DELETE.String()
	Method_PATCH  = sysl.Endpoint_RestParams_PATCH.String()
)

nolint:revive,stylecheck

BuiltInTypes are the builtin types of Sysl. There's no primitive int32 (and int64) type. The parser interprets the Sysl syntax int32 value as an int primitive with a bit width (sysl.Type_Constraint.BitWidth) of 32.

View Source
var LogLevels = map[string]logrus.Level{
	"":      logrus.ErrorLevel,
	"off":   logrus.ErrorLevel,
	"debug": logrus.DebugLevel,
	"info":  logrus.InfoLevel,
	"warn":  logrus.WarnLevel,
	"trace": logrus.TraceLevel,
}

LogLevels ... nolint:gochecknoglobals

Functions

func Assert

func Assert(ok bool, format string, args ...interface{})

func AssertFsHasExactly

func AssertFsHasExactly(t *testing.T, fs afero.Fs, paths ...string) bool

AssertFsHasExactly asserts that fs contains the given files and only those. All paths must start with '/'.

func BuildFolderTest

func BuildFolderTest(t *testing.T, fs afero.Fs, folders, files []string)

func CleanAppName added in v0.217.0

func CleanAppName(name string) string

func GetApp

func GetApp(appName *sysl.AppName, mod *sysl.Module) *sysl.Application

func GetAppName

func GetAppName(appname *sysl.AppName) string

func GetRemoteRepoRoot added in v0.568.0

func GetRemoteRepoRoot(path string) string

func GetTypeDetail

func GetTypeDetail(t *sysl.Type) (typeName string, typeDetail string)

GetTypeDetail returns name of the type and details in string format

func GetTypePrimitiveName added in v0.344.0

func GetTypePrimitiveName(t sysl.Type_Primitive) string

nolint:interfacer

func HandleCRLF

func HandleCRLF(text []byte) []byte

func HasPattern

func HasPattern(attrs map[string]*sysl.Attribute, pattern string) bool

func HasSameType

func HasSameType(type1 *sysl.Type, type2 *sysl.Type) bool

HasSameType returns true if type 2 matches with type 1

func IsBuiltIn added in v0.344.0

func IsBuiltIn(name string) bool

func IsRemoteImport added in v0.431.0

func IsRemoteImport(path string) bool

func IsSameApp

func IsSameApp(a *sysl.AppName, b *sysl.AppName) bool

func IsSameCall

func IsSameCall(a *sysl.Call, b *sysl.Call) bool

func JoinAppName added in v0.223.0

func JoinAppName(name *sysl.AppName) string

JoinAppName returns a string with the parts of an app name joined on the namespace separator.

func JoinAppNameParts added in v0.255.0

func JoinAppNameParts(parts ...string) string

JoinAppNameParts returns a string with the parts of an app name joined on the namespace separator.

func JoinTypePath added in v0.223.0

func JoinTypePath(path []string) string

JoinTypePath returns a string with the parts of a type reference path joined on ".".

func JoinTypeRef added in v0.258.0

func JoinTypeRef(ref *sysl.ScopedRef) string

JoinTypeRef returns a string encoding the reference to a type.

If the app name is present it will be joined on " :: " and prefixed to the path, joined by ".".

func JoinTypeRefScope added in v0.258.0

func JoinTypeRefScope(ref *sysl.Scope) string

JoinTypeRefScope returns a string encoding the reference to a type.

If the app name is present it will be joined on " :: " and prefixed to the path, joined by ".".

func MustAbsolute

func MustAbsolute(t *testing.T, path string) string

func MustRelative

func MustRelative(t *testing.T, base, target string) string

func NewMockChrootFs

func NewMockChrootFs(root string) (*MockFs, *ChrootFs)

NewMockFs creates a wrapper fs to record function calls with the mock library, it requires a memory map fs

func PanicOnError

func PanicOnError(err error)

func PanicOnErrorf

func PanicOnErrorf(err error, format string, args ...interface{})

func PopulateCMDFlagsFromFile added in v0.8.0

func PopulateCMDFlagsFromFile(cmdArgs []string) ([]string, error)

func ReadCMDFlags added in v0.8.0

func ReadCMDFlags(configPath string) ([]string, error)

func SetLogLevel added in v0.355.0

func SetLogLevel(level string)

func SplitAppNameParts added in v0.255.0

func SplitAppNameParts(appName string) []string

SplitAppNameParts returns the parts of an app name that was previously joined into a string.

func TypeBool

func TypeBool() *sysl.Type

TypeBool returns boolean type

func TypeDecimal

func TypeDecimal() *sysl.Type

TypeDecimal returns decimal type

func TypeEmpty

func TypeEmpty() *sysl.Type

TypeEmpty returns empty primitive type

func TypeFloat

func TypeFloat() *sysl.Type

TypeFloat returns float type

func TypeInt

func TypeInt() *sysl.Type

TypeInt returns integer type

func TypeNone

func TypeNone() *sysl.Type

TypeNone returns none-type

func TypeString

func TypeString() *sysl.Type

TypeString returns string type

func WriteToMemOverlayFs

func WriteToMemOverlayFs(osRoot string) (memFs, fs afero.Fs)

Types

type ChrootFs

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

func NewChrootFs

func NewChrootFs(fs afero.Fs, root string) *ChrootFs

NewChrootFs returns a filesystem that is rooted at root argument

func (*ChrootFs) Chmod

func (fs *ChrootFs) Chmod(name string, mode os.FileMode) error

func (*ChrootFs) Chown added in v0.459.0

func (fs *ChrootFs) Chown(name string, uid, gid int) error

func (*ChrootFs) Chtimes

func (fs *ChrootFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*ChrootFs) Create

func (fs *ChrootFs) Create(name string) (afero.File, error)

func (*ChrootFs) Mkdir

func (fs *ChrootFs) Mkdir(name string, perm os.FileMode) error

func (*ChrootFs) MkdirAll

func (fs *ChrootFs) MkdirAll(path string, perm os.FileMode) error

func (*ChrootFs) Name

func (fs *ChrootFs) Name() string

func (*ChrootFs) Open

func (fs *ChrootFs) Open(name string) (afero.File, error)

func (*ChrootFs) OpenFile

func (fs *ChrootFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*ChrootFs) Remove

func (fs *ChrootFs) Remove(name string) error

func (*ChrootFs) RemoveAll

func (fs *ChrootFs) RemoveAll(path string) error

func (*ChrootFs) Rename

func (fs *ChrootFs) Rename(oldname, newname string) error

func (*ChrootFs) Root added in v0.431.0

func (fs *ChrootFs) Root() string

func (*ChrootFs) Stat

func (fs *ChrootFs) Stat(name string) (os.FileInfo, error)

type Exit added in v0.431.0

type Exit struct {
	Code int
	// contains filtered or unexported fields
}

func Exitf added in v0.431.0

func Exitf(code int, format string, args ...interface{}) Exit

func (Exit) Error added in v0.431.0

func (e Exit) Error() string

type MockFs

type MockFs struct {
	mock.Mock
}

func (*MockFs) Chmod

func (m *MockFs) Chmod(name string, mode os.FileMode) error

func (*MockFs) Chown added in v0.459.0

func (m *MockFs) Chown(name string, uid, gid int) error

func (*MockFs) Chtimes

func (m *MockFs) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*MockFs) Create

func (m *MockFs) Create(name string) (afero.File, error)

func (*MockFs) Mkdir

func (m *MockFs) Mkdir(name string, perm os.FileMode) error

func (*MockFs) MkdirAll

func (m *MockFs) MkdirAll(name string, perm os.FileMode) error

func (*MockFs) Name

func (m *MockFs) Name() string

func (*MockFs) Open

func (m *MockFs) Open(name string) (afero.File, error)

func (*MockFs) OpenFile

func (m *MockFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*MockFs) Remove

func (m *MockFs) Remove(name string) error

func (*MockFs) RemoveAll

func (m *MockFs) RemoveAll(path string) error

func (*MockFs) Rename

func (m *MockFs) Rename(oldname, newname string) error

func (*MockFs) Stat

func (m *MockFs) Stat(name string) (os.FileInfo, error)

type StrSet

type StrSet map[string]struct{}

func MakeStrSet

func MakeStrSet(initial ...string) StrSet

func MakeStrSetFromActionStatement

func MakeStrSetFromActionStatement(stmts []*sysl.Statement) StrSet

func MakeStrSetFromAttr

func MakeStrSetFromAttr(attr string, attrs map[string]*sysl.Attribute) StrSet

func (StrSet) Clone

func (s StrSet) Clone() StrSet

func (StrSet) Contains

func (s StrSet) Contains(elem string) bool

func (StrSet) Difference

func (s StrSet) Difference(other StrSet) StrSet

Returns the elements that only belong to s. If s is subset of other, it would return an empty set. Just be aware that output may be one of the inputs and when change the output, the input would also be changed.

func (StrSet) Insert

func (s StrSet) Insert(elem string)

func (StrSet) Intersection

func (s StrSet) Intersection(other StrSet) StrSet

func (StrSet) IsSubset

func (s StrSet) IsSubset(parent StrSet) bool

Returns true if child set is a subset of parent set

func (StrSet) Remove

func (s StrSet) Remove(elem string)

func (StrSet) ToSlice

func (s StrSet) ToSlice() []string

func (StrSet) ToSortedSlice

func (s StrSet) ToSortedSlice() []string

func (StrSet) Union

func (s StrSet) Union(other StrSet) StrSet

Jump to

Keyboard shortcuts

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