Compare commits
17 Commits
3e80221641
...
feature/be
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ee6b74b10 | |||
| b40378ec23 | |||
| 0b1a45319f | |||
| e879c3f10f | |||
| 985418ae51 | |||
| 0e133ae6db | |||
| 5d839035b9 | |||
| 7e1bbdc9b3 | |||
| f175416ac2 | |||
| 613baaf229 | |||
| 8fc9cb31c4 | |||
| 78b5af747e | |||
| 269717eb1c | |||
| 61896baad8 | |||
| feff997aba | |||
| 89e331069e | |||
| 88ce6d4579 |
@@ -6,13 +6,13 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"katenary.io/internal/generator"
|
||||
"katenary.io/internal/generator/katenaryfile"
|
||||
"katenary.io/internal/generator/labels"
|
||||
"katenary.io/internal/logger"
|
||||
"katenary.io/internal/utils"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/cli"
|
||||
@@ -28,7 +28,7 @@ func main() {
|
||||
rootCmd := buildRootCmd()
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ Katenary will try to _Unmarshal_ these labels.
|
||||
| `katenary.v3/configmap-files` | Inject files as Configmap. | `[]string` |
|
||||
| `katenary.v3/cronjob` | Create a cronjob from the service. | `object` |
|
||||
| `katenary.v3/dependencies` | Add Helm dependencies to the service. | `[]object` |
|
||||
| `katenary.v3/depends-on` | Method to check if a service is ready (for depends_on). | `string` |
|
||||
| `katenary.v3/description` | Description of the service | `string` |
|
||||
| `katenary.v3/env-from` | Add environment variables from another service. | `[]string` |
|
||||
| `katenary.v3/exchange-volumes` | Add exchange volumes (empty directory on the node) to share data | `[]object` |
|
||||
@@ -144,6 +145,45 @@ labels:
|
||||
```
|
||||
|
||||
|
||||
### katenary.v3/depends-on
|
||||
|
||||
Method to check if a service is ready (for depends_on).
|
||||
|
||||
**Type**: `string`
|
||||
|
||||
When a service uses `depends_on`, Katenary creates an initContainer to wait
|
||||
for the dependent service to be ready.
|
||||
|
||||
By default, Katenary uses the Kubernetes API to check if the service endpoint
|
||||
has ready addresses. This method does not require the service to expose a port
|
||||
and does not create a Kubernetes Service automatically.
|
||||
|
||||
If you need to create a Kubernetes Service for external access, use the
|
||||
`katenary.v3/ports` label instead.
|
||||
|
||||
Set this label to `legacy` to use the old netcat method that requires a port
|
||||
to be defined for the dependent service.
|
||||
|
||||
**Example:**
|
||||
|
||||
```yaml
|
||||
web:
|
||||
image: nginx
|
||||
depends_on:
|
||||
- database
|
||||
labels:
|
||||
# Use legacy netcat method (requires port)
|
||||
katenary.v3/depends-on: legacy
|
||||
|
||||
database:
|
||||
image: mysql
|
||||
labels:
|
||||
# Create a Kubernetes Service for external access
|
||||
katenary.v3/ports:
|
||||
- 3306
|
||||
```
|
||||
|
||||
|
||||
### katenary.v3/description
|
||||
|
||||
Description of the service
|
||||
@@ -352,7 +392,12 @@ Ports to be added to the service.
|
||||
**Type**: `[]uint32`
|
||||
|
||||
Only useful for services without exposed port. It is mandatory if the
|
||||
service is a dependency of another service.
|
||||
service is a dependency of another service AND you want to create a
|
||||
Kubernetes Service for external access.
|
||||
|
||||
If you only need to check if the service is ready (using depends_on),
|
||||
you don't need to declare ports. The service will not be created automatically
|
||||
unless you add this label.
|
||||
|
||||
**Example:**
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ var Version = "master" // changed at compile time
|
||||
```
|
||||
|
||||
<a name="Convert"></a>
|
||||
## func [Convert](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/converter.go#L101>)
|
||||
## func [Convert](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/converter.go#L100>)
|
||||
|
||||
```go
|
||||
func Convert(config ConvertOptions, dockerComposeFile ...string) error
|
||||
@@ -44,7 +44,7 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error
|
||||
Convert a compose \(docker, podman...\) project to a helm chart. It calls Generate\(\) to generate the chart and then write it to the disk.
|
||||
|
||||
<a name="GetLabels"></a>
|
||||
## func [GetLabels](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels.go#L13>)
|
||||
## func [GetLabels](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels.go#L13>)
|
||||
|
||||
```go
|
||||
func GetLabels(serviceName, appName string) map[string]string
|
||||
@@ -53,7 +53,7 @@ func GetLabels(serviceName, appName string) map[string]string
|
||||
GetLabels returns the labels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the labels in the templates.
|
||||
|
||||
<a name="GetMatchLabels"></a>
|
||||
## func [GetMatchLabels](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels.go#L26>)
|
||||
## func [GetMatchLabels](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels.go#L26>)
|
||||
|
||||
```go
|
||||
func GetMatchLabels(serviceName, appName string) map[string]string
|
||||
@@ -62,7 +62,7 @@ func GetMatchLabels(serviceName, appName string) map[string]string
|
||||
GetMatchLabels returns the matchLabels for a service. It uses the appName to replace the \_\_replace\_\_ in the labels. This is used to generate the matchLabels in the templates.
|
||||
|
||||
<a name="GetVersion"></a>
|
||||
## func [GetVersion](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/version.go#L15>)
|
||||
## func [GetVersion](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/version.go#L15>)
|
||||
|
||||
```go
|
||||
func GetVersion() string
|
||||
@@ -71,7 +71,7 @@ func GetVersion() string
|
||||
GetVersion return the version of katneary. It's important to understand that the version is set at compile time for the github release. But, it the user get katneary using \`go install\`, the version should be different.
|
||||
|
||||
<a name="Helper"></a>
|
||||
## func [Helper](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/helper.go#L16>)
|
||||
## func [Helper](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/helper.go#L16>)
|
||||
|
||||
```go
|
||||
func Helper(name string) string
|
||||
@@ -80,7 +80,7 @@ func Helper(name string) string
|
||||
Helper returns the \_helpers.tpl file for a chart.
|
||||
|
||||
<a name="NewCronJob"></a>
|
||||
## func [NewCronJob](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/cronJob.go#L29>)
|
||||
## func [NewCronJob](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/cronJob.go#L29>)
|
||||
|
||||
```go
|
||||
func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (*CronJob, *RBAC)
|
||||
@@ -89,7 +89,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
NewCronJob creates a new CronJob from a compose service. The appName is the name of the application taken from the project name.
|
||||
|
||||
<a name="ToK8SYaml"></a>
|
||||
## func [ToK8SYaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/utils.go#L91>)
|
||||
## func [ToK8SYaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/utils.go#L91>)
|
||||
|
||||
```go
|
||||
func ToK8SYaml(obj any) ([]byte, error)
|
||||
@@ -98,7 +98,7 @@ func ToK8SYaml(obj any) ([]byte, error)
|
||||
|
||||
|
||||
<a name="UnWrapTPL"></a>
|
||||
## func [UnWrapTPL](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/utils.go#L87>)
|
||||
## func [UnWrapTPL](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/utils.go#L87>)
|
||||
|
||||
```go
|
||||
func UnWrapTPL(in []byte) []byte
|
||||
@@ -107,7 +107,7 @@ func UnWrapTPL(in []byte) []byte
|
||||
UnWrapTPL removes the line wrapping from a template.
|
||||
|
||||
<a name="ChartTemplate"></a>
|
||||
## type [ChartTemplate](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L23-L26>)
|
||||
## type [ChartTemplate](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/chart.go#L22-L25>)
|
||||
|
||||
ChartTemplate is a template of a chart. It contains the content of the template and the name of the service. This is used internally to generate the templates.
|
||||
|
||||
@@ -119,7 +119,7 @@ type ChartTemplate struct {
|
||||
```
|
||||
|
||||
<a name="ConfigMap"></a>
|
||||
## type [ConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L39-L44>)
|
||||
## type [ConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L38-L43>)
|
||||
|
||||
ConfigMap is a kubernetes ConfigMap. Implements the DataMap interface.
|
||||
|
||||
@@ -131,7 +131,7 @@ type ConfigMap struct {
|
||||
```
|
||||
|
||||
<a name="NewConfigMap"></a>
|
||||
### func [NewConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L48>)
|
||||
### func [NewConfigMap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L47>)
|
||||
|
||||
```go
|
||||
func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *ConfigMap
|
||||
@@ -140,7 +140,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
|
||||
NewConfigMap creates a new ConfigMap from a compose service. The appName is the name of the application taken from the project name. The ConfigMap is filled by environment variables and labels "map\-env".
|
||||
|
||||
<a name="NewConfigMapFromDirectory"></a>
|
||||
### func [NewConfigMapFromDirectory](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L121>)
|
||||
### func [NewConfigMapFromDirectory](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L120>)
|
||||
|
||||
```go
|
||||
func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string) *ConfigMap
|
||||
@@ -149,7 +149,7 @@ func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string
|
||||
NewConfigMapFromDirectory creates a new ConfigMap from a compose service. This path is the path to the file or directory. If the path is a directory, all files in the directory are added to the ConfigMap. Each subdirectory are ignored. Note that the Generate\(\) function will create the subdirectories ConfigMaps.
|
||||
|
||||
<a name="ConfigMap.AddBinaryData"></a>
|
||||
### func \(\*ConfigMap\) [AddBinaryData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L159>)
|
||||
### func \(\*ConfigMap\) [AddBinaryData](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L158>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) AddBinaryData(key string, value []byte)
|
||||
@@ -158,7 +158,7 @@ func (c *ConfigMap) AddBinaryData(key string, value []byte)
|
||||
AddBinaryData adds binary data to the configmap. Append or overwrite the value if the key already exists.
|
||||
|
||||
<a name="ConfigMap.AddData"></a>
|
||||
### func \(\*ConfigMap\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L154>)
|
||||
### func \(\*ConfigMap\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L153>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) AddData(key, value string)
|
||||
@@ -167,7 +167,7 @@ func (c *ConfigMap) AddData(key, value string)
|
||||
AddData adds a key value pair to the configmap. Append or overwrite the value if the key already exists.
|
||||
|
||||
<a name="ConfigMap.AppendDir"></a>
|
||||
### func \(\*ConfigMap\) [AppendDir](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L168>)
|
||||
### func \(\*ConfigMap\) [AppendDir](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L167>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) AppendDir(path string) error
|
||||
@@ -176,7 +176,7 @@ func (c *ConfigMap) AppendDir(path string) error
|
||||
AppendDir adds files from given path to the configmap. It is not recursive, to add all files in a directory, you need to call this function for each subdirectory.
|
||||
|
||||
<a name="ConfigMap.AppendFile"></a>
|
||||
### func \(\*ConfigMap\) [AppendFile](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L215>)
|
||||
### func \(\*ConfigMap\) [AppendFile](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L214>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) AppendFile(path string) error
|
||||
@@ -185,7 +185,7 @@ func (c *ConfigMap) AppendFile(path string) error
|
||||
|
||||
|
||||
<a name="ConfigMap.Filename"></a>
|
||||
### func \(\*ConfigMap\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L239>)
|
||||
### func \(\*ConfigMap\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L238>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) Filename() string
|
||||
@@ -194,7 +194,7 @@ func (c *ConfigMap) Filename() string
|
||||
Filename returns the filename of the configmap. If the configmap is used for files, the filename contains the path.
|
||||
|
||||
<a name="ConfigMap.SetData"></a>
|
||||
### func \(\*ConfigMap\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L249>)
|
||||
### func \(\*ConfigMap\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L248>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) SetData(data map[string]string)
|
||||
@@ -203,7 +203,7 @@ func (c *ConfigMap) SetData(data map[string]string)
|
||||
SetData sets the data of the configmap. It replaces the entire data.
|
||||
|
||||
<a name="ConfigMap.Yaml"></a>
|
||||
### func \(\*ConfigMap\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L254>)
|
||||
### func \(\*ConfigMap\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L253>)
|
||||
|
||||
```go
|
||||
func (c *ConfigMap) Yaml() ([]byte, error)
|
||||
@@ -212,7 +212,7 @@ func (c *ConfigMap) Yaml() ([]byte, error)
|
||||
Yaml returns the yaml representation of the configmap
|
||||
|
||||
<a name="ConfigMapMount"></a>
|
||||
## type [ConfigMapMount](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L30-L33>)
|
||||
## type [ConfigMapMount](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L31-L34>)
|
||||
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ type ConfigMapMount struct {
|
||||
```
|
||||
|
||||
<a name="ConvertOptions"></a>
|
||||
## type [ConvertOptions](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L29-L38>)
|
||||
## type [ConvertOptions](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/chart.go#L28-L37>)
|
||||
|
||||
ConvertOptions are the options to convert a compose project to a helm chart.
|
||||
|
||||
@@ -241,7 +241,7 @@ type ConvertOptions struct {
|
||||
```
|
||||
|
||||
<a name="CronJob"></a>
|
||||
## type [CronJob](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/cronJob.go#L23-L26>)
|
||||
## type [CronJob](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/cronJob.go#L23-L26>)
|
||||
|
||||
CronJob is a kubernetes CronJob.
|
||||
|
||||
@@ -253,7 +253,7 @@ type CronJob struct {
|
||||
```
|
||||
|
||||
<a name="CronJob.Filename"></a>
|
||||
### func \(\*CronJob\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/cronJob.go#L113>)
|
||||
### func \(\*CronJob\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/cronJob.go#L113>)
|
||||
|
||||
```go
|
||||
func (c *CronJob) Filename() string
|
||||
@@ -264,7 +264,7 @@ Filename returns the filename of the cronjob.
|
||||
Implements the Yaml interface.
|
||||
|
||||
<a name="CronJob.Yaml"></a>
|
||||
### func \(\*CronJob\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/cronJob.go#L120>)
|
||||
### func \(\*CronJob\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/cronJob.go#L120>)
|
||||
|
||||
```go
|
||||
func (c *CronJob) Yaml() ([]byte, error)
|
||||
@@ -275,7 +275,7 @@ Yaml returns the yaml representation of the cronjob.
|
||||
Implements the Yaml interface.
|
||||
|
||||
<a name="CronJobValue"></a>
|
||||
## type [CronJobValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L118-L123>)
|
||||
## type [CronJobValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L118-L123>)
|
||||
|
||||
CronJobValue is a cronjob configuration that will be saved in values.yaml.
|
||||
|
||||
@@ -289,7 +289,7 @@ type CronJobValue struct {
|
||||
```
|
||||
|
||||
<a name="DataMap"></a>
|
||||
## type [DataMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/types.go#L4-L7>)
|
||||
## type [DataMap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/types.go#L4-L7>)
|
||||
|
||||
DataMap is a kubernetes ConfigMap or Secret. It can be used to add data to the ConfigMap or Secret.
|
||||
|
||||
@@ -301,7 +301,7 @@ type DataMap interface {
|
||||
```
|
||||
|
||||
<a name="Deployment"></a>
|
||||
## type [Deployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L36-L46>)
|
||||
## type [Deployment](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L37-L48>)
|
||||
|
||||
Deployment is a kubernetes Deployment.
|
||||
|
||||
@@ -313,7 +313,7 @@ type Deployment struct {
|
||||
```
|
||||
|
||||
<a name="NewDeployment"></a>
|
||||
### func [NewDeployment](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L50>)
|
||||
### func [NewDeployment](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L52>)
|
||||
|
||||
```go
|
||||
func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
|
||||
@@ -322,7 +322,7 @@ func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment
|
||||
NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name. It also creates the Values map that will be used to create the values.yaml file.
|
||||
|
||||
<a name="Deployment.AddContainer"></a>
|
||||
### func \(\*Deployment\) [AddContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L117>)
|
||||
### func \(\*Deployment\) [AddContainer](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L119>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) AddContainer(service types.ServiceConfig)
|
||||
@@ -331,7 +331,7 @@ func (d *Deployment) AddContainer(service types.ServiceConfig)
|
||||
AddContainer adds a container to the deployment.
|
||||
|
||||
<a name="Deployment.AddHealthCheck"></a>
|
||||
### func \(\*Deployment\) [AddHealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L164>)
|
||||
### func \(\*Deployment\) [AddHealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L166>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *corev1.Container)
|
||||
@@ -340,7 +340,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core
|
||||
|
||||
|
||||
<a name="Deployment.AddIngress"></a>
|
||||
### func \(\*Deployment\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L193>)
|
||||
### func \(\*Deployment\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L195>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *Ingress
|
||||
@@ -349,7 +349,7 @@ func (d *Deployment) AddIngress(service types.ServiceConfig, appName string) *In
|
||||
AddIngress adds an ingress to the deployment. It creates the ingress object.
|
||||
|
||||
<a name="Deployment.AddLegacyVolume"></a>
|
||||
### func \(\*Deployment\) [AddLegacyVolume](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L216>)
|
||||
### func \(\*Deployment\) [AddLegacyVolume](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L218>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) AddLegacyVolume(name, kind string)
|
||||
@@ -358,7 +358,7 @@ func (d *Deployment) AddLegacyVolume(name, kind string)
|
||||
|
||||
|
||||
<a name="Deployment.AddVolumes"></a>
|
||||
### func \(\*Deployment\) [AddVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L199>)
|
||||
### func \(\*Deployment\) [AddVolumes](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L201>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
|
||||
@@ -367,7 +367,7 @@ func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string)
|
||||
AddVolumes adds a volume to the deployment. It does not create the PVC, it only adds the volumes to the deployment. If the volume is a bind volume it will warn the user that it is not supported yet.
|
||||
|
||||
<a name="Deployment.BindFrom"></a>
|
||||
### func \(\*Deployment\) [BindFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L237>)
|
||||
### func \(\*Deployment\) [BindFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L239>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
|
||||
@@ -376,7 +376,7 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment)
|
||||
|
||||
|
||||
<a name="Deployment.BindMapFilesToContainer"></a>
|
||||
### func \(\*Deployment\) [BindMapFilesToContainer](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L372>)
|
||||
### func \(\*Deployment\) [BindMapFilesToContainer](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L419>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secrets []string, appName string) (*corev1.Container, int)
|
||||
@@ -385,7 +385,7 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret
|
||||
|
||||
|
||||
<a name="Deployment.DependsOn"></a>
|
||||
### func \(\*Deployment\) [DependsOn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L265>)
|
||||
### func \(\*Deployment\) [DependsOn](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L267>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) DependsOn(to *Deployment, servicename string) error
|
||||
@@ -394,7 +394,7 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error
|
||||
DependsOn adds a initContainer to the deployment that will wait for the service to be up.
|
||||
|
||||
<a name="Deployment.Filename"></a>
|
||||
### func \(\*Deployment\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L297>)
|
||||
### func \(\*Deployment\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L344>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) Filename() string
|
||||
@@ -403,7 +403,7 @@ func (d *Deployment) Filename() string
|
||||
Filename returns the filename of the deployment.
|
||||
|
||||
<a name="Deployment.MountExchangeVolumes"></a>
|
||||
### func \(\*Deployment\) [MountExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L423>)
|
||||
### func \(\*Deployment\) [MountExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L470>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) MountExchangeVolumes()
|
||||
@@ -412,7 +412,7 @@ func (d *Deployment) MountExchangeVolumes()
|
||||
|
||||
|
||||
<a name="Deployment.SetEnvFrom"></a>
|
||||
### func \(\*Deployment\) [SetEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L302>)
|
||||
### func \(\*Deployment\) [SetEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L349>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, samePod ...bool)
|
||||
@@ -420,8 +420,17 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
|
||||
|
||||
SetEnvFrom sets the environment variables to a configmap. The configmap is created.
|
||||
|
||||
<a name="Deployment.SetServiceAccountName"></a>
|
||||
### func \(\*Deployment\) [SetServiceAccountName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L654>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) SetServiceAccountName()
|
||||
```
|
||||
|
||||
|
||||
|
||||
<a name="Deployment.Yaml"></a>
|
||||
### func \(\*Deployment\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/deployment.go#L447>)
|
||||
### func \(\*Deployment\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/deployment.go#L494>)
|
||||
|
||||
```go
|
||||
func (d *Deployment) Yaml() ([]byte, error)
|
||||
@@ -430,7 +439,7 @@ func (d *Deployment) Yaml() ([]byte, error)
|
||||
Yaml returns the yaml representation of the deployment.
|
||||
|
||||
<a name="FileMapUsage"></a>
|
||||
## type [FileMapUsage](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/configMap.go#L23>)
|
||||
## type [FileMapUsage](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/configMap.go#L22>)
|
||||
|
||||
FileMapUsage is the usage of the filemap.
|
||||
|
||||
@@ -448,7 +457,7 @@ const (
|
||||
```
|
||||
|
||||
<a name="HelmChart"></a>
|
||||
## type [HelmChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L42-L55>)
|
||||
## type [HelmChart](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/chart.go#L41-L54>)
|
||||
|
||||
HelmChart is a Helm Chart representation. It contains all the templates, values, versions, helpers...
|
||||
|
||||
@@ -471,7 +480,7 @@ type HelmChart struct {
|
||||
```
|
||||
|
||||
<a name="Generate"></a>
|
||||
### func [Generate](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/generator.go#L33>)
|
||||
### func [Generate](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/generator.go#L32>)
|
||||
|
||||
```go
|
||||
func Generate(project *types.Project) (*HelmChart, error)
|
||||
@@ -482,7 +491,7 @@ Generate a chart from a compose project. This does not write files to disk, it o
|
||||
The Generate function will create the HelmChart object this way:
|
||||
|
||||
- Detect the service port name or leave the port number if not found.
|
||||
- Create a deployment for each service that are not ingnore.
|
||||
- Create a deployment for each service that are not ingore.
|
||||
- Create a service and ingresses for each service that has ports and/or declared ingresses.
|
||||
- Create a PVC or Configmap volumes for each volume.
|
||||
- Create init containers for each service which has dependencies to other services.
|
||||
@@ -491,7 +500,7 @@ The Generate function will create the HelmChart object this way:
|
||||
- Merge the same\-pod services.
|
||||
|
||||
<a name="NewChart"></a>
|
||||
### func [NewChart](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L58>)
|
||||
### func [NewChart](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/chart.go#L57>)
|
||||
|
||||
```go
|
||||
func NewChart(name string) *HelmChart
|
||||
@@ -500,7 +509,7 @@ func NewChart(name string) *HelmChart
|
||||
NewChart creates a new empty chart with the given name.
|
||||
|
||||
<a name="HelmChart.SaveTemplates"></a>
|
||||
### func \(\*HelmChart\) [SaveTemplates](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/chart.go#L73>)
|
||||
### func \(\*HelmChart\) [SaveTemplates](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/chart.go#L72>)
|
||||
|
||||
```go
|
||||
func (chart *HelmChart) SaveTemplates(templateDir string)
|
||||
@@ -509,7 +518,7 @@ func (chart *HelmChart) SaveTemplates(templateDir string)
|
||||
SaveTemplates the templates of the chart to the given directory.
|
||||
|
||||
<a name="Ingress"></a>
|
||||
## type [Ingress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/ingress.go#L18-L22>)
|
||||
## type [Ingress](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/ingress.go#L18-L22>)
|
||||
|
||||
|
||||
|
||||
@@ -521,7 +530,7 @@ type Ingress struct {
|
||||
```
|
||||
|
||||
<a name="NewIngress"></a>
|
||||
### func [NewIngress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/ingress.go#L25>)
|
||||
### func [NewIngress](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/ingress.go#L25>)
|
||||
|
||||
```go
|
||||
func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
|
||||
@@ -530,7 +539,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress
|
||||
NewIngress creates a new Ingress from a compose service.
|
||||
|
||||
<a name="Ingress.Filename"></a>
|
||||
### func \(\*Ingress\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/ingress.go#L129>)
|
||||
### func \(\*Ingress\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/ingress.go#L129>)
|
||||
|
||||
```go
|
||||
func (ingress *Ingress) Filename() string
|
||||
@@ -539,7 +548,7 @@ func (ingress *Ingress) Filename() string
|
||||
|
||||
|
||||
<a name="Ingress.Yaml"></a>
|
||||
### func \(\*Ingress\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/ingress.go#L133>)
|
||||
### func \(\*Ingress\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/ingress.go#L133>)
|
||||
|
||||
```go
|
||||
func (ingress *Ingress) Yaml() ([]byte, error)
|
||||
@@ -548,7 +557,7 @@ func (ingress *Ingress) Yaml() ([]byte, error)
|
||||
|
||||
|
||||
<a name="IngressValue"></a>
|
||||
## type [IngressValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L29-L36>)
|
||||
## type [IngressValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L29-L36>)
|
||||
|
||||
IngressValue is a ingress configuration that will be saved in values.yaml.
|
||||
|
||||
@@ -564,7 +573,7 @@ type IngressValue struct {
|
||||
```
|
||||
|
||||
<a name="PersistenceValue"></a>
|
||||
## type [PersistenceValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L16-L21>)
|
||||
## type [PersistenceValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L16-L21>)
|
||||
|
||||
PersistenceValue is a persistence configuration that will be saved in values.yaml.
|
||||
|
||||
@@ -578,7 +587,7 @@ type PersistenceValue struct {
|
||||
```
|
||||
|
||||
<a name="RBAC"></a>
|
||||
## type [RBAC](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L20-L24>)
|
||||
## type [RBAC](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L20-L24>)
|
||||
|
||||
RBAC is a kubernetes RBAC containing a role, a rolebinding and an associated serviceaccount.
|
||||
|
||||
@@ -591,7 +600,7 @@ type RBAC struct {
|
||||
```
|
||||
|
||||
<a name="NewRBAC"></a>
|
||||
### func [NewRBAC](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L27>)
|
||||
### func [NewRBAC](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L27>)
|
||||
|
||||
```go
|
||||
func NewRBAC(service types.ServiceConfig, appName string) *RBAC
|
||||
@@ -600,7 +609,7 @@ func NewRBAC(service types.ServiceConfig, appName string) *RBAC
|
||||
NewRBAC creates a new RBAC from a compose service. The appName is the name of the application taken from the project name.
|
||||
|
||||
<a name="RepositoryValue"></a>
|
||||
## type [RepositoryValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L10-L13>)
|
||||
## type [RepositoryValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L10-L13>)
|
||||
|
||||
RepositoryValue is a docker repository image and tag that will be saved in values.yaml.
|
||||
|
||||
@@ -612,7 +621,7 @@ type RepositoryValue struct {
|
||||
```
|
||||
|
||||
<a name="Role"></a>
|
||||
## type [Role](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L114-L117>)
|
||||
## type [Role](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L114-L117>)
|
||||
|
||||
Role is a kubernetes Role.
|
||||
|
||||
@@ -623,8 +632,17 @@ type Role struct {
|
||||
}
|
||||
```
|
||||
|
||||
<a name="NewRestrictedRole"></a>
|
||||
### func [NewRestrictedRole](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L150>)
|
||||
|
||||
```go
|
||||
func NewRestrictedRole(service types.ServiceConfig, appName string) *Role
|
||||
```
|
||||
|
||||
NewRestrictedRole creates a Role with minimal permissions for init containers.
|
||||
|
||||
<a name="Role.Filename"></a>
|
||||
### func \(\*Role\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L119>)
|
||||
### func \(\*Role\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L119>)
|
||||
|
||||
```go
|
||||
func (r *Role) Filename() string
|
||||
@@ -633,7 +651,7 @@ func (r *Role) Filename() string
|
||||
|
||||
|
||||
<a name="Role.Yaml"></a>
|
||||
### func \(\*Role\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L123>)
|
||||
### func \(\*Role\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L123>)
|
||||
|
||||
```go
|
||||
func (r *Role) Yaml() ([]byte, error)
|
||||
@@ -642,7 +660,7 @@ func (r *Role) Yaml() ([]byte, error)
|
||||
|
||||
|
||||
<a name="RoleBinding"></a>
|
||||
## type [RoleBinding](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L100-L103>)
|
||||
## type [RoleBinding](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L100-L103>)
|
||||
|
||||
RoleBinding is a kubernetes RoleBinding.
|
||||
|
||||
@@ -653,8 +671,17 @@ type RoleBinding struct {
|
||||
}
|
||||
```
|
||||
|
||||
<a name="NewRestrictedRoleBinding"></a>
|
||||
### func [NewRestrictedRoleBinding](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L175>)
|
||||
|
||||
```go
|
||||
func NewRestrictedRoleBinding(service types.ServiceConfig, appName string) *RoleBinding
|
||||
```
|
||||
|
||||
NewRestrictedRoleBinding creates a RoleBinding that binds the restricted role to the ServiceAccount.
|
||||
|
||||
<a name="RoleBinding.Filename"></a>
|
||||
### func \(\*RoleBinding\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L105>)
|
||||
### func \(\*RoleBinding\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L105>)
|
||||
|
||||
```go
|
||||
func (r *RoleBinding) Filename() string
|
||||
@@ -663,7 +690,7 @@ func (r *RoleBinding) Filename() string
|
||||
|
||||
|
||||
<a name="RoleBinding.Yaml"></a>
|
||||
### func \(\*RoleBinding\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L109>)
|
||||
### func \(\*RoleBinding\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L109>)
|
||||
|
||||
```go
|
||||
func (r *RoleBinding) Yaml() ([]byte, error)
|
||||
@@ -672,7 +699,7 @@ func (r *RoleBinding) Yaml() ([]byte, error)
|
||||
|
||||
|
||||
<a name="Secret"></a>
|
||||
## type [Secret](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L23-L26>)
|
||||
## type [Secret](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L23-L26>)
|
||||
|
||||
Secret is a kubernetes Secret.
|
||||
|
||||
@@ -686,7 +713,7 @@ type Secret struct {
|
||||
```
|
||||
|
||||
<a name="NewSecret"></a>
|
||||
### func [NewSecret](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L29>)
|
||||
### func [NewSecret](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L29>)
|
||||
|
||||
```go
|
||||
func NewSecret(service types.ServiceConfig, appName string) *Secret
|
||||
@@ -695,7 +722,7 @@ func NewSecret(service types.ServiceConfig, appName string) *Secret
|
||||
NewSecret creates a new Secret from a compose service
|
||||
|
||||
<a name="Secret.AddData"></a>
|
||||
### func \(\*Secret\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L71>)
|
||||
### func \(\*Secret\) [AddData](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L71>)
|
||||
|
||||
```go
|
||||
func (s *Secret) AddData(key, value string)
|
||||
@@ -704,7 +731,7 @@ func (s *Secret) AddData(key, value string)
|
||||
AddData adds a key value pair to the secret.
|
||||
|
||||
<a name="Secret.Filename"></a>
|
||||
### func \(\*Secret\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L87>)
|
||||
### func \(\*Secret\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L87>)
|
||||
|
||||
```go
|
||||
func (s *Secret) Filename() string
|
||||
@@ -713,7 +740,7 @@ func (s *Secret) Filename() string
|
||||
Filename returns the filename of the secret.
|
||||
|
||||
<a name="Secret.SetData"></a>
|
||||
### func \(\*Secret\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L92>)
|
||||
### func \(\*Secret\) [SetData](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L92>)
|
||||
|
||||
```go
|
||||
func (s *Secret) SetData(data map[string]string)
|
||||
@@ -722,7 +749,7 @@ func (s *Secret) SetData(data map[string]string)
|
||||
SetData sets the data of the secret.
|
||||
|
||||
<a name="Secret.Yaml"></a>
|
||||
### func \(\*Secret\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/secret.go#L99>)
|
||||
### func \(\*Secret\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/secret.go#L99>)
|
||||
|
||||
```go
|
||||
func (s *Secret) Yaml() ([]byte, error)
|
||||
@@ -731,7 +758,7 @@ func (s *Secret) Yaml() ([]byte, error)
|
||||
Yaml returns the yaml representation of the secret.
|
||||
|
||||
<a name="Service"></a>
|
||||
## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/service.go#L19-L22>)
|
||||
## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/service.go#L19-L22>)
|
||||
|
||||
Service is a kubernetes Service.
|
||||
|
||||
@@ -743,7 +770,7 @@ type Service struct {
|
||||
```
|
||||
|
||||
<a name="NewService"></a>
|
||||
### func [NewService](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/service.go#L25>)
|
||||
### func [NewService](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/service.go#L25>)
|
||||
|
||||
```go
|
||||
func NewService(service types.ServiceConfig, appName string) *Service
|
||||
@@ -752,7 +779,7 @@ func NewService(service types.ServiceConfig, appName string) *Service
|
||||
NewService creates a new Service from a compose service.
|
||||
|
||||
<a name="Service.AddPort"></a>
|
||||
### func \(\*Service\) [AddPort](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/service.go#L54>)
|
||||
### func \(\*Service\) [AddPort](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/service.go#L54>)
|
||||
|
||||
```go
|
||||
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
||||
@@ -761,7 +788,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
||||
AddPort adds a port to the service.
|
||||
|
||||
<a name="Service.Filename"></a>
|
||||
### func \(\*Service\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/service.go#L75>)
|
||||
### func \(\*Service\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/service.go#L75>)
|
||||
|
||||
```go
|
||||
func (s *Service) Filename() string
|
||||
@@ -770,7 +797,7 @@ func (s *Service) Filename() string
|
||||
Filename returns the filename of the service.
|
||||
|
||||
<a name="Service.Yaml"></a>
|
||||
### func \(\*Service\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/service.go#L80>)
|
||||
### func \(\*Service\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/service.go#L80>)
|
||||
|
||||
```go
|
||||
func (s *Service) Yaml() ([]byte, error)
|
||||
@@ -779,7 +806,7 @@ func (s *Service) Yaml() ([]byte, error)
|
||||
Yaml returns the yaml representation of the service.
|
||||
|
||||
<a name="ServiceAccount"></a>
|
||||
## type [ServiceAccount](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L132-L135>)
|
||||
## type [ServiceAccount](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L205-L208>)
|
||||
|
||||
ServiceAccount is a kubernetes ServiceAccount.
|
||||
|
||||
@@ -790,8 +817,17 @@ type ServiceAccount struct {
|
||||
}
|
||||
```
|
||||
|
||||
<a name="NewServiceAccount"></a>
|
||||
### func [NewServiceAccount](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L132>)
|
||||
|
||||
```go
|
||||
func NewServiceAccount(service types.ServiceConfig, appName string) *ServiceAccount
|
||||
```
|
||||
|
||||
NewServiceAccount creates a new ServiceAccount from a compose service.
|
||||
|
||||
<a name="ServiceAccount.Filename"></a>
|
||||
### func \(\*ServiceAccount\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L137>)
|
||||
### func \(\*ServiceAccount\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L210>)
|
||||
|
||||
```go
|
||||
func (r *ServiceAccount) Filename() string
|
||||
@@ -800,7 +836,7 @@ func (r *ServiceAccount) Filename() string
|
||||
|
||||
|
||||
<a name="ServiceAccount.Yaml"></a>
|
||||
### func \(\*ServiceAccount\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/rbac.go#L141>)
|
||||
### func \(\*ServiceAccount\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/rbac.go#L214>)
|
||||
|
||||
```go
|
||||
func (r *ServiceAccount) Yaml() ([]byte, error)
|
||||
@@ -809,7 +845,7 @@ func (r *ServiceAccount) Yaml() ([]byte, error)
|
||||
|
||||
|
||||
<a name="TLS"></a>
|
||||
## type [TLS](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L23-L26>)
|
||||
## type [TLS](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L23-L26>)
|
||||
|
||||
|
||||
|
||||
@@ -821,7 +857,7 @@ type TLS struct {
|
||||
```
|
||||
|
||||
<a name="Value"></a>
|
||||
## type [Value](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L39-L50>)
|
||||
## type [Value](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L39-L50>)
|
||||
|
||||
Value will be saved in values.yaml. It contains configuration for all deployment and services.
|
||||
|
||||
@@ -841,7 +877,7 @@ type Value struct {
|
||||
```
|
||||
|
||||
<a name="NewValue"></a>
|
||||
### func [NewValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L57>)
|
||||
### func [NewValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L57>)
|
||||
|
||||
```go
|
||||
func NewValue(service types.ServiceConfig, main ...bool) *Value
|
||||
@@ -852,7 +888,7 @@ NewValue creates a new Value from a compose service. The value contains the nece
|
||||
If \`main\` is true, the tag will be empty because it will be set in the helm chart appVersion.
|
||||
|
||||
<a name="Value.AddIngress"></a>
|
||||
### func \(\*Value\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L90>)
|
||||
### func \(\*Value\) [AddIngress](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L90>)
|
||||
|
||||
```go
|
||||
func (v *Value) AddIngress(host, path string)
|
||||
@@ -861,7 +897,7 @@ func (v *Value) AddIngress(host, path string)
|
||||
|
||||
|
||||
<a name="Value.AddPersistence"></a>
|
||||
### func \(\*Value\) [AddPersistence](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/values.go#L104>)
|
||||
### func \(\*Value\) [AddPersistence](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/values.go#L104>)
|
||||
|
||||
```go
|
||||
func (v *Value) AddPersistence(volumeName string)
|
||||
@@ -870,7 +906,7 @@ func (v *Value) AddPersistence(volumeName string)
|
||||
AddPersistence adds persistence configuration to the Value.
|
||||
|
||||
<a name="VolumeClaim"></a>
|
||||
## type [VolumeClaim](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/volume.go#L19-L24>)
|
||||
## type [VolumeClaim](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/volume.go#L19-L24>)
|
||||
|
||||
VolumeClaim is a kubernetes VolumeClaim. This is a PersistentVolumeClaim.
|
||||
|
||||
@@ -882,7 +918,7 @@ type VolumeClaim struct {
|
||||
```
|
||||
|
||||
<a name="NewVolumeClaim"></a>
|
||||
### func [NewVolumeClaim](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/volume.go#L27>)
|
||||
### func [NewVolumeClaim](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/volume.go#L27>)
|
||||
|
||||
```go
|
||||
func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *VolumeClaim
|
||||
@@ -891,7 +927,7 @@ func NewVolumeClaim(service types.ServiceConfig, volumeName, appName string) *Vo
|
||||
NewVolumeClaim creates a new VolumeClaim from a compose service.
|
||||
|
||||
<a name="VolumeClaim.Filename"></a>
|
||||
### func \(\*VolumeClaim\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/volume.go#L63>)
|
||||
### func \(\*VolumeClaim\) [Filename](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/volume.go#L63>)
|
||||
|
||||
```go
|
||||
func (v *VolumeClaim) Filename() string
|
||||
@@ -900,7 +936,7 @@ func (v *VolumeClaim) Filename() string
|
||||
Filename returns the suggested filename for a VolumeClaim.
|
||||
|
||||
<a name="VolumeClaim.Yaml"></a>
|
||||
### func \(\*VolumeClaim\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/volume.go#L68>)
|
||||
### func \(\*VolumeClaim\) [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/volume.go#L68>)
|
||||
|
||||
```go
|
||||
func (v *VolumeClaim) Yaml() ([]byte, error)
|
||||
@@ -909,7 +945,7 @@ func (v *VolumeClaim) Yaml() ([]byte, error)
|
||||
Yaml marshals a VolumeClaim into yaml.
|
||||
|
||||
<a name="Yaml"></a>
|
||||
## type [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/types.go#L10-L13>)
|
||||
## type [Yaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/types.go#L10-L13>)
|
||||
|
||||
Yaml is a kubernetes object that can be converted to yaml.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import "katenary.io/internal/generator/extrafiles"
|
||||
|
||||
Package extrafiles provides function to generate the Chart files that are not objects. Like README.md and notes.txt...
|
||||
|
||||
## func [NotesFile](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/extrafiles/notes.go#L13>)
|
||||
## func [NotesFile](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/extrafiles/notes.go#L13>)
|
||||
|
||||
```go
|
||||
func NotesFile(services []string) string
|
||||
@@ -17,7 +17,7 @@ func NotesFile(services []string) string
|
||||
NotesFile returns the content of the note.txt file.
|
||||
|
||||
<a name="ReadMeFile"></a>
|
||||
## func [ReadMeFile](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/extrafiles/readme.go#L46>)
|
||||
## func [ReadMeFile](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/extrafiles/readme.go#L46>)
|
||||
|
||||
```go
|
||||
func ReadMeFile(charname, description string, values map[string]any) string
|
||||
|
||||
@@ -12,7 +12,7 @@ A katenary file, named "katenary.yml" or "katenary.yaml", is a file where you ca
|
||||
|
||||
Formely, the file describe the same structure as in labels, and so that can be validated and completed by LSP. It also ease the use of katenary.
|
||||
|
||||
## func [GenerateSchema](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L137>)
|
||||
## func [GenerateSchema](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/katenaryfile/main.go#L141>)
|
||||
|
||||
```go
|
||||
func GenerateSchema() string
|
||||
@@ -21,7 +21,7 @@ func GenerateSchema() string
|
||||
GenerateSchema generates the schema for the katenary.yaml file.
|
||||
|
||||
<a name="OverrideWithConfig"></a>
|
||||
## func [OverrideWithConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L49>)
|
||||
## func [OverrideWithConfig](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/katenaryfile/main.go#L48>)
|
||||
|
||||
```go
|
||||
func OverrideWithConfig(project *types.Project)
|
||||
@@ -30,7 +30,7 @@ func OverrideWithConfig(project *types.Project)
|
||||
OverrideWithConfig overrides the project with the katenary.yaml file. It will set the labels of the services with the values from the katenary.yaml file. It work in memory, so it will not modify the original project.
|
||||
|
||||
<a name="Service"></a>
|
||||
## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L27-L44>)
|
||||
## type [Service](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/katenaryfile/main.go#L26-L43>)
|
||||
|
||||
Service is a struct that contains the service configuration for katenary
|
||||
|
||||
@@ -56,7 +56,7 @@ type Service struct {
|
||||
```
|
||||
|
||||
<a name="StringOrMap"></a>
|
||||
## type [StringOrMap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/katenaryfile/main.go#L24>)
|
||||
## type [StringOrMap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/katenaryfile/main.go#L23>)
|
||||
|
||||
StringOrMap is a struct that can be either a string or a map of strings. It's a helper struct to unmarshal the katenary.yaml file and produce the schema
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ const KatenaryLabelPrefix = "katenary.v3"
|
||||
```
|
||||
|
||||
<a name="GetLabelHelp"></a>
|
||||
## func [GetLabelHelp](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L89>)
|
||||
## func [GetLabelHelp](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L90>)
|
||||
|
||||
```go
|
||||
func GetLabelHelp(asMarkdown bool) string
|
||||
@@ -26,7 +26,7 @@ func GetLabelHelp(asMarkdown bool) string
|
||||
GetLabelHelp return the help for the labels.
|
||||
|
||||
<a name="GetLabelHelpFor"></a>
|
||||
## func [GetLabelHelpFor](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L98>)
|
||||
## func [GetLabelHelpFor](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L99>)
|
||||
|
||||
```go
|
||||
func GetLabelHelpFor(labelname string, asMarkdown bool) string
|
||||
@@ -35,7 +35,7 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string
|
||||
GetLabelHelpFor returns the help for a specific label.
|
||||
|
||||
<a name="GetLabelNames"></a>
|
||||
## func [GetLabelNames](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L73>)
|
||||
## func [GetLabelNames](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L74>)
|
||||
|
||||
```go
|
||||
func GetLabelNames() []string
|
||||
@@ -44,7 +44,7 @@ func GetLabelNames() []string
|
||||
GetLabelNames returns a sorted list of all katenary label names.
|
||||
|
||||
<a name="Prefix"></a>
|
||||
## func [Prefix](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L236>)
|
||||
## func [Prefix](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L237>)
|
||||
|
||||
```go
|
||||
func Prefix() string
|
||||
@@ -53,7 +53,7 @@ func Prefix() string
|
||||
|
||||
|
||||
<a name="Help"></a>
|
||||
## type [Help](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L65-L70>)
|
||||
## type [Help](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L66-L71>)
|
||||
|
||||
Help is the documentation of a label.
|
||||
|
||||
@@ -67,7 +67,7 @@ type Help struct {
|
||||
```
|
||||
|
||||
<a name="Label"></a>
|
||||
## type [Label](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L58>)
|
||||
## type [Label](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L59>)
|
||||
|
||||
Label is a katenary label to find in compose files.
|
||||
|
||||
@@ -95,11 +95,12 @@ const (
|
||||
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||
LabelValuesFrom Label = KatenaryLabelPrefix + "/values-from"
|
||||
LabelDependsOn Label = KatenaryLabelPrefix + "/depends-on"
|
||||
)
|
||||
```
|
||||
|
||||
<a name="LabelName"></a>
|
||||
### func [LabelName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/katenaryLabels.go#L60>)
|
||||
### func [LabelName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/katenaryLabels.go#L61>)
|
||||
|
||||
```go
|
||||
func LabelName(name string) Label
|
||||
|
||||
@@ -8,7 +8,7 @@ import "katenary.io/internal/generator/labels/labelstructs"
|
||||
|
||||
Package labelstructs is a package that contains the structs used to represent the labels in the yaml files.
|
||||
|
||||
## type [ConfigMapFiles](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/configMap.go#L5>)
|
||||
## type [ConfigMapFiles](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/configMap.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ type ConfigMapFiles []string
|
||||
```
|
||||
|
||||
<a name="ConfigMapFileFrom"></a>
|
||||
### func [ConfigMapFileFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/configMap.go#L7>)
|
||||
### func [ConfigMapFileFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/configMap.go#L7>)
|
||||
|
||||
```go
|
||||
func ConfigMapFileFrom(data string) (ConfigMapFiles, error)
|
||||
@@ -26,7 +26,7 @@ func ConfigMapFileFrom(data string) (ConfigMapFiles, error)
|
||||
|
||||
|
||||
<a name="CronJob"></a>
|
||||
## type [CronJob](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/cronJob.go#L5-L10>)
|
||||
## type [CronJob](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/cronJob.go#L5-L10>)
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ type CronJob struct {
|
||||
```
|
||||
|
||||
<a name="CronJobFrom"></a>
|
||||
### func [CronJobFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/cronJob.go#L12>)
|
||||
### func [CronJobFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/cronJob.go#L12>)
|
||||
|
||||
```go
|
||||
func CronJobFrom(data string) (*CronJob, error)
|
||||
@@ -49,7 +49,7 @@ func CronJobFrom(data string) (*CronJob, error)
|
||||
|
||||
|
||||
<a name="Dependency"></a>
|
||||
## type [Dependency](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/dependencies.go#L6-L12>)
|
||||
## type [Dependency](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/dependencies.go#L6-L12>)
|
||||
|
||||
Dependency is a dependency of a chart to other charts.
|
||||
|
||||
@@ -64,7 +64,7 @@ type Dependency struct {
|
||||
```
|
||||
|
||||
<a name="DependenciesFrom"></a>
|
||||
### func [DependenciesFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/dependencies.go#L15>)
|
||||
### func [DependenciesFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/dependencies.go#L15>)
|
||||
|
||||
```go
|
||||
func DependenciesFrom(data string) ([]Dependency, error)
|
||||
@@ -73,7 +73,7 @@ func DependenciesFrom(data string) ([]Dependency, error)
|
||||
DependenciesFrom returns a slice of dependencies from the given string.
|
||||
|
||||
<a name="EnvFrom"></a>
|
||||
## type [EnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/envFrom.go#L5>)
|
||||
## type [EnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/envFrom.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ type EnvFrom []string
|
||||
```
|
||||
|
||||
<a name="EnvFromFrom"></a>
|
||||
### func [EnvFromFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/envFrom.go#L8>)
|
||||
### func [EnvFromFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/envFrom.go#L8>)
|
||||
|
||||
```go
|
||||
func EnvFromFrom(data string) (EnvFrom, error)
|
||||
@@ -91,7 +91,7 @@ func EnvFromFrom(data string) (EnvFrom, error)
|
||||
EnvFromFrom returns a EnvFrom from the given string.
|
||||
|
||||
<a name="ExchangeVolume"></a>
|
||||
## type [ExchangeVolume](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/exchangeVolume.go#L5-L10>)
|
||||
## type [ExchangeVolume](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/exchangeVolume.go#L5-L10>)
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ type ExchangeVolume struct {
|
||||
```
|
||||
|
||||
<a name="NewExchangeVolumes"></a>
|
||||
### func [NewExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/exchangeVolume.go#L12>)
|
||||
### func [NewExchangeVolumes](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/exchangeVolume.go#L12>)
|
||||
|
||||
```go
|
||||
func NewExchangeVolumes(data string) ([]*ExchangeVolume, error)
|
||||
@@ -114,7 +114,7 @@ func NewExchangeVolumes(data string) ([]*ExchangeVolume, error)
|
||||
|
||||
|
||||
<a name="HealthCheck"></a>
|
||||
## type [HealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/probes.go#L11-L14>)
|
||||
## type [HealthCheck](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/probes.go#L11-L14>)
|
||||
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ type HealthCheck struct {
|
||||
```
|
||||
|
||||
<a name="ProbeFrom"></a>
|
||||
### func [ProbeFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/probes.go#L16>)
|
||||
### func [ProbeFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/probes.go#L16>)
|
||||
|
||||
```go
|
||||
func ProbeFrom(data string) (*HealthCheck, error)
|
||||
@@ -135,7 +135,7 @@ func ProbeFrom(data string) (*HealthCheck, error)
|
||||
|
||||
|
||||
<a name="Ingress"></a>
|
||||
## type [Ingress](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/ingress.go#L15-L23>)
|
||||
## type [Ingress](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/ingress.go#L15-L23>)
|
||||
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ type Ingress struct {
|
||||
```
|
||||
|
||||
<a name="IngressFrom"></a>
|
||||
### func [IngressFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/ingress.go#L26>)
|
||||
### func [IngressFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/ingress.go#L26>)
|
||||
|
||||
```go
|
||||
func IngressFrom(data string) (*Ingress, error)
|
||||
@@ -161,7 +161,7 @@ func IngressFrom(data string) (*Ingress, error)
|
||||
IngressFrom creates a new Ingress from a compose service.
|
||||
|
||||
<a name="MapEnv"></a>
|
||||
## type [MapEnv](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/mapenv.go#L5>)
|
||||
## type [MapEnv](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/mapenv.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ type MapEnv map[string]string
|
||||
```
|
||||
|
||||
<a name="MapEnvFrom"></a>
|
||||
### func [MapEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/mapenv.go#L8>)
|
||||
### func [MapEnvFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/mapenv.go#L8>)
|
||||
|
||||
```go
|
||||
func MapEnvFrom(data string) (MapEnv, error)
|
||||
@@ -179,7 +179,7 @@ func MapEnvFrom(data string) (MapEnv, error)
|
||||
MapEnvFrom returns a MapEnv from the given string.
|
||||
|
||||
<a name="Ports"></a>
|
||||
## type [Ports](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/ports.go#L5>)
|
||||
## type [Ports](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/ports.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ type Ports []uint32
|
||||
```
|
||||
|
||||
<a name="PortsFrom"></a>
|
||||
### func [PortsFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/ports.go#L8>)
|
||||
### func [PortsFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/ports.go#L8>)
|
||||
|
||||
```go
|
||||
func PortsFrom(data string) (Ports, error)
|
||||
@@ -197,7 +197,7 @@ func PortsFrom(data string) (Ports, error)
|
||||
PortsFrom returns a Ports from the given string.
|
||||
|
||||
<a name="Secrets"></a>
|
||||
## type [Secrets](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/secrets.go#L5>)
|
||||
## type [Secrets](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/secrets.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ type Secrets []string
|
||||
```
|
||||
|
||||
<a name="SecretsFrom"></a>
|
||||
### func [SecretsFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/secrets.go#L7>)
|
||||
### func [SecretsFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/secrets.go#L7>)
|
||||
|
||||
```go
|
||||
func SecretsFrom(data string) (Secrets, error)
|
||||
@@ -215,7 +215,7 @@ func SecretsFrom(data string) (Secrets, error)
|
||||
|
||||
|
||||
<a name="TLS"></a>
|
||||
## type [TLS](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/ingress.go#L11-L13>)
|
||||
## type [TLS](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/ingress.go#L11-L13>)
|
||||
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ type TLS struct {
|
||||
```
|
||||
|
||||
<a name="ValueFrom"></a>
|
||||
## type [ValueFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/valueFrom.go#L5>)
|
||||
## type [ValueFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/valueFrom.go#L5>)
|
||||
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ type ValueFrom map[string]string
|
||||
```
|
||||
|
||||
<a name="GetValueFrom"></a>
|
||||
### func [GetValueFrom](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/generator/labels/labelstructs/valueFrom.go#L7>)
|
||||
### func [GetValueFrom](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/generator/labels/labelstructs/valueFrom.go#L7>)
|
||||
|
||||
```go
|
||||
func GetValueFrom(data string) (*ValueFrom, error)
|
||||
|
||||
@@ -8,7 +8,7 @@ import "katenary.io/internal/logger"
|
||||
|
||||
Package logger provides simple logging functions with icons and colors.
|
||||
|
||||
## func [Failure](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L43>)
|
||||
## func [Failure](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L75>)
|
||||
|
||||
```go
|
||||
func Failure(msg ...any)
|
||||
@@ -16,8 +16,35 @@ func Failure(msg ...any)
|
||||
|
||||
Failure prints a failure message.
|
||||
|
||||
<a name="Failuref"></a>
|
||||
## func [Failuref](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L81>)
|
||||
|
||||
```go
|
||||
func Failuref(format string, msg ...any)
|
||||
```
|
||||
|
||||
Failuref prints a formatted failure message.
|
||||
|
||||
<a name="Fatal"></a>
|
||||
## func [Fatal](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L108>)
|
||||
|
||||
```go
|
||||
func Fatal(msg ...any)
|
||||
```
|
||||
|
||||
Fatal prints a fatal error message and exits with code 1.
|
||||
|
||||
<a name="Fatalf"></a>
|
||||
## func [Fatalf](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L114>)
|
||||
|
||||
```go
|
||||
func Fatalf(format string, msg ...any)
|
||||
```
|
||||
|
||||
Fatalf prints a fatal error message with formatting and exits with code 1.
|
||||
|
||||
<a name="Info"></a>
|
||||
## func [Info](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L26>)
|
||||
## func [Info](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L41>)
|
||||
|
||||
```go
|
||||
func Info(msg ...any)
|
||||
@@ -25,8 +52,17 @@ func Info(msg ...any)
|
||||
|
||||
Info prints an informational message.
|
||||
|
||||
<a name="Infof"></a>
|
||||
## func [Infof](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L46>)
|
||||
|
||||
```go
|
||||
func Infof(format string, msg ...any)
|
||||
```
|
||||
|
||||
Infof prints a formatted informational message.
|
||||
|
||||
<a name="Log"></a>
|
||||
## func [Log](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L49>)
|
||||
## func [Log](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L87>)
|
||||
|
||||
```go
|
||||
func Log(icon Icon, msg ...any)
|
||||
@@ -34,8 +70,35 @@ func Log(icon Icon, msg ...any)
|
||||
|
||||
Log prints a message with a custom icon.
|
||||
|
||||
<a name="Logf"></a>
|
||||
## func [Logf](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L92>)
|
||||
|
||||
```go
|
||||
func Logf(icon Icon, format string, msg ...any)
|
||||
```
|
||||
|
||||
Logf prints a formatted message with a custom icon.
|
||||
|
||||
<a name="Print"></a>
|
||||
## func [Print](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L31>)
|
||||
|
||||
```go
|
||||
func Print(msg ...any)
|
||||
```
|
||||
|
||||
Print prints a message without icon.
|
||||
|
||||
<a name="Printf"></a>
|
||||
## func [Printf](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L36>)
|
||||
|
||||
```go
|
||||
func Printf(format string, msg ...any)
|
||||
```
|
||||
|
||||
Printf prints a formatted message without icon.
|
||||
|
||||
<a name="Success"></a>
|
||||
## func [Success](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L37>)
|
||||
## func [Success](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L63>)
|
||||
|
||||
```go
|
||||
func Success(msg ...any)
|
||||
@@ -43,8 +106,17 @@ func Success(msg ...any)
|
||||
|
||||
Success prints a success message.
|
||||
|
||||
<a name="Successf"></a>
|
||||
## func [Successf](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L69>)
|
||||
|
||||
```go
|
||||
func Successf(format string, msg ...any)
|
||||
```
|
||||
|
||||
Successf prints a formatted success message.
|
||||
|
||||
<a name="Warn"></a>
|
||||
## func [Warn](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L31>)
|
||||
## func [Warn](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L51>)
|
||||
|
||||
```go
|
||||
func Warn(msg ...any)
|
||||
@@ -52,8 +124,17 @@ func Warn(msg ...any)
|
||||
|
||||
Warn prints a warning message.
|
||||
|
||||
<a name="Warnf"></a>
|
||||
## func [Warnf](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L57>)
|
||||
|
||||
```go
|
||||
func Warnf(format string, msg ...any)
|
||||
```
|
||||
|
||||
Warnf prints a formatted warning message.
|
||||
|
||||
<a name="Icon"></a>
|
||||
## type [Icon](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/logger/logger.go#L5>)
|
||||
## type [Icon](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/logger/logger.go#L10>)
|
||||
|
||||
Icon is a unicode icon
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import "katenary.io/internal/parser"
|
||||
|
||||
Package parser is a wrapper around compose\-go to parse compose files.
|
||||
|
||||
## func [Parse](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/parser/main.go#L29>)
|
||||
## func [Parse](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/parser/main.go#L30>)
|
||||
|
||||
```go
|
||||
func Parse(profiles []string, envFiles []string, dockerComposeFile ...string) (*types.Project, error)
|
||||
|
||||
@@ -17,7 +17,7 @@ const DirectoryPermission = 0o755
|
||||
```
|
||||
|
||||
<a name="AsResourceName"></a>
|
||||
## func [AsResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L198>)
|
||||
## func [AsResourceName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L197>)
|
||||
|
||||
```go
|
||||
func AsResourceName(name string) string
|
||||
@@ -26,7 +26,7 @@ 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>
|
||||
## func [Confirm](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L166>)
|
||||
## func [Confirm](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L165>)
|
||||
|
||||
```go
|
||||
func Confirm(question string, icon ...logger.Icon) bool
|
||||
@@ -35,7 +35,7 @@ func Confirm(question string, icon ...logger.Icon) bool
|
||||
Confirm asks a question and returns true if the answer is y.
|
||||
|
||||
<a name="CountStartingSpaces"></a>
|
||||
## func [CountStartingSpaces](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L42>)
|
||||
## func [CountStartingSpaces](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L41>)
|
||||
|
||||
```go
|
||||
func CountStartingSpaces(line string) int
|
||||
@@ -44,7 +44,7 @@ func CountStartingSpaces(line string) int
|
||||
CountStartingSpaces counts the number of spaces at the beginning of a string.
|
||||
|
||||
<a name="EncodeBasicYaml"></a>
|
||||
## func [EncodeBasicYaml](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L180>)
|
||||
## func [EncodeBasicYaml](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L179>)
|
||||
|
||||
```go
|
||||
func EncodeBasicYaml(data any) ([]byte, error)
|
||||
@@ -53,7 +53,7 @@ func EncodeBasicYaml(data any) ([]byte, error)
|
||||
EncodeBasicYaml encodes a basic yaml from an interface.
|
||||
|
||||
<a name="FixedResourceName"></a>
|
||||
## func [FixedResourceName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L192>)
|
||||
## func [FixedResourceName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L191>)
|
||||
|
||||
```go
|
||||
func FixedResourceName(name string) string
|
||||
@@ -62,7 +62,7 @@ func FixedResourceName(name string) string
|
||||
FixedResourceName returns a resource name without underscores to respect the kubernetes naming convention.
|
||||
|
||||
<a name="GetContainerByName"></a>
|
||||
## func [GetContainerByName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L88>)
|
||||
## func [GetContainerByName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L87>)
|
||||
|
||||
```go
|
||||
func GetContainerByName(name string, containers []corev1.Container) (*corev1.Container, int)
|
||||
@@ -71,7 +71,7 @@ func GetContainerByName(name string, containers []corev1.Container) (*corev1.Con
|
||||
GetContainerByName returns a container by name and its index in the array. It returns nil, \-1 if not found.
|
||||
|
||||
<a name="GetKind"></a>
|
||||
## func [GetKind](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L55>)
|
||||
## func [GetKind](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L54>)
|
||||
|
||||
```go
|
||||
func GetKind(path string) (kind string)
|
||||
@@ -80,7 +80,7 @@ func GetKind(path string) (kind string)
|
||||
GetKind returns the kind of the resource from the file path.
|
||||
|
||||
<a name="GetServiceNameByPort"></a>
|
||||
## func [GetServiceNameByPort](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L78>)
|
||||
## func [GetServiceNameByPort](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L77>)
|
||||
|
||||
```go
|
||||
func GetServiceNameByPort(port int) string
|
||||
@@ -89,7 +89,7 @@ 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.
|
||||
|
||||
<a name="GetValuesFromLabel"></a>
|
||||
## func [GetValuesFromLabel](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L130>)
|
||||
## func [GetValuesFromLabel](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L129>)
|
||||
|
||||
```go
|
||||
func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[string]*EnvConfig
|
||||
@@ -98,7 +98,7 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
|
||||
GetValuesFromLabel returns a map of values from a label.
|
||||
|
||||
<a name="HashComposefiles"></a>
|
||||
## func [HashComposefiles](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/hash.go#L12>)
|
||||
## func [HashComposefiles](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/hash.go#L12>)
|
||||
|
||||
```go
|
||||
func HashComposefiles(files []string) (string, error)
|
||||
@@ -107,7 +107,7 @@ func HashComposefiles(files []string) (string, error)
|
||||
HashComposefiles returns a hash of the compose files.
|
||||
|
||||
<a name="Int32Ptr"></a>
|
||||
## func [Int32Ptr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L36>)
|
||||
## func [Int32Ptr](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L35>)
|
||||
|
||||
```go
|
||||
func Int32Ptr(i int32) *int32
|
||||
@@ -116,7 +116,7 @@ func Int32Ptr(i int32) *int32
|
||||
Int32Ptr returns a pointer to an int32.
|
||||
|
||||
<a name="PathToName"></a>
|
||||
## func [PathToName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L107>)
|
||||
## func [PathToName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L106>)
|
||||
|
||||
```go
|
||||
func PathToName(path string) string
|
||||
@@ -125,7 +125,7 @@ func PathToName(path string) string
|
||||
PathToName converts a path to a kubernetes complient name.
|
||||
|
||||
<a name="StrPtr"></a>
|
||||
## func [StrPtr](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L39>)
|
||||
## func [StrPtr](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L38>)
|
||||
|
||||
```go
|
||||
func StrPtr(s string) *string
|
||||
@@ -134,7 +134,7 @@ func StrPtr(s string) *string
|
||||
StrPtr returns a pointer to a string.
|
||||
|
||||
<a name="TplName"></a>
|
||||
## func [TplName](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L23>)
|
||||
## func [TplName](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L22>)
|
||||
|
||||
```go
|
||||
func TplName(serviceName, appname string, suffix ...string) string
|
||||
@@ -143,7 +143,7 @@ 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.
|
||||
|
||||
<a name="TplValue"></a>
|
||||
## func [TplValue](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L98>)
|
||||
## func [TplValue](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L97>)
|
||||
|
||||
```go
|
||||
func TplValue(serviceName, variable string, pipes ...string) string
|
||||
@@ -152,7 +152,7 @@ func TplValue(serviceName, variable string, pipes ...string) string
|
||||
TplValue returns a string that can be used in a template to access a value from the values file.
|
||||
|
||||
<a name="WordWrap"></a>
|
||||
## func [WordWrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L161>)
|
||||
## func [WordWrap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L160>)
|
||||
|
||||
```go
|
||||
func WordWrap(text string, lineWidth int) string
|
||||
@@ -161,7 +161,7 @@ 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.
|
||||
|
||||
<a name="Wrap"></a>
|
||||
## func [Wrap](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L72>)
|
||||
## func [Wrap](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L71>)
|
||||
|
||||
```go
|
||||
func Wrap(src, above, below string) string
|
||||
@@ -170,7 +170,7 @@ 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.
|
||||
|
||||
<a name="EnvConfig"></a>
|
||||
## type [EnvConfig](<https://repo.katenary.io/Katenary/katenary/blob/master/internal/utils/utils.go#L124-L127>)
|
||||
## type [EnvConfig](<https://repo.katenary.io/Katenary/katenary/blob/feature/better-depends-on/internal/utils/utils.go#L123-L126>)
|
||||
|
||||
EnvConfig is a struct to hold the description of an environment variable.
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ Katenary transforms compose services this way:
|
||||
- environment variables will be stored inside a `ConfigMap`
|
||||
- image, tags, and ingresses configuration are also stored in `values.yaml` file
|
||||
- if named volumes are declared, Katenary create `PersistentVolumeClaims` - not enabled in values file
|
||||
- `depends_on` needs that the pointed service declared a port. If not, you can use labels to inform Katenary
|
||||
- `depends_on` uses Kubernetes API by default to check if the service endpoint is ready. No port required.
|
||||
- If you need to create a Kubernetes Service for external access, add the `katenary.v3/ports` label.
|
||||
Use label `katenary.v3/depends-on: legacy` to use the old netcat method (requires port).
|
||||
|
||||
For any other specific configuration, like binding local files as `ConfigMap`, bind variables, add values with
|
||||
documentation, etc. You'll need to use labels.
|
||||
@@ -147,10 +149,8 @@ Katenary proposes a lot of labels to configure the helm chart generation, but so
|
||||
|
||||
### Work with Depends On?
|
||||
|
||||
Kubernetes does not provide service or pod starting detection from others pods. But Katenary will create `initContainer`
|
||||
to make you able to wait for a service to respond. But you'll probably need to adapt a bit the compose file.
|
||||
|
||||
See this compose file:
|
||||
Katenary creates `initContainer` to wait for dependent services to be ready. By default, it uses the Kubernetes API
|
||||
to check if the service endpoint has ready addresses - no port required.
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
@@ -167,9 +167,28 @@ services:
|
||||
MYSQL_ROOT_PASSWORD: foobar
|
||||
```
|
||||
|
||||
In this case, `webapp` needs to know the `database` port because the `depends_on` points on it and Kubernetes has not
|
||||
(yet) solution to check the database startup. Katenary wants to create a `initContainer` to hit on the related service.
|
||||
So, instead of exposing the port in the compose definition, let's declare this to Katenary with labels:
|
||||
If you need the old netcat-based method (requires port), add the `katenary.v3/depends-on: legacy` label to the dependent service:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
webapp:
|
||||
image: php:8-apache
|
||||
depends_on:
|
||||
- database
|
||||
labels:
|
||||
katenary.v3/depends-on: legacy
|
||||
|
||||
database:
|
||||
image: mariadb
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: foobar
|
||||
ports:
|
||||
- 3306:3306
|
||||
```
|
||||
|
||||
If you want to create a Kubernetes Service for external access, add the `katenary.v3/ports` label to the service:
|
||||
|
||||
```yaml
|
||||
version: "3"
|
||||
@@ -185,7 +204,7 @@ services:
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: foobar
|
||||
labels:
|
||||
katenary.v3/ports: |-
|
||||
katenary.v3/ports:
|
||||
- 3306
|
||||
```
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ image, tags, and ingresses configuration are also stored in \f[CR]values.yaml\f[
|
||||
.IP \[bu] 2
|
||||
if named volumes are declared, Katenary create \f[CR]PersistentVolumeClaims\f[R] \- not enabled in values file
|
||||
.IP \[bu] 2
|
||||
\f[CR]depends_on\f[R] needs that the pointed service declared a port.
|
||||
If not, you can use labels to inform Katenary
|
||||
\f[CR]depends_on\f[R] uses Kubernetes API to check if the service endpoint is ready. No port declaration is required.
|
||||
If you need to create a Kubernetes Service for external access, use the \f[CR]katenary.v3/ports\f[R] label.
|
||||
.PP
|
||||
For any other specific configuration, like binding local files as \f[CR]ConfigMap\f[R], bind variables, add values with documentation, etc.
|
||||
You\[aq]ll need to use labels.
|
||||
|
||||
@@ -2,7 +2,6 @@ package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -331,12 +330,12 @@ func (chart *HelmChart) setSharedConf(service types.ServiceConfig, deployments m
|
||||
}
|
||||
fromservices, err := labelstructs.EnvFromFrom(service.Labels[labels.LabelEnvFrom])
|
||||
if err != nil {
|
||||
log.Fatal("error unmarshaling env-from label:", err)
|
||||
logger.Fatal("error unmarshaling env-from label:", err)
|
||||
}
|
||||
// find the configmap in the chart templates
|
||||
for _, fromservice := range fromservices {
|
||||
if _, ok := chart.Templates[fromservice+".configmap.yaml"]; !ok {
|
||||
log.Printf("configmap %s not found in chart templates", fromservice)
|
||||
logger.Warnf("configmap %s not found in chart templates", fromservice)
|
||||
continue
|
||||
}
|
||||
// find the corresponding target deployment
|
||||
@@ -356,7 +355,7 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de
|
||||
}
|
||||
mapping, err := labelstructs.GetValueFrom(service.Labels[labels.LabelValuesFrom])
|
||||
if err != nil {
|
||||
log.Fatal("error unmarshaling values-from label:", err)
|
||||
logger.Fatal("error unmarshaling values-from label:", err)
|
||||
}
|
||||
|
||||
findDeployment := func(name string) *Deployment {
|
||||
@@ -375,11 +374,11 @@ func (chart *HelmChart) setEnvironmentValuesFrom(service types.ServiceConfig, de
|
||||
dep := findDeployment(depName[0])
|
||||
target := findDeployment(service.Name)
|
||||
if dep == nil || target == nil {
|
||||
log.Fatalf("deployment %s or %s not found", depName[0], service.Name)
|
||||
logger.Fatalf("deployment %s or %s not found", depName[0], service.Name)
|
||||
}
|
||||
container, index := utils.GetContainerByName(target.service.ContainerName, target.Spec.Template.Spec.Containers)
|
||||
if container == nil {
|
||||
log.Fatalf("Container %s not found", target.GetName())
|
||||
logger.Fatalf("Container %s not found", target.GetName())
|
||||
}
|
||||
reourceName := fmt.Sprintf(`{{ include "%s.fullname" . }}-%s`, chart.Name, depName[0])
|
||||
// add environment with from
|
||||
|
||||
@@ -2,7 +2,6 @@ package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -69,7 +68,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
|
||||
// get the secrets from the labels
|
||||
secrets, err := labelstructs.SecretsFrom(service.Labels[labels.LabelSecrets])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
// drop the secrets from the environment
|
||||
for _, secret := range secrets {
|
||||
@@ -95,7 +94,7 @@ func NewConfigMap(service types.ServiceConfig, appName string, forFile bool) *Co
|
||||
if l, ok := service.Labels[labels.LabelMapEnv]; ok {
|
||||
envmap, err := labelstructs.MapEnvFrom(l)
|
||||
if err != nil {
|
||||
log.Fatal("Error parsing map-env", err)
|
||||
logger.Fatal("Error parsing map-env", err)
|
||||
}
|
||||
for key, value := range envmap {
|
||||
cm.AddData(key, strings.ReplaceAll(value, "__APP__", appName))
|
||||
@@ -145,7 +144,7 @@ func NewConfigMapFromDirectory(service types.ServiceConfig, appName, path string
|
||||
path = filepath.Join(service.WorkingDir, path)
|
||||
path = filepath.Clean(path)
|
||||
if err := cm.AppendDir(path); err != nil {
|
||||
log.Fatal("Error adding files to configmap:", err)
|
||||
logger.Fatal("Error adding files to configmap:", err)
|
||||
}
|
||||
return cm
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -110,8 +109,19 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
|
||||
|
||||
// the current working directory is the directory
|
||||
currentDir, _ := os.Getwd()
|
||||
// Filter to only existing files before chdir
|
||||
var existingFiles []string
|
||||
for _, f := range dockerComposeFile {
|
||||
if _, err := os.Stat(f); err == nil {
|
||||
existingFiles = append(existingFiles, f)
|
||||
}
|
||||
}
|
||||
if len(existingFiles) == 0 && len(dockerComposeFile) > 0 {
|
||||
return fmt.Errorf("no compose file found: %v", dockerComposeFile)
|
||||
}
|
||||
|
||||
// go to the root of the project
|
||||
if err := os.Chdir(filepath.Dir(dockerComposeFile[0])); err != nil {
|
||||
if err := os.Chdir(filepath.Dir(existingFiles[0])); err != nil {
|
||||
logger.Failure(err.Error())
|
||||
return err
|
||||
}
|
||||
@@ -123,12 +133,12 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
|
||||
}()
|
||||
|
||||
// repove the directory part of the docker-compose files
|
||||
for i, f := range dockerComposeFile {
|
||||
dockerComposeFile[i] = filepath.Base(f)
|
||||
for i, f := range existingFiles {
|
||||
existingFiles[i] = filepath.Base(f)
|
||||
}
|
||||
|
||||
// parse the compose files
|
||||
project, err := parser.Parse(config.Profiles, config.EnvFiles, dockerComposeFile...)
|
||||
project, err := parser.Parse(config.Profiles, config.EnvFiles, existingFiles...)
|
||||
if err != nil {
|
||||
logger.Failure("Cannot parse compose files", err.Error())
|
||||
return err
|
||||
@@ -206,6 +216,10 @@ func Convert(config ConvertOptions, dockerComposeFile ...string) error {
|
||||
|
||||
// call helm update if needed
|
||||
callHelmUpdate(config)
|
||||
|
||||
// flush warnings after all conversion is complete
|
||||
logger.FlushWarnings()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -596,7 +610,7 @@ func callHelmUpdate(config ConvertOptions) {
|
||||
func removeNewlinesInsideBrackets(values []byte) []byte {
|
||||
re, err := regexp.Compile(`(?s)\{\{(.*?)\}\}`)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
return re.ReplaceAllFunc(values, func(b []byte) []byte {
|
||||
// get the first match
|
||||
@@ -635,7 +649,7 @@ func writeContent(path string, content []byte) {
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if _, err := f.Write(content); err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"katenary.io/internal/generator/labels"
|
||||
"katenary.io/internal/generator/labels/labelstructs"
|
||||
"katenary.io/internal/logger"
|
||||
"katenary.io/internal/utils"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
@@ -33,7 +33,7 @@ func NewCronJob(service types.ServiceConfig, chart *HelmChart, appName string) (
|
||||
}
|
||||
mapping, err := labelstructs.CronJobFrom(labels)
|
||||
if err != nil {
|
||||
log.Fatalf("Error parsing cronjob labels: %s", err)
|
||||
logger.Fatalf("Error parsing cronjob labels: %s", err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -20,6 +19,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const shCommand = "/bin/sh"
|
||||
|
||||
var _ Yaml = (*Deployment)(nil)
|
||||
|
||||
type mountPathConfig struct {
|
||||
@@ -43,6 +44,7 @@ type Deployment struct {
|
||||
isMainApp bool `yaml:"-"`
|
||||
exchangesVolumes map[string]*labelstructs.ExchangeVolume `yaml:"-"`
|
||||
boundEnvVar []string `yaml:"-"` // environement to remove
|
||||
needsServiceAccount bool `yaml:"-"`
|
||||
}
|
||||
|
||||
// NewDeployment creates a new Deployment from a compose service. The appName is the name of the application taken from the project name.
|
||||
@@ -166,7 +168,7 @@ func (d *Deployment) AddHealthCheck(service types.ServiceConfig, container *core
|
||||
if v, ok := service.Labels[labels.LabelHealthCheck]; ok {
|
||||
probes, err := labelstructs.ProbeFrom(v)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
container.LivenessProbe = probes.LivenessProbe
|
||||
container.ReadinessProbe = probes.ReadinessProbe
|
||||
@@ -201,7 +203,7 @@ func (d *Deployment) AddVolumes(service types.ServiceConfig, appName string) {
|
||||
if v, ok := service.Labels[labels.LabelConfigMapFiles]; ok {
|
||||
binds, err := labelstructs.ConfigMapFileFrom(v)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
for _, bind := range binds {
|
||||
tobind[bind] = true
|
||||
@@ -263,26 +265,38 @@ func (d *Deployment) BindFrom(service types.ServiceConfig, binded *Deployment) {
|
||||
|
||||
// DependsOn adds a initContainer to the deployment that will wait for the service to be up.
|
||||
func (d *Deployment) DependsOn(to *Deployment, servicename string) error {
|
||||
// Add a initContainer with busybox:latest using netcat to check if the service is up
|
||||
// it will wait until the service responds to all ports
|
||||
logger.Info("Adding dependency from ", d.service.Name, " to ", to.service.Name)
|
||||
|
||||
useLegacy := false
|
||||
if label, ok := d.service.Labels[labels.LabelDependsOn]; ok {
|
||||
useLegacy = strings.ToLower(label) == "legacy"
|
||||
}
|
||||
|
||||
if useLegacy {
|
||||
return d.dependsOnLegacy(to, servicename)
|
||||
}
|
||||
|
||||
d.needsServiceAccount = true
|
||||
return d.dependsOnK8sAPI(to)
|
||||
}
|
||||
|
||||
func (d *Deployment) dependsOnLegacy(to *Deployment, servicename string) error {
|
||||
for _, container := range to.Spec.Template.Spec.Containers {
|
||||
commands := []string{}
|
||||
if len(container.Ports) == 0 {
|
||||
logger.Warn("No ports found for service ",
|
||||
logger.Fatal("No ports found for service ",
|
||||
servicename,
|
||||
". You should declare a port in the service or use "+
|
||||
labels.LabelPorts+
|
||||
" label.",
|
||||
)
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, port := range container.Ports {
|
||||
command := fmt.Sprintf("until nc -z %s %d; do\n sleep 1;\ndone", to.Name, port.ContainerPort)
|
||||
commands = append(commands, command)
|
||||
}
|
||||
|
||||
command := []string{"/bin/sh", "-c", strings.Join(commands, "\n")}
|
||||
command := []string{shCommand, "-c", strings.Join(commands, "\n")}
|
||||
d.Spec.Template.Spec.InitContainers = append(d.Spec.Template.Spec.InitContainers, corev1.Container{
|
||||
Name: "wait-for-" + to.service.Name,
|
||||
Image: "busybox:latest",
|
||||
@@ -293,6 +307,39 @@ func (d *Deployment) DependsOn(to *Deployment, servicename string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Deployment) dependsOnK8sAPI(to *Deployment) error {
|
||||
script := `NAMESPACE=${NAMESPACE:-default}
|
||||
DEPLOYMENT_NAME=%s
|
||||
KUBERNETES_SERVICE_HOST=${KUBERNETES_SERVICE_HOST:-kubernetes.default.svc}
|
||||
KUBERNETES_SERVICE_PORT=${KUBERNETES_SERVICE_PORT:-443}
|
||||
|
||||
until curl -s -o- --header="Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
|
||||
--cacert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
|
||||
"https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/apis/apps/v1/namespaces/${NAMESPACE}/deployments/${DEPLOYMENT_NAME}" \
|
||||
| grep -q '"readyReplicas":\s*[1-9][0-9]*'; do
|
||||
sleep 2
|
||||
done`
|
||||
|
||||
command := []string{shCommand, "-c", fmt.Sprintf(script, to.Name)}
|
||||
d.Spec.Template.Spec.InitContainers = append(d.Spec.Template.Spec.InitContainers, corev1.Container{
|
||||
Name: "wait-for-" + to.service.Name,
|
||||
Image: "quay.io/curl/curl:latest",
|
||||
Command: command,
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
Name: "NAMESPACE",
|
||||
ValueFrom: &corev1.EnvVarSource{
|
||||
FieldRef: &corev1.ObjectFieldSelector{
|
||||
FieldPath: "metadata.namespace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Filename returns the filename of the deployment.
|
||||
func (d *Deployment) Filename() string {
|
||||
return d.service.Name + ".deployment.yaml"
|
||||
@@ -311,7 +358,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
|
||||
defer func() {
|
||||
c, index := d.BindMapFilesToContainer(service, secrets, appName)
|
||||
if c == nil || index == -1 {
|
||||
log.Println("Container not found for service ", service.Name)
|
||||
logger.Warn("Container not found for service ", service.Name)
|
||||
return
|
||||
}
|
||||
d.Spec.Template.Spec.Containers[index] = *c
|
||||
@@ -320,7 +367,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
|
||||
// secrets from label
|
||||
labelSecrets, err := labelstructs.SecretsFrom(service.Labels[labels.LabelSecrets])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
// values from label
|
||||
@@ -335,7 +382,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
|
||||
_, ok := service.Environment[secret]
|
||||
if !ok {
|
||||
drop = append(drop, secret)
|
||||
logger.Warn("Secret " + secret + " not found in service " + service.Name + " - skpped")
|
||||
logger.Warn("Secret " + secret + " not found in service " + service.Name + " - skipped")
|
||||
continue
|
||||
}
|
||||
secrets = append(secrets, secret)
|
||||
@@ -352,7 +399,7 @@ func (d *Deployment) SetEnvFrom(service types.ServiceConfig, appName string, sam
|
||||
val, ok := service.Environment[value]
|
||||
if !ok {
|
||||
drop = append(drop, value)
|
||||
logger.Warn("Environment variable " + value + " not found in service " + service.Name + " - skpped")
|
||||
logger.Warn("Environment variable " + value + " not found in service " + service.Name + " - skipped")
|
||||
continue
|
||||
}
|
||||
if d.chart.Values[service.Name].(*Value).Environment == nil {
|
||||
@@ -384,8 +431,8 @@ func (d *Deployment) BindMapFilesToContainer(service types.ServiceConfig, secret
|
||||
|
||||
if envSize > 0 {
|
||||
if service.Name == "db" {
|
||||
log.Println("Service ", service.Name, " has environment variables")
|
||||
log.Println(service.Environment)
|
||||
logger.Info("Service ", service.Name, " has environment variables")
|
||||
logger.Info(service.Environment)
|
||||
}
|
||||
fromSources = append(fromSources, corev1.EnvFromSource{
|
||||
ConfigMapRef: &corev1.ConfigMapEnvSource{
|
||||
@@ -568,7 +615,7 @@ func (d *Deployment) Yaml() ([]byte, error) {
|
||||
}
|
||||
|
||||
// manage serviceAccount, add condition to use the serviceAccount from values.yaml
|
||||
if strings.Contains(line, "serviceAccountName:") {
|
||||
if strings.Contains(line, "serviceAccountName:") && !d.needsServiceAccount {
|
||||
spaces = strings.Repeat(" ", utils.CountStartingSpaces(line))
|
||||
pre := spaces + `{{- if ne .Values.` + serviceName + `.serviceAccount "" }}`
|
||||
post := spaces + "{{- end }}"
|
||||
@@ -604,6 +651,12 @@ func (d *Deployment) Yaml() ([]byte, error) {
|
||||
return []byte(strings.Join(content, "\n")), nil
|
||||
}
|
||||
|
||||
func (d *Deployment) SetServiceAccountName() {
|
||||
if d.needsServiceAccount {
|
||||
d.Spec.Template.Spec.ServiceAccountName = utils.TplName(d.service.Name, d.chart.Name, "dependency")
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Deployment) appendDirectoryToConfigMap(service types.ServiceConfig, appName string, volume types.ServiceVolumeConfig) {
|
||||
pathnme := utils.PathToName(volume.Source)
|
||||
if _, ok := d.configMaps[pathnme]; !ok {
|
||||
@@ -615,7 +668,7 @@ func (d *Deployment) appendDirectoryToConfigMap(service types.ServiceConfig, app
|
||||
// TODO: make it recursive to add all files in the directory and subdirectories
|
||||
_, err := os.ReadDir(volume.Source)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
cm := NewConfigMapFromDirectory(service, appName, volume.Source)
|
||||
d.configMaps[pathnme] = &ConfigMapMount{
|
||||
@@ -660,7 +713,7 @@ func (d *Deployment) appendFileToConfigMap(service types.ServiceConfig, appName
|
||||
|
||||
}
|
||||
if err := cm.AppendFile(volume.Source); err != nil {
|
||||
log.Fatal("Error adding file to configmap:", err)
|
||||
logger.Fatal("Error adding file to configmap:", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,7 +774,7 @@ func (d *Deployment) bindVolumes(volume types.ServiceVolumeConfig, tobind map[st
|
||||
// Add volume to container
|
||||
stat, err := os.Stat(volume.Source)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
if stat.IsDir() {
|
||||
|
||||
@@ -3,6 +3,7 @@ package generator
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
yaml3 "gopkg.in/yaml.v3"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
@@ -142,6 +144,90 @@ services:
|
||||
if len(dt.Spec.Template.Spec.InitContainers) != 1 {
|
||||
t.Errorf("Expected 1 init container, got %d", len(dt.Spec.Template.Spec.InitContainers))
|
||||
}
|
||||
|
||||
initContainer := dt.Spec.Template.Spec.InitContainers[0]
|
||||
if !strings.Contains(initContainer.Image, "quay.io/curl/curl") {
|
||||
t.Errorf("Expected quay.io/curl/curl image, got %s", initContainer.Image)
|
||||
}
|
||||
|
||||
fullCommand := strings.Join(initContainer.Command, " ")
|
||||
if !strings.Contains(fullCommand, "curl") {
|
||||
t.Errorf("Expected curl command (K8s API method), got %s", fullCommand)
|
||||
}
|
||||
|
||||
if !strings.Contains(fullCommand, "/apis/apps/v1/namespaces/") {
|
||||
t.Errorf("Expected Kubernetes API call to /apis/apps/v1/namespaces/, got %s", fullCommand)
|
||||
}
|
||||
|
||||
if !strings.Contains(fullCommand, "/deployments/") {
|
||||
t.Errorf("Expected Kubernetes API call to /deployments/, got %s", fullCommand)
|
||||
}
|
||||
|
||||
if !strings.Contains(fullCommand, "readyReplicas") {
|
||||
t.Errorf("Expected readyReplicas check, got %s", fullCommand)
|
||||
}
|
||||
|
||||
if len(initContainer.Env) == 0 {
|
||||
t.Errorf("Expected environment variables to be set for namespace")
|
||||
}
|
||||
|
||||
hasNamespace := false
|
||||
for _, env := range initContainer.Env {
|
||||
if env.Name == "NAMESPACE" && env.ValueFrom != nil && env.ValueFrom.FieldRef != nil {
|
||||
if env.ValueFrom.FieldRef.FieldPath == "metadata.namespace" {
|
||||
hasNamespace = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !hasNamespace {
|
||||
t.Errorf("Expected NAMESPACE env var with metadata.namespace fieldRef")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDependsOnLegacy(t *testing.T) {
|
||||
composeFile := `
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.29
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- database
|
||||
labels:
|
||||
katenary.v3/depends-on: legacy
|
||||
|
||||
database:
|
||||
image: mariadb:10.5
|
||||
ports:
|
||||
- 3306:3306
|
||||
`
|
||||
tmpDir := setup(composeFile)
|
||||
defer teardown(tmpDir)
|
||||
|
||||
currentDir, _ := os.Getwd()
|
||||
os.Chdir(tmpDir)
|
||||
defer os.Chdir(currentDir)
|
||||
|
||||
output := internalCompileTest(t, "-s", webTemplateOutput)
|
||||
dt := v1.Deployment{}
|
||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
|
||||
if len(dt.Spec.Template.Spec.InitContainers) != 1 {
|
||||
t.Errorf("Expected 1 init container, got %d", len(dt.Spec.Template.Spec.InitContainers))
|
||||
}
|
||||
|
||||
initContainer := dt.Spec.Template.Spec.InitContainers[0]
|
||||
if !strings.Contains(initContainer.Image, "busybox") {
|
||||
t.Errorf("Expected busybox image, got %s", initContainer.Image)
|
||||
}
|
||||
|
||||
fullCommand := strings.Join(initContainer.Command, " ")
|
||||
if !strings.Contains(fullCommand, "nc") {
|
||||
t.Errorf("Expected nc (netcat) command for legacy method, got %s", fullCommand)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelmDependencies(t *testing.T) {
|
||||
@@ -563,3 +649,195 @@ services:
|
||||
t.Errorf("Expected command to be 'bar baz', got %s", strings.Join(command, " "))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestrictedRBACGeneration(t *testing.T) {
|
||||
composeFile := `
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.29
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
database:
|
||||
image: mariadb:10.5
|
||||
ports:
|
||||
- 3306:3306
|
||||
`
|
||||
tmpDir := setup(composeFile)
|
||||
defer teardown(tmpDir)
|
||||
|
||||
currentDir, _ := os.Getwd()
|
||||
os.Chdir(tmpDir)
|
||||
defer os.Chdir(currentDir)
|
||||
|
||||
rbacOutput := internalCompileTest(t, "-s", "templates/web/depends-on.rbac.yaml")
|
||||
|
||||
docs := strings.Split(rbacOutput, "---\n")
|
||||
|
||||
// Filter out empty documents and strip helm template comments
|
||||
var filteredDocs []string
|
||||
for _, doc := range docs {
|
||||
if strings.TrimSpace(doc) != "" {
|
||||
// Remove '# Source:' comment lines that helm template adds
|
||||
lines := strings.Split(doc, "\n")
|
||||
var contentLines []string
|
||||
for _, line := range lines {
|
||||
if !strings.HasPrefix(strings.TrimSpace(line), "# Source:") {
|
||||
contentLines = append(contentLines, line)
|
||||
}
|
||||
}
|
||||
filteredDocs = append(filteredDocs, strings.Join(contentLines, "\n"))
|
||||
}
|
||||
}
|
||||
|
||||
if len(filteredDocs) != 3 {
|
||||
t.Fatalf("Expected 3 YAML documents in RBAC file, got %d (filtered from %d)", len(filteredDocs), len(docs))
|
||||
}
|
||||
|
||||
var sa corev1.ServiceAccount
|
||||
if err := yaml.Unmarshal([]byte(strings.TrimSpace(filteredDocs[0])), &sa); err != nil {
|
||||
t.Errorf("Failed to unmarshal ServiceAccount: %v", err)
|
||||
}
|
||||
if sa.Kind != "ServiceAccount" {
|
||||
t.Errorf("Expected Kind=ServiceAccount, got %s", sa.Kind)
|
||||
}
|
||||
if !strings.Contains(sa.Name, "web") {
|
||||
t.Errorf("Expected ServiceAccount name to contain 'web', got %s", sa.Name)
|
||||
}
|
||||
|
||||
var role rbacv1.Role
|
||||
if err := yaml.Unmarshal([]byte(strings.TrimSpace(filteredDocs[1])), &role); err != nil {
|
||||
t.Errorf("Failed to unmarshal Role: %v", err)
|
||||
}
|
||||
if role.Kind != "Role" {
|
||||
t.Errorf("Expected Kind=Role, got %s", role.Kind)
|
||||
}
|
||||
if len(role.Rules) != 1 {
|
||||
t.Errorf("Expected 1 rule in Role, got %d", len(role.Rules))
|
||||
}
|
||||
|
||||
rule := role.Rules[0]
|
||||
if !contains(rule.APIGroups, "apps") {
|
||||
t.Error("Expected APIGroup to include 'apps'")
|
||||
}
|
||||
if !contains(rule.Resources, "deployments") {
|
||||
t.Errorf("Expected Resource to include 'deployments', got %v", rule.Resources)
|
||||
}
|
||||
|
||||
for _, res := range rule.Resources {
|
||||
if res == "*" {
|
||||
t.Error("Role should not have wildcard (*) resource permissions")
|
||||
}
|
||||
}
|
||||
for _, verb := range rule.Verbs {
|
||||
if verb == "*" {
|
||||
t.Error("Role should not have wildcard (*) verb permissions")
|
||||
}
|
||||
}
|
||||
|
||||
var rb rbacv1.RoleBinding
|
||||
if err := yaml.Unmarshal([]byte(strings.TrimSpace(filteredDocs[2])), &rb); err != nil {
|
||||
t.Errorf("Failed to unmarshal RoleBinding: %v", err)
|
||||
}
|
||||
if rb.Kind != "RoleBinding" {
|
||||
t.Errorf("Expected Kind=RoleBinding, got %s", rb.Kind)
|
||||
}
|
||||
if len(rb.Subjects) != 1 {
|
||||
t.Errorf("Expected 1 subject in RoleBinding, got %d", len(rb.Subjects))
|
||||
}
|
||||
if rb.Subjects[0].Kind != "ServiceAccount" {
|
||||
t.Errorf("Expected Subject Kind=ServiceAccount, got %s", rb.Subjects[0].Kind)
|
||||
}
|
||||
|
||||
// Helm template renders the name, so check if it contains "web"
|
||||
if !strings.Contains(rb.RoleRef.Name, "web") {
|
||||
t.Errorf("Expected RoleRef Name to contain 'web', got %s", rb.RoleRef.Name)
|
||||
}
|
||||
if rb.RoleRef.Kind != "Role" {
|
||||
t.Errorf("Expected RoleRef Kind=Role, got %s", rb.RoleRef.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeploymentReferencesServiceAccount(t *testing.T) {
|
||||
composeFile := `
|
||||
services:
|
||||
web:
|
||||
image: nginx:1.29
|
||||
ports:
|
||||
- 80:80
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
database:
|
||||
image: mariadb:10.5
|
||||
ports:
|
||||
- 3306:3306
|
||||
`
|
||||
tmpDir := setup(composeFile)
|
||||
defer teardown(tmpDir)
|
||||
|
||||
currentDir, _ := os.Getwd()
|
||||
os.Chdir(tmpDir)
|
||||
defer os.Chdir(currentDir)
|
||||
|
||||
output := internalCompileTest(t, "-s", "templates/web/deployment.yaml")
|
||||
|
||||
var dt v1.Deployment
|
||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||
t.Errorf("Failed to unmarshal Deployment: %v", err)
|
||||
}
|
||||
|
||||
serviceAccountName := dt.Spec.Template.Spec.ServiceAccountName
|
||||
if !strings.Contains(serviceAccountName, "web") {
|
||||
t.Errorf("Expected ServiceAccountName to contain 'web', got %s", serviceAccountName)
|
||||
}
|
||||
|
||||
if len(dt.Spec.Template.Spec.InitContainers) == 0 {
|
||||
t.Fatal("Expected at least one init container for depends_on")
|
||||
}
|
||||
|
||||
initContainer := dt.Spec.Template.Spec.InitContainers[0]
|
||||
if initContainer.Name != "wait-for-database" {
|
||||
t.Errorf("Expected init container name 'wait-for-database', got %s", initContainer.Name)
|
||||
}
|
||||
|
||||
fullCommand := strings.Join(initContainer.Command, " ")
|
||||
if !strings.Contains(fullCommand, "curl") {
|
||||
t.Error("Expected init container to use curl for K8s API calls")
|
||||
}
|
||||
if !strings.Contains(fullCommand, "/apis/apps/v1/namespaces/") {
|
||||
t.Error("Expected init container to call /apis/apps/v1/namespaces/ endpoint")
|
||||
}
|
||||
if !strings.Contains(fullCommand, "/deployments/") {
|
||||
t.Error("Expected init container to access /deployments/ resource")
|
||||
}
|
||||
if !strings.Contains(fullCommand, "readyReplicas") {
|
||||
t.Error("Expected init container to check readyReplicas")
|
||||
}
|
||||
|
||||
hasNamespace := false
|
||||
for _, env := range initContainer.Env {
|
||||
if env.Name == "NAMESPACE" && env.ValueFrom != nil && env.ValueFrom.FieldRef != nil {
|
||||
if env.ValueFrom.FieldRef.FieldPath == "metadata.namespace" {
|
||||
hasNamespace = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !hasNamespace {
|
||||
t.Error("Expected NAMESPACE env var with metadata.namespace fieldRef")
|
||||
}
|
||||
|
||||
_, err := os.Stat("./chart/templates/web/depends-on.rbac.yaml")
|
||||
if os.IsNotExist(err) {
|
||||
t.Error("RBAC file depends-on.rbac.yaml should exist for service using depends_on with K8s API")
|
||||
} else if err != nil {
|
||||
t.Errorf("Unexpected error checking RBAC file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func contains(slice []string, item string) bool {
|
||||
return slices.Contains(slice, item)
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
"katenary.io/internal/logger"
|
||||
)
|
||||
|
||||
//go:embed readme.tpl
|
||||
@@ -50,7 +50,7 @@ func ReadMeFile(charname, description string, values map[string]any) string {
|
||||
vv := map[string]any{}
|
||||
out, _ := yaml.Marshal(values)
|
||||
if err := yaml.Unmarshal(out, &vv); err != nil {
|
||||
log.Printf("Error parsing values: %s", err)
|
||||
logger.Warnf("Error parsing values: %s", err)
|
||||
}
|
||||
|
||||
result := make(map[string]string)
|
||||
|
||||
@@ -3,7 +3,6 @@ package generator
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -23,7 +22,7 @@ import (
|
||||
// The Generate function will create the HelmChart object this way:
|
||||
//
|
||||
// - Detect the service port name or leave the port number if not found.
|
||||
// - Create a deployment for each service that are not ingnore.
|
||||
// - Create a deployment for each service that are not ingore.
|
||||
// - Create a service and ingresses for each service that has ports and/or declared ingresses.
|
||||
// - Create a PVC or Configmap volumes for each volume.
|
||||
// - Create init containers for each service which has dependencies to other services.
|
||||
@@ -135,6 +134,23 @@ func Generate(project *types.Project) (*HelmChart, error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// warn users if dependent service has no ports
|
||||
for _, s := range project.Services {
|
||||
for _, d := range s.GetDependencies() {
|
||||
if dep, ok := deployments[d]; ok {
|
||||
if len(dep.service.Ports) == 0 {
|
||||
logger.Warnf("Service %s is used in depends_on but has no ports declared. No Kubernetes Service will be created for it. Add katenary.v3/ports label if you need to create a Service.", d)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set ServiceAccountName for deployments that need it
|
||||
for _, d := range deployments {
|
||||
d.SetServiceAccountName()
|
||||
}
|
||||
|
||||
for _, name := range drops {
|
||||
delete(deployments, name)
|
||||
}
|
||||
@@ -143,9 +159,14 @@ func Generate(project *types.Project) (*HelmChart, error) {
|
||||
chart.setEnvironmentValuesFrom(s, deployments)
|
||||
}
|
||||
|
||||
// generate RBAC resources for services that need K8s API access (non-legacy depends_on)
|
||||
if err := chart.generateRBAC(deployments); err != nil {
|
||||
logger.Fatalf("error generating RBAC: %s", err)
|
||||
}
|
||||
|
||||
// generate configmaps with environment variables
|
||||
if err := chart.generateConfigMapsAndSecrets(project); err != nil {
|
||||
log.Fatalf("error generating configmaps and secrets: %s", err)
|
||||
logger.Fatalf("error generating configmaps and secrets: %s", err)
|
||||
}
|
||||
|
||||
// if the env-from label is set, we need to add the env vars from the configmap
|
||||
@@ -280,7 +301,7 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
|
||||
var d *Deployment
|
||||
var ok bool
|
||||
if d, ok = deployments[service.Name]; !ok {
|
||||
log.Printf("service %s not found in deployments", service.Name)
|
||||
logger.Warnf("service %s not found in deployments", service.Name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -292,7 +313,7 @@ func addStaticVolumes(deployments map[string]*Deployment, service types.ServiceC
|
||||
var y []byte
|
||||
var err error
|
||||
if y, err = config.configMap.Yaml(); err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
// add the configmap to the chart
|
||||
@@ -434,13 +455,65 @@ func samePodVolume(service types.ServiceConfig, v types.ServiceVolumeConfig, dep
|
||||
// check if it has the same volume
|
||||
for _, tv := range target.Spec.Template.Spec.Volumes {
|
||||
if tv.Name == v.Source {
|
||||
log.Printf("found same pod volume %s in deployment %s and %s", tv.Name, service.Name, targetDeployment)
|
||||
logger.Warnf("found same pod volume %s in deployment %s and %s", tv.Name, service.Name, targetDeployment)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// generateRBAC creates RBAC resources (ServiceAccount, Role, RoleBinding) for services that need K8s API access.
|
||||
// A service needs RBAC if it has non-legacy depends_on relationships.
|
||||
func (chart *HelmChart) generateRBAC(deployments map[string]*Deployment) error {
|
||||
serviceMap := make(map[string]bool)
|
||||
|
||||
for _, d := range deployments {
|
||||
if !d.needsServiceAccount {
|
||||
continue
|
||||
}
|
||||
|
||||
sa := NewServiceAccount(*d.service, chart.Name)
|
||||
role := NewRestrictedRole(*d.service, chart.Name)
|
||||
rb := NewRestrictedRoleBinding(*d.service, chart.Name)
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
saYaml, err := yaml.Marshal(sa.ServiceAccount)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling ServiceAccount for %s: %w", d.service.Name, err)
|
||||
}
|
||||
buf.Write(saYaml)
|
||||
buf.WriteString("---\n")
|
||||
|
||||
roleYaml, err := yaml.Marshal(role.Role)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling Role for %s: %w", d.service.Name, err)
|
||||
}
|
||||
buf.Write(roleYaml)
|
||||
buf.WriteString("---\n")
|
||||
|
||||
rbYaml, err := yaml.Marshal(rb.RoleBinding)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error marshaling RoleBinding for %s: %w", d.service.Name, err)
|
||||
}
|
||||
buf.Write(rbYaml)
|
||||
|
||||
filename := d.service.Name + "/depends-on.rbac.yaml"
|
||||
chart.Templates[filename] = &ChartTemplate{
|
||||
Content: buf.Bytes(),
|
||||
Servicename: d.service.Name,
|
||||
}
|
||||
|
||||
serviceMap[d.service.Name] = true
|
||||
}
|
||||
|
||||
for svcName := range serviceMap {
|
||||
logger.Log(logger.IconPackage, "Creating RBAC", svcName)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func fixContainerNames(project *types.Project) {
|
||||
// fix container names to be unique
|
||||
for i, service := range project.Services {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"katenary.io/internal/generator/labels"
|
||||
"katenary.io/internal/generator/labels/labelstructs"
|
||||
"katenary.io/internal/logger"
|
||||
"katenary.io/internal/utils"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
@@ -36,7 +36,7 @@ func NewIngress(service types.ServiceConfig, Chart *HelmChart) *Ingress {
|
||||
|
||||
mapping, err := labelstructs.IngressFrom(label)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse ingress label: %s\n", err)
|
||||
logger.Fatalf("Failed to parse ingress label: %s\n", err)
|
||||
}
|
||||
if mapping.Hostname == "" {
|
||||
mapping.Hostname = service.Name + ".tld"
|
||||
|
||||
@@ -3,7 +3,6 @@ package katenaryfile
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -67,7 +66,7 @@ func OverrideWithConfig(project *types.Project) {
|
||||
return
|
||||
}
|
||||
if err := yaml.NewDecoder(fp).Decode(&services); err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
return
|
||||
}
|
||||
for _, p := range project.Services {
|
||||
@@ -79,7 +78,7 @@ func OverrideWithConfig(project *types.Project) {
|
||||
}
|
||||
err := getLabelContent(o, &s, labelName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
project.Services[name] = s
|
||||
}
|
||||
@@ -113,7 +112,7 @@ func getLabelContent(o any, service *types.ServiceConfig, labelName string) erro
|
||||
|
||||
c, err := yaml.Marshal(o)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
logger.Failure(err.Error())
|
||||
return err
|
||||
}
|
||||
val := strings.TrimSpace(string(c))
|
||||
@@ -121,7 +120,7 @@ func getLabelContent(o any, service *types.ServiceConfig, labelName string) erro
|
||||
// special case, values must be set from some defaults
|
||||
ing, err := labelstructs.IngressFrom(val)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
return err
|
||||
}
|
||||
c, err := yaml.Marshal(ing)
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
"bytes"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"text/template"
|
||||
|
||||
"katenary.io/internal/logger"
|
||||
"katenary.io/internal/utils"
|
||||
|
||||
"sigs.k8s.io/yaml"
|
||||
@@ -36,6 +36,7 @@ const (
|
||||
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||
LabelValuesFrom Label = KatenaryLabelPrefix + "/values-from"
|
||||
LabelDependsOn Label = KatenaryLabelPrefix + "/depends-on"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -134,7 +135,7 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string {
|
||||
KatenaryPrefix: KatenaryLabelPrefix,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Error executing template: %v", err)
|
||||
logger.Fatalf("Error executing template: %v", err)
|
||||
}
|
||||
help.Long = buf.String()
|
||||
buf.Reset()
|
||||
@@ -145,7 +146,7 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string {
|
||||
KatenaryPrefix: KatenaryLabelPrefix,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Error executing template: %v", err)
|
||||
logger.Fatalf("Error executing template: %v", err)
|
||||
}
|
||||
help.Example = buf.String()
|
||||
buf.Reset()
|
||||
@@ -160,7 +161,7 @@ func GetLabelHelpFor(labelname string, asMarkdown bool) string {
|
||||
KatenaryPrefix: KatenaryLabelPrefix,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("Error executing template: %v", err)
|
||||
logger.Fatalf("Error executing template: %v", err)
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
|
||||
@@ -92,7 +92,12 @@
|
||||
short: "Ports to be added to the service."
|
||||
long: |-
|
||||
Only useful for services without exposed port. It is mandatory if the
|
||||
service is a dependency of another service.
|
||||
service is a dependency of another service AND you want to create a
|
||||
Kubernetes Service for external access.
|
||||
|
||||
If you only need to check if the service is ready (using depends_on),
|
||||
you don't need to declare ports. The service will not be created automatically
|
||||
unless you add this label.
|
||||
example: |-
|
||||
labels:
|
||||
{{ .KatenaryPrefix }}/ports: |-
|
||||
@@ -355,4 +360,36 @@
|
||||
DB_USER: database.MARIADB_USER
|
||||
DB_PASSWORD: database.MARIADB_PASSWORD
|
||||
|
||||
"depends-on":
|
||||
short: "Method to check if a service is ready (for depends_on)."
|
||||
long: |-
|
||||
When a service uses `depends_on`, Katenary creates an initContainer to wait
|
||||
for the dependent service to be ready.
|
||||
|
||||
By default, Katenary uses the Kubernetes API to check if the deployment's
|
||||
`readyReplicas` status is greater than 0. This method does not require the
|
||||
service to expose a port and does not create a Kubernetes Service automatically.
|
||||
|
||||
If you need to create a Kubernetes Service for external access, use the
|
||||
`katenary.v3/ports` label instead.
|
||||
|
||||
Set this label to `legacy` to use the old netcat method that requires a port
|
||||
to be defined for the dependent service.
|
||||
example: |-
|
||||
web:
|
||||
image: nginx
|
||||
depends_on:
|
||||
- database
|
||||
labels:
|
||||
# Use legacy netcat method (requires port)
|
||||
{{ .KatenaryPrefix }}/depends-on: legacy
|
||||
|
||||
database:
|
||||
image: mysql
|
||||
labels:
|
||||
# Create a Kubernetes Service for external access
|
||||
{{ .KatenaryPrefix }}/ports:
|
||||
- 3306
|
||||
type: "string"
|
||||
|
||||
# vim: ft=gotmpl.yaml
|
||||
|
||||
@@ -2,10 +2,10 @@ package labelstructs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"katenary.io/internal/logger"
|
||||
)
|
||||
|
||||
type HealthCheck struct {
|
||||
@@ -24,13 +24,13 @@ func ProbeFrom(data string) (*HealthCheck, error) {
|
||||
if livenessProbe, ok := tmp["livenessProbe"]; ok {
|
||||
livenessProbeBytes, err := json.Marshal(livenessProbe)
|
||||
if err != nil {
|
||||
log.Printf("Error marshalling livenessProbe: %v", err)
|
||||
logger.Warnf("Error marshalling livenessProbe: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
livenessProbe := &corev1.Probe{}
|
||||
err = json.Unmarshal(livenessProbeBytes, livenessProbe)
|
||||
if err != nil {
|
||||
log.Printf("Error unmarshalling livenessProbe: %v", err)
|
||||
logger.Warnf("Error unmarshalling livenessProbe: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
mapping.LivenessProbe = livenessProbe
|
||||
@@ -39,13 +39,13 @@ func ProbeFrom(data string) (*HealthCheck, error) {
|
||||
if readinessProbe, ok := tmp["readinessProbe"]; ok {
|
||||
readinessProbeBytes, err := json.Marshal(readinessProbe)
|
||||
if err != nil {
|
||||
log.Printf("Error marshalling readinessProbe: %v", err)
|
||||
logger.Warnf("Error marshalling readinessProbe: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
readinessProbe := &corev1.Probe{}
|
||||
err = json.Unmarshal(readinessProbeBytes, readinessProbe)
|
||||
if err != nil {
|
||||
log.Printf("Error unmarshalling readinessProbe: %v", err)
|
||||
logger.Warnf("Error unmarshalling readinessProbe: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
mapping.ReadinessProbe = readinessProbe
|
||||
|
||||
@@ -32,7 +32,7 @@ func NewRBAC(service types.ServiceConfig, appName string) *RBAC {
|
||||
APIVersion: "rbac.authorization.k8s.io/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: utils.TplName(service.Name, appName),
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
Labels: GetLabels(service.Name, appName),
|
||||
Annotations: Annotations,
|
||||
},
|
||||
@@ -128,6 +128,79 @@ func (r *Role) Yaml() ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// NewServiceAccount creates a new ServiceAccount from a compose service.
|
||||
func NewServiceAccount(service types.ServiceConfig, appName string) *ServiceAccount {
|
||||
return &ServiceAccount{
|
||||
ServiceAccount: &corev1.ServiceAccount{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "ServiceAccount",
|
||||
APIVersion: "v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
Labels: GetLabels(service.Name, appName),
|
||||
Annotations: Annotations,
|
||||
},
|
||||
},
|
||||
service: &service,
|
||||
}
|
||||
}
|
||||
|
||||
// NewRestrictedRole creates a Role with minimal permissions for init containers.
|
||||
func NewRestrictedRole(service types.ServiceConfig, appName string) *Role {
|
||||
return &Role{
|
||||
Role: &rbacv1.Role{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Role",
|
||||
APIVersion: "rbac.authorization.k8s.io/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
Labels: GetLabels(service.Name, appName),
|
||||
Annotations: Annotations,
|
||||
},
|
||||
Rules: []rbacv1.PolicyRule{
|
||||
{
|
||||
APIGroups: []string{"apps"},
|
||||
Resources: []string{"deployments"},
|
||||
Verbs: []string{"get"},
|
||||
},
|
||||
},
|
||||
},
|
||||
service: &service,
|
||||
}
|
||||
}
|
||||
|
||||
// NewRestrictedRoleBinding creates a RoleBinding that binds the restricted role to the ServiceAccount.
|
||||
func NewRestrictedRoleBinding(service types.ServiceConfig, appName string) *RoleBinding {
|
||||
return &RoleBinding{
|
||||
RoleBinding: &rbacv1.RoleBinding{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "RoleBinding",
|
||||
APIVersion: "rbac.authorization.k8s.io/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
Labels: GetLabels(service.Name, appName),
|
||||
Annotations: Annotations,
|
||||
},
|
||||
Subjects: []rbacv1.Subject{
|
||||
{
|
||||
Kind: "ServiceAccount",
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
Namespace: "{{ .Release.Namespace }}",
|
||||
},
|
||||
},
|
||||
RoleRef: rbacv1.RoleRef{
|
||||
Kind: "Role",
|
||||
Name: utils.TplName(service.Name, appName, "dependency"),
|
||||
APIGroup: "rbac.authorization.k8s.io",
|
||||
},
|
||||
},
|
||||
service: &service,
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceAccount is a kubernetes ServiceAccount.
|
||||
type ServiceAccount struct {
|
||||
*corev1.ServiceAccount
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"katenary.io/internal/logger"
|
||||
"katenary.io/internal/parser"
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ func setup(content string) string {
|
||||
|
||||
func teardown(tmpDir string) {
|
||||
// remove the temporary directory
|
||||
log.Println("Removing temporary directory: ", tmpDir)
|
||||
logger.Info("Removing temporary directory: ", tmpDir)
|
||||
if err := os.RemoveAll(tmpDir); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func compileTest(t *testing.T, force bool, options ...string) string {
|
||||
ChartVersion: chartVersion,
|
||||
}
|
||||
if err := Convert(convertOptions, "compose.yml"); err != nil {
|
||||
log.Printf("Failed to convert: %s", err)
|
||||
logger.Warnf("Failed to convert: %s", err)
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
// Package logger provides simple logging functions with icons and colors.
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Icon is a unicode icon
|
||||
type Icon string
|
||||
|
||||
@@ -22,30 +28,117 @@ const (
|
||||
|
||||
const reset = "\033[0m"
|
||||
|
||||
const (
|
||||
ColorGreen = "\033[38;5;34m"
|
||||
ColorRed = "\033[38;5;196m"
|
||||
ColorOrange = "\033[38;5;214m"
|
||||
ColorWarning = "\033[38;5;214m"
|
||||
)
|
||||
|
||||
var (
|
||||
warnings []string
|
||||
mu sync.Mutex
|
||||
)
|
||||
|
||||
// Print prints a message without icon.
|
||||
func Print(msg ...any) {
|
||||
fmt.Print(msg...)
|
||||
}
|
||||
|
||||
// Printf prints a formatted message without icon.
|
||||
func Printf(format string, msg ...any) {
|
||||
fmt.Printf(format, msg...)
|
||||
}
|
||||
|
||||
// Info prints an informational message.
|
||||
func Info(msg ...any) {
|
||||
message("", IconInfo, msg...)
|
||||
}
|
||||
|
||||
// Infof prints a formatted informational message.
|
||||
func Infof(format string, msg ...any) {
|
||||
message("", IconInfo, fmt.Sprintf(format, msg...))
|
||||
}
|
||||
|
||||
// Warn prints a warning message.
|
||||
func Warn(msg ...any) {
|
||||
orange := "\033[38;5;214m"
|
||||
message(orange, IconWarning, msg...)
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
warning := fmt.Sprint(msg...)
|
||||
warnings = append(warnings, warning)
|
||||
}
|
||||
|
||||
// Warnf prints a formatted warning message.
|
||||
func Warnf(format string, msg ...any) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
warning := fmt.Sprintf(format, msg...)
|
||||
warnings = append(warnings, warning)
|
||||
}
|
||||
|
||||
// Success prints a success message.
|
||||
func Success(msg ...any) {
|
||||
green := "\033[38;5;34m"
|
||||
message(green, IconSuccess, msg...)
|
||||
message(ColorGreen, IconSuccess, msg...)
|
||||
}
|
||||
|
||||
// Successf prints a formatted success message.
|
||||
func Successf(format string, msg ...any) {
|
||||
message(ColorGreen, IconSuccess, fmt.Sprintf(format, msg...))
|
||||
}
|
||||
|
||||
// Failure prints a failure message.
|
||||
func Failure(msg ...any) {
|
||||
red := "\033[38;5;196m"
|
||||
message(red, IconFailure, msg...)
|
||||
message(ColorRed, IconFailure, msg...)
|
||||
}
|
||||
|
||||
// Failuref prints a formatted failure message.
|
||||
func Failuref(format string, msg ...any) {
|
||||
message(ColorRed, IconFailure, fmt.Sprintf(format, msg...))
|
||||
}
|
||||
|
||||
// Log prints a message with a custom icon.
|
||||
func Log(icon Icon, msg ...any) {
|
||||
message("", icon, msg...)
|
||||
}
|
||||
|
||||
// Logf prints a formatted message with a custom icon.
|
||||
func Logf(icon Icon, format string, msg ...any) {
|
||||
message("", icon, fmt.Sprintf(format, msg...))
|
||||
}
|
||||
|
||||
func fatal(red string, icon Icon, msg ...any) {
|
||||
fmt.Print(icon, " ", red)
|
||||
fmt.Print(msg...)
|
||||
fmt.Println(reset)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func fatalf(red string, icon Icon, format string, msg ...any) {
|
||||
fatal(red, icon, fmt.Sprintf(format, msg...))
|
||||
}
|
||||
|
||||
// Fatal prints a fatal error message and exits with code 1.
|
||||
func Fatal(msg ...any) {
|
||||
fatal(ColorRed, IconFailure, msg...)
|
||||
}
|
||||
|
||||
// Fatalf prints a fatal error message with formatting and exits with code 1.
|
||||
func Fatalf(format string, msg ...any) {
|
||||
fatalf(ColorRed, IconFailure, format, msg...)
|
||||
}
|
||||
|
||||
// FlushWarnings prints all collected warnings at the end of the conversion.
|
||||
func FlushWarnings() {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if len(warnings) > 0 {
|
||||
fmt.Println()
|
||||
fmt.Print(ColorWarning, IconWarning, " The following issues may need attention:", reset)
|
||||
fmt.Println()
|
||||
for _, warning := range warnings {
|
||||
fmt.Println(" •", warning)
|
||||
}
|
||||
fmt.Println()
|
||||
warnings = nil
|
||||
}
|
||||
}
|
||||
|
||||
101
internal/logger/logger_test.go
Normal file
101
internal/logger/logger_test.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIcons(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
got Icon
|
||||
expected Icon
|
||||
}{
|
||||
{"IconSuccess", IconSuccess, "✅"},
|
||||
{"IconFailure", IconFailure, "❌"},
|
||||
{"IconWarning", IconWarning, "❕"},
|
||||
{"IconNote", IconNote, "📝"},
|
||||
{"IconWorld", IconWorld, "🌐"},
|
||||
{"IconPlug", IconPlug, "🔌"},
|
||||
{"IconPackage", IconPackage, "📦"},
|
||||
{"IconCabinet", IconCabinet, "🗄️"},
|
||||
{"IconInfo", IconInfo, "🔵"},
|
||||
{"IconSecret", IconSecret, "🔒"},
|
||||
{"IconConfig", IconConfig, "🔧"},
|
||||
{"IconDependency", IconDependency, "🔗"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.got != tt.expected {
|
||||
t.Errorf("got %q, want %q", tt.got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInfo(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Info panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
Info("test message")
|
||||
}
|
||||
|
||||
func TestWarn(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Warn panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
Warn("test warning")
|
||||
}
|
||||
|
||||
func TestSuccess(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Success panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
Success("test success")
|
||||
}
|
||||
|
||||
func TestFailure(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Failure panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
Failure("test failure")
|
||||
}
|
||||
|
||||
func TestLog(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Errorf("Log panicked: %v", r)
|
||||
}
|
||||
}()
|
||||
Log(IconInfo, "test log")
|
||||
}
|
||||
|
||||
func TestWarningsCollection(t *testing.T) {
|
||||
// Clear any existing warnings
|
||||
warnings = nil
|
||||
|
||||
// Add some warnings
|
||||
Warn("test warning 1")
|
||||
Warnf("test warning 2: %s", "value")
|
||||
|
||||
// Check that warnings were collected
|
||||
if len(warnings) != 2 {
|
||||
t.Errorf("expected 2 warnings, got %d", len(warnings))
|
||||
}
|
||||
|
||||
// Check the content of warnings
|
||||
if warnings[0] != "test warning 1" {
|
||||
t.Errorf("expected 'test warning 1', got '%s'", warnings[0])
|
||||
}
|
||||
if warnings[1] != "test warning 2: value" {
|
||||
t.Errorf("expected 'test warning 2: value', got '%s'", warnings[1])
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ package parser
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/cli"
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
"katenary.io/internal/logger"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -37,20 +37,25 @@ func Parse(profiles []string, envFiles []string, dockerComposeFile ...string) (*
|
||||
var err error
|
||||
envFiles[i], err = filepath.Abs(envFiles[i])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
options, err := cli.NewProjectOptions(dockerComposeFile,
|
||||
opts := []cli.ProjectOptionsFn{
|
||||
cli.WithProfiles(profiles),
|
||||
cli.WithInterpolation(true),
|
||||
cli.WithDefaultConfigPath,
|
||||
cli.WithEnvFiles(envFiles...),
|
||||
cli.WithOsEnv,
|
||||
cli.WithDotEnv,
|
||||
cli.WithNormalization(true),
|
||||
cli.WithResolvedPaths(false),
|
||||
)
|
||||
}
|
||||
|
||||
if len(dockerComposeFile) == 0 {
|
||||
opts = append(opts, cli.WithDefaultConfigPath)
|
||||
}
|
||||
|
||||
options, err := cli.NewProjectOptions(dockerComposeFile, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"katenary.io/internal/logger"
|
||||
)
|
||||
|
||||
const composeFile = `
|
||||
@@ -27,7 +28,7 @@ func setupTest() (string, error) {
|
||||
func tearDownTest(tmpDir string) {
|
||||
if tmpDir != "" {
|
||||
if err := os.RemoveAll(tmpDir); err != nil {
|
||||
log.Fatalf("Failed to remove temporary directory %s: %s", tmpDir, err.Error())
|
||||
logger.Fatalf("Failed to remove temporary directory %s: %s", tmpDir, err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package utils
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -133,8 +132,8 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
|
||||
labelContent := []any{}
|
||||
err := yaml.Unmarshal([]byte(v), &labelContent)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing label %s: %s", v, err)
|
||||
log.Fatal(err)
|
||||
logger.Warnf("Error parsing label %s: %s", v, err)
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
for _, value := range labelContent {
|
||||
@@ -150,7 +149,7 @@ func GetValuesFromLabel(service types.ServiceConfig, LabelValues string) map[str
|
||||
descriptions[k.(string)] = &EnvConfig{Service: service, Description: v.(string)}
|
||||
}
|
||||
default:
|
||||
log.Fatalf("Unknown type in label: %s %T", LabelValues, value)
|
||||
logger.Fatalf("Unknown type in label: %s %T", LabelValues, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +170,7 @@ func Confirm(question string, icon ...logger.Icon) bool {
|
||||
}
|
||||
var response string
|
||||
if _, err := fmt.Scanln(&response); err != nil {
|
||||
log.Fatalf("Error parsing response: %s", err.Error())
|
||||
logger.Fatalf("Error parsing response: %s", err.Error())
|
||||
}
|
||||
return strings.ToLower(response) == "y"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user