Skip to content

Commit

Permalink
Merge pull request #1 from a-company-jp/shion/add-config-pkg
Browse files Browse the repository at this point in the history
✨ pkg/config
  • Loading branch information
Shion1305 authored Oct 11, 2024
2 parents bbcd7c2 + f39533f commit 45b4361
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setting.*.yaml
!setting.example.yaml
27 changes: 27 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package config

import (
"gopkg.in/yaml.v3"
"log/slog"
"os"
)

var Config config

type config struct {
LineConfig LineConfig `yaml:"line"`
VonageConfig VonageConfig `yaml:"vonage"`
}

func init() {
Config = config{}
loc := os.Getenv("ENV_LOCATION")
if loc == "" {
slog.Error("No ENV_LOCATION found")
return
}
if err := yaml.Unmarshal([]byte(loc), &Config); err != nil {
slog.Error("Failed to unmarshal yaml", err)
return
}
}
7 changes: 7 additions & 0 deletions pkg/config/line.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package config

type LineConfig struct {
ClientID string `yaml:"channel_id"`
ChannelSecret string `yaml:"channel_secret"`
ChannelToken string `yaml:"channel_access_token"`
}
7 changes: 7 additions & 0 deletions pkg/config/setting.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
line:
channel_id:
channel_secret:
channel_access_token:
vonage:
x_vgai_key:
agent_id:
6 changes: 6 additions & 0 deletions pkg/config/vonage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package config

type VonageConfig struct {
VgaiKey string `yaml:"x_vgai_key"`
AgentID string `yaml:"agent_id"`
}

0 comments on commit 45b4361

Please sign in to comment.