-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from a-company-jp/shion/add-config-pkg
✨ pkg/config
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
setting.*.yaml | ||
!setting.example.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"` | ||
} |