From 82f83d0571824c84692d454ddb1b9828b08e3194 Mon Sep 17 00:00:00 2001 From: "cory.murphy" Date: Tue, 8 Oct 2024 06:48:31 -0400 Subject: [PATCH] refactor config --- charts/argobot/Chart.yaml | 4 ++-- charts/argobot/values.yaml | 11 ++--------- pkg/cli/start.go | 4 ++-- pkg/env/app_config.go | 6 ------ pkg/env/argocli_config.go | 8 -------- pkg/env/config.go | 4 ++-- pkg/server/server_test.go | 4 ++-- pkg/testdata/argobot_config.yaml | 5 +---- version | 2 +- 9 files changed, 12 insertions(+), 36 deletions(-) delete mode 100644 pkg/env/app_config.go delete mode 100644 pkg/env/argocli_config.go diff --git a/charts/argobot/Chart.yaml b/charts/argobot/Chart.yaml index d0ad920..9f8c85b 100644 --- a/charts/argobot/Chart.yaml +++ b/charts/argobot/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: argobot description: Helm chart for the corymurphy/argobot app type: application -version: 0.7.0 -appVersion: 0.7.0 +version: 0.8.0 +appVersion: 0.8.0 diff --git a/charts/argobot/values.yaml b/charts/argobot/values.yaml index 3db04d8..93eeb87 100644 --- a/charts/argobot/values.yaml +++ b/charts/argobot/values.yaml @@ -44,15 +44,8 @@ config: | app: integration_id: 77423 - app_configuration: - dataDirectory: .data - privateKeyFilePath: /app/key.pem - - argoConfig: - command: argocd - server: argocd-server.argocd - AdditionalArguments: --plaintext - apiBaseUrl: http://argocd-server.argocd.svc.cluster.local:80 + privateKeyFilePath: /app/key.pem + apiBaseUrl: http://argocd-server.argocd.svc.cluster.local:80 webServer: resources: diff --git a/pkg/cli/start.go b/pkg/cli/start.go index c1e847e..53cc1e4 100644 --- a/pkg/cli/start.go +++ b/pkg/cli/start.go @@ -29,7 +29,7 @@ var run = &cobra.Command{ panic(err) } - content, err := os.ReadFile(config.AppConfig.PrivateKeyFilePath) + content, err := os.ReadFile(config.PrivateKeyFilePath) if err != nil { panic(err) @@ -39,7 +39,7 @@ var run = &cobra.Command{ config.Github.App.WebhookSecret = os.Getenv(WebhookSecretEnvVar) argoClient := &argocd.ApplicationsClient{ - BaseUrl: config.ArgoConfig.ApiBaseUrl, + BaseUrl: config.ArgoCdUrl, } if apiKey, exists := os.LookupEnv("ARGOBOT_ARGOCD_API_KEY"); exists { diff --git a/pkg/env/app_config.go b/pkg/env/app_config.go deleted file mode 100644 index ad25c64..0000000 --- a/pkg/env/app_config.go +++ /dev/null @@ -1,6 +0,0 @@ -package env - -type AppConfig struct { - DataDirectory string `yaml:"dataDirectory"` - PrivateKeyFilePath string `yaml:"privateKeyFilePath"` -} diff --git a/pkg/env/argocli_config.go b/pkg/env/argocli_config.go deleted file mode 100644 index 65785ce..0000000 --- a/pkg/env/argocli_config.go +++ /dev/null @@ -1,8 +0,0 @@ -package env - -type ArgoConfig struct { - Command string `yaml:"command"` - Server string `yaml:"server"` - ApiBaseUrl string `yaml:"apiBaseUrl"` - AdditionalArgs string `yaml:"AdditionalArguments"` -} diff --git a/pkg/env/config.go b/pkg/env/config.go index b13a145..270a2bd 100644 --- a/pkg/env/config.go +++ b/pkg/env/config.go @@ -6,6 +6,6 @@ type Config struct { Server HTTPConfig `yaml:"server"` Github githubapp.Config `yaml:"github"` - AppConfig AppConfig `yaml:"app_configuration"` - ArgoConfig ArgoConfig `yaml:"argoConfig"` + ArgoCdUrl string `yaml:"argoCdUrl"` + PrivateKeyFilePath string `yaml:"privateKeyFilePath"` } diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index 81208ff..9bb6db0 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -55,7 +55,7 @@ func Test_PRCommentHandler(t *testing.T) { if err != nil { panic(err) } - content, err := os.ReadFile(config.AppConfig.PrivateKeyFilePath) + content, err := os.ReadFile(config.PrivateKeyFilePath) if err != nil { panic(err) } @@ -103,7 +103,7 @@ func NewServerTestCases(mockServer *httptest.Server) *[]ServerTestCase { if err != nil { panic(err) } - content, err := os.ReadFile(config.AppConfig.PrivateKeyFilePath) + content, err := os.ReadFile(config.PrivateKeyFilePath) if err != nil { panic(err) } diff --git a/pkg/testdata/argobot_config.yaml b/pkg/testdata/argobot_config.yaml index 81f7581..77c88b6 100644 --- a/pkg/testdata/argobot_config.yaml +++ b/pkg/testdata/argobot_config.yaml @@ -8,7 +8,4 @@ github: integration_id: 123456 webhookSecret: fc1b391fa17718cfdbf9497ec9bfe59 -app_configuration: - pull_request_preamble: "I am echo bot." - data_directory: .data - private_key_file_path: ../testdata/github_app.pem +privateKeyFilePath: ../testdata/github_app.pem diff --git a/version b/version index faef31a..a3df0a6 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.7.0 +0.8.0