2023-12-06 15:24:02 +01:00
|
|
|
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
|
|
|
|
|
|
|
|
|
|
# utils
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2025-08-20 12:16:14 +02:00
|
|
|
import "katenary.io/internal/utils"
|
2023-12-06 15:24:02 +01:00
|
|
|
```
|
|
|
|
|
|
2025-07-04 14:59:49 +02:00
|
|
|
Package utils provides some utility functions used in katenary. It defines some constants and functions used in the whole project.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2025-07-06 15:36:43 +02:00
|
|
|
## Constants
|
|
|
|
|
|
|
|
|
|
<a name="DirectoryPermission"></a>DirectoryPermission is the default values for permissions apply to created directories.
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
const DirectoryPermission = 0o755
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
<a name="AsResourceName"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func AsResourceName
|
2024-11-22 15:12:44 +01:00
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
func AsResourceName(name string) string
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
AsResourceName returns a resource name with underscores to respect the kubernetes naming convention. It's the opposite of FixedResourceName.
|
|
|
|
|
|
|
|
|
|
<a name="Confirm"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func Confirm
|
2024-05-06 21:11:36 +02:00
|
|
|
|
|
|
|
|
```go
|
2025-09-15 13:36:22 +02:00
|
|
|
func Confirm(question string, icon ...logger.Icon) bool
|
2024-05-06 21:11:36 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Confirm asks a question and returns true if the answer is y.
|
|
|
|
|
|
|
|
|
|
<a name="CountStartingSpaces"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func CountStartingSpaces
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func CountStartingSpaces(line string) int
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
CountStartingSpaces counts the number of spaces at the beginning of a string.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-05-06 21:11:36 +02:00
|
|
|
<a name="EncodeBasicYaml"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func EncodeBasicYaml
|
2024-05-06 21:11:36 +02:00
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
func EncodeBasicYaml(data any) ([]byte, error)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
EncodeBasicYaml encodes a basic yaml from an interface.
|
|
|
|
|
|
2024-11-08 13:13:27 +01:00
|
|
|
<a name="FixedResourceName"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func FixedResourceName
|
2024-11-08 13:13:27 +01:00
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
func FixedResourceName(name string) string
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="GetContainerByName"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func GetContainerByName
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="GetKind"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func GetKind
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetKind(path string) (kind string)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
GetKind returns the kind of the resource from the file path.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="GetServiceNameByPort"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func GetServiceNameByPort
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetServiceNameByPort(port int) string
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
GetServiceNameByPort returns the service name for a port. It the service name is not found, it returns an empty string.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="GetValuesFromLabel"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func GetValuesFromLabel
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
GetValuesFromLabel returns a map of values from a label.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="HashComposefiles"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func HashComposefiles
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func HashComposefiles(files []string) (string, error)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
HashComposefiles returns a hash of the compose files.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="Int32Ptr"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func Int32Ptr
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func Int32Ptr(i int32) *int32
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Int32Ptr returns a pointer to an int32.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="PathToName"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func PathToName
|
2024-04-10 04:51:45 +02:00
|
|
|
|
|
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func PathToName(path string) string
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
PathToName converts a path to a kubernetes complient name.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="StrPtr"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func StrPtr
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func StrPtr(s string) *string
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
StrPtr returns a pointer to a string.
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="TplName"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func TplName
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func TplName(serviceName, appname string, suffix ...string) string
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
TplName returns the name of the kubernetes resource as a template string. It is used in the templates and defined in \_helper.tpl file.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="TplValue"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func TplValue
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func TplValue(serviceName, variable string, pipes ...string) string
|
|
|
|
|
```
|
|
|
|
|
|
2025-07-11 09:16:43 +02:00
|
|
|
TplValue returns a string that can be used in a template to access a value from the values file.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="WordWrap"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func WordWrap
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func WordWrap(text string, lineWidth int) string
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
WordWrap wraps a string to a given line width. Warning: it may break the string. You need to check the result.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="Wrap"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## func Wrap
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
func Wrap(src, above, below string) string
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
Wrap wraps a string with a string above and below. It will respect the indentation of the src string.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
<a name="EnvConfig"></a>
|
2026-05-03 21:21:38 +02:00
|
|
|
## type EnvConfig
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
EnvConfig is a struct to hold the description of an environment variable.
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
```go
|
2023-12-06 15:24:02 +01:00
|
|
|
type EnvConfig struct {
|
|
|
|
|
Service types.ServiceConfig
|
2024-05-06 21:11:36 +02:00
|
|
|
Description string
|
2023-12-06 15:24:02 +01:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-10 04:51:45 +02:00
|
|
|
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
|