Skip to content

Commit

Permalink
refactor config
Browse files Browse the repository at this point in the history
  • Loading branch information
corymurphy committed Oct 8, 2024
1 parent af79729 commit 82f83d0
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 36 deletions.
4 changes: 2 additions & 2 deletions charts/argobot/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 2 additions & 9 deletions charts/argobot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions pkg/env/app_config.go

This file was deleted.

8 changes: 0 additions & 8 deletions pkg/env/argocli_config.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/env/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
4 changes: 2 additions & 2 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/testdata/argobot_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.8.0

0 comments on commit 82f83d0

Please sign in to comment.