From 5d4f72e984b886d7f7dc2ddc071bdb2ec5a537ed Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Wed, 3 Apr 2024 21:33:26 +0200 Subject: [PATCH] Fix unued variable, useless functions... --- generator/converter.go | 5 +++-- generator/deployment.go | 7 ------- generator/globals.go | 3 --- generator/secret.go | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/generator/converter.go b/generator/converter.go index 9af18ff..e3e5bf1 100644 --- a/generator/converter.go +++ b/generator/converter.go @@ -388,6 +388,7 @@ const imagePullSecretHelp = ` func addImagePullSecretsHelp(values []byte) []byte { // add imagePullSecrets help lines := strings.Split(string(values), "\n") + for i, line := range lines { if strings.Contains(line, "pullSecrets:") { spaces := utils.CountStartingSpaces(line) @@ -411,10 +412,10 @@ func addChartDoc(values []byte, project *types.Project) []byte { lines := strings.Split(string(values), "\n") for i, line := range lines { if regexp.MustCompile(`(?m)^name:`).MatchString(line) { - doc := fmt.Sprintf("\n# Name of the chart (required), basically the name of the project.\n") + doc := "\n# Name of the chart (required), basically the name of the project.\n" lines[i] = doc + line } else if regexp.MustCompile(`(?m)^version:`).MatchString(line) { - doc := fmt.Sprintf("\n# Version of the chart (required)\n") + doc := "\n# Version of the chart (required)\n" lines[i] = doc + line } else if strings.Contains(line, "appVersion:") { spaces := utils.CountStartingSpaces(line) diff --git a/generator/deployment.go b/generator/deployment.go index 627bfd3..394ed46 100644 --- a/generator/deployment.go +++ b/generator/deployment.go @@ -33,13 +33,6 @@ type Deployment struct { // It also creates the Values map that will be used to create the values.yaml file. func NewDeployment(service types.ServiceConfig, chart *HelmChart) *Deployment { - ports := []corev1.ContainerPort{} - for _, port := range service.Ports { - ports = append(ports, corev1.ContainerPort{ - ContainerPort: int32(port.Target), - }) - } - isMainApp := false if mainLabel, ok := service.Labels[LABEL_MAIN_APP]; ok { main := strings.ToLower(mainLabel) diff --git a/generator/globals.go b/generator/globals.go index edab2a4..e4e74ba 100644 --- a/generator/globals.go +++ b/generator/globals.go @@ -3,9 +3,6 @@ package generator import "regexp" var ( - // regexp to all tpl strings - tplValueRegexp = regexp.MustCompile(`\{\{.*\}\}-`) - // find all labels starting by __replace_ and ending with ":" // and get the value between the quotes // ?s => multiline diff --git a/generator/secret.go b/generator/secret.go index be98fed..eb020ed 100644 --- a/generator/secret.go +++ b/generator/secret.go @@ -76,7 +76,7 @@ func NewSecret(service types.ServiceConfig, appName string) *Secret { // SetData sets the data of the secret. func (s *Secret) SetData(data map[string]string) { for key, value := range data { - s.AddData(key, fmt.Sprintf("%s", value)) + s.AddData(key, value) } }