188 lines
3.5 KiB
Markdown
188 lines
3.5 KiB
Markdown
|
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
||
|
|
||
|
# utils
|
||
|
|
||
|
``` go
|
||
|
import "katenary/utils"
|
||
|
```
|
||
|
|
||
|
Utils package provides some utility functions used in katenary. It
|
||
|
defines some constants and functions used in the whole project.
|
||
|
|
||
|
## Constants
|
||
|
|
||
|
Icons used in katenary.
|
||
|
|
||
|
``` go
|
||
|
const (
|
||
|
IconSuccess Icon = "✅"
|
||
|
IconFailure = "❌"
|
||
|
IconWarning = "⚠️'"
|
||
|
IconNote = "📝"
|
||
|
IconWorld = "🌐"
|
||
|
IconPlug = "🔌"
|
||
|
IconPackage = "📦"
|
||
|
IconCabinet = "🗄️"
|
||
|
IconInfo = "❕"
|
||
|
IconSecret = "🔒"
|
||
|
IconConfig = "🔧"
|
||
|
IconDependency = "🔗"
|
||
|
)
|
||
|
```
|
||
|
|
||
|
## func CountStartingSpaces
|
||
|
|
||
|
``` go
|
||
|
func CountStartingSpaces(line string) int
|
||
|
```
|
||
|
|
||
|
CountStartingSpaces counts the number of spaces at the beginning of a
|
||
|
string.
|
||
|
|
||
|
## func GetContainerByName
|
||
|
|
||
|
``` go
|
||
|
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
|
||
|
```
|
||
|
|
||
|
GetContainerByName returns a container by name and its index in the
|
||
|
array. It returns nil, -1 if not found.
|
||
|
|
||
|
## func GetKind
|
||
|
|
||
|
``` go
|
||
|
func GetKind(path string) (kind string)
|
||
|
```
|
||
|
|
||
|
GetKind returns the kind of the resource from the file path.
|
||
|
|
||
|
## func GetServiceNameByPort
|
||
|
|
||
|
``` go
|
||
|
func GetServiceNameByPort(port int) string
|
||
|
```
|
||
|
|
||
|
GetServiceNameByPort returns the service name for a port. It the service
|
||
|
name is not found, it returns an empty string.
|
||
|
|
||
|
## func GetValuesFromLabel
|
||
|
|
||
|
``` go
|
||
|
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
|
||
|
```
|
||
|
|
||
|
GetValuesFromLabel returns a map of values from a label.
|
||
|
|
||
|
## func HashComposefiles
|
||
|
|
||
|
``` go
|
||
|
func HashComposefiles(files []string) (string, error)
|
||
|
```
|
||
|
|
||
|
HashComposefiles returns a hash of the compose files.
|
||
|
|
||
|
## func Int32Ptr
|
||
|
|
||
|
``` go
|
||
|
func Int32Ptr(i int32) *int32
|
||
|
```
|
||
|
|
||
|
Int32Ptr returns a pointer to an int32.
|
||
|
|
||
|
## func MapKeys
|
||
|
|
||
|
``` go
|
||
|
func MapKeys(m map[string]interface{}) []string
|
||
|
```
|
||
|
|
||
|
## func PathToName
|
||
|
|
||
|
``` go
|
||
|
func PathToName(path string) string
|
||
|
```
|
||
|
|
||
|
PathToName converts a path to a kubernetes complient name.
|
||
|
|
||
|
## func StrPtr
|
||
|
|
||
|
``` go
|
||
|
func StrPtr(s string) *string
|
||
|
```
|
||
|
|
||
|
StrPtr returns a pointer to a string.
|
||
|
|
||
|
## func TplName
|
||
|
|
||
|
``` go
|
||
|
func TplName(serviceName, appname string, suffix ...string) string
|
||
|
```
|
||
|
|
||
|
TplName returns the name of the kubernetes resource as a template
|
||
|
string. It is used in the templates and defined in \_helper.tpl file.
|
||
|
|
||
|
## func TplValue
|
||
|
|
||
|
``` go
|
||
|
func TplValue(serviceName, variable string, pipes ...string) string
|
||
|
```
|
||
|
|
||
|
GetContainerByName returns a container by name and its index in the
|
||
|
array.
|
||
|
|
||
|
## func Warn
|
||
|
|
||
|
``` go
|
||
|
func Warn(msg ...interface{})
|
||
|
```
|
||
|
|
||
|
Warn prints a warning message
|
||
|
|
||
|
## func WordWrap
|
||
|
|
||
|
``` go
|
||
|
func WordWrap(text string, lineWidth int) string
|
||
|
```
|
||
|
|
||
|
WordWrap wraps a string to a given line width. Warning: it may break the
|
||
|
string. You need to check the result.
|
||
|
|
||
|
## func Wrap
|
||
|
|
||
|
``` go
|
||
|
func Wrap(src, above, below string) string
|
||
|
```
|
||
|
|
||
|
Wrap wraps a string with a string above and below. It will respect the
|
||
|
indentation of the src string.
|
||
|
|
||
|
## func WrapBytes
|
||
|
|
||
|
``` go
|
||
|
func WrapBytes(src, above, below []byte) []byte
|
||
|
```
|
||
|
|
||
|
WrapBytes wraps a byte array with a byte array above and below. It will
|
||
|
respect the indentation of the src string.
|
||
|
|
||
|
## type EnvConfig
|
||
|
|
||
|
EnvConfig is a struct to hold the description of an environment
|
||
|
variable.
|
||
|
|
||
|
``` go
|
||
|
type EnvConfig struct {
|
||
|
Description string
|
||
|
Service types.ServiceConfig
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## type Icon
|
||
|
|
||
|
Icon is a unicode icon
|
||
|
|
||
|
``` go
|
||
|
type Icon string
|
||
|
```
|
||
|
|
||
|
Generated by [gomarkdoc](https://github.com/princjef/gomarkdoc)
|