-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Transit Gateway MVP for hub-and-spoke VPC connectivity #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f44ff61
d39f7ed
65f634c
6a91297
b8b9df0
3546bee
363f6b0
92b42d1
79ca9e8
b706b9a
ec150a5
6599145
3b55b18
a0ed61e
41a93b2
6c535b9
f6fa537
66bef7e
dfefaa6
a869197
d279681
41cbecf
ba0e0ec
9405b96
47030f3
b32e423
49bd445
044ac99
253e0d3
7fa08ed
7aae9aa
e149d97
1685fc4
ddcbb8d
2e769e5
b736be7
56c37e8
6bb9021
b35cb48
468fc6b
ab54736
e0bcfef
375e156
6e293bf
a5aea31
1dd04e6
f548620
797f6f9
696a451
5e29080
1247284
b82ec3c
7a80d15
b179e5a
e6c0c23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,22 +10,42 @@ import ( | |||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| type cliConfig struct { | ||||||||||||||||||||||||||||||||||
| APIKey string `json:"api_key"` | ||||||||||||||||||||||||||||||||||
| APIURL string `json:"api_url"` | ||||||||||||||||||||||||||||||||||
| Output string `json:"output"` | ||||||||||||||||||||||||||||||||||
| Tenant string `json:"tenant"` | ||||||||||||||||||||||||||||||||||
| Debug bool `json:"debug"` | ||||||||||||||||||||||||||||||||||
| APICredential string `json:"auth"` | ||||||||||||||||||||||||||||||||||
| APIURL string `json:"api_url"` | ||||||||||||||||||||||||||||||||||
| Output string `json:"output"` | ||||||||||||||||||||||||||||||||||
| Tenant string `json:"tenant"` | ||||||||||||||||||||||||||||||||||
| Debug bool `json:"debug"` | ||||||||||||||||||||||||||||||||||
| // LegacyAPIKey for backward compatibility with existing config files | ||||||||||||||||||||||||||||||||||
| LegacyAPIKey string `json:"api_key,omitempty"` //#nosec G117 | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // UnmarshalJSON handles both old ("api_key") and new ("auth") JSON tags | ||||||||||||||||||||||||||||||||||
| func (c *cliConfig) UnmarshalJSON(data []byte) error { | ||||||||||||||||||||||||||||||||||
| type alias cliConfig | ||||||||||||||||||||||||||||||||||
| tmp := struct { | ||||||||||||||||||||||||||||||||||
| *alias | ||||||||||||||||||||||||||||||||||
| LegacyAPIKey string `json:"api_key,omitempty"` | ||||||||||||||||||||||||||||||||||
| }{alias: (*alias)(c)} | ||||||||||||||||||||||||||||||||||
| if err := json.Unmarshal(data, &tmp); err != nil { | ||||||||||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| if c.APICredential == "" && tmp.LegacyAPIKey != "" { | ||||||||||||||||||||||||||||||||||
| c.APICredential = tmp.LegacyAPIKey | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| func getConfigFilePath() string { | ||||||||||||||||||||||||||||||||||
| if path := os.Getenv("CLOUD_CONFIG_PATH"); path != "" { | ||||||||||||||||||||||||||||||||||
| return path | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| home, _ := os.UserHomeDir() | ||||||||||||||||||||||||||||||||||
| return filepath.Join(home, ".cloud", "config.json") | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| var configFile = getConfigFilePath() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| func loadConfigFile() string { | ||||||||||||||||||||||||||||||||||
| data, err := os.ReadFile(configFile) | ||||||||||||||||||||||||||||||||||
| configPath := getConfigFilePath() | ||||||||||||||||||||||||||||||||||
| data, err := os.ReadFile(configPath) //#nosec G304 | ||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -35,11 +55,12 @@ func loadConfigFile() string { | |||||||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return cfg.APIKey | ||||||||||||||||||||||||||||||||||
| return cfg.APICredential | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| func loadFullConfig() *cliConfig { | ||||||||||||||||||||||||||||||||||
| data, err := os.ReadFile(configFile) | ||||||||||||||||||||||||||||||||||
| configPath := getConfigFilePath() | ||||||||||||||||||||||||||||||||||
| data, err := os.ReadFile(configPath) //#nosec G304 | ||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||
| return &cliConfig{} | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -53,17 +74,18 @@ func loadFullConfig() *cliConfig { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| func saveConfigFile(cfg cliConfig) error { | ||||||||||||||||||||||||||||||||||
| dir := filepath.Dir(configFile) | ||||||||||||||||||||||||||||||||||
| if err := os.MkdirAll(dir, 0755); err != nil { | ||||||||||||||||||||||||||||||||||
| configPath := getConfigFilePath() | ||||||||||||||||||||||||||||||||||
| dir := filepath.Dir(configPath) | ||||||||||||||||||||||||||||||||||
| if err := os.MkdirAll(dir, 0750); err != nil { | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace file-mode literals with named constants. Line 57 introduces 🔧 Proposed fix+const (
+ configDirMode os.FileMode = 0o750
+ configFileMode os.FileMode = 0o600
+)
+
func saveConfigFile(cfg cliConfig) error {
dir := filepath.Dir(configFile)
- if err := os.MkdirAll(dir, 0750); err != nil {
+ if err := os.MkdirAll(dir, configDirMode); err != nil {
return fmt.Errorf("failed to create config directory: %w", err)
}
@@
- if err := os.WriteFile(configFile, data, 0600); err != nil {
+ if err := os.WriteFile(configFile, data, configFileMode); err != nil {
return fmt.Errorf("failed to write config file: %w", err)
}As per coding guidelines, "Do not use magic numbers - use named constants instead". 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||||||||
| return fmt.Errorf("failed to create config directory: %w", err) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| data, err := json.MarshalIndent(cfg, "", " ") | ||||||||||||||||||||||||||||||||||
| data, err := json.MarshalIndent(cfg, "", " ") //#nosec G117 | ||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||
| return fmt.Errorf("failed to marshal config: %w", err) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if err := os.WriteFile(configFile, data, 0600); err != nil { | ||||||||||||||||||||||||||||||||||
| if err := os.WriteFile(configPath, data, 0600); err != nil { | ||||||||||||||||||||||||||||||||||
| return fmt.Errorf("failed to write config file: %w", err) | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -95,7 +117,7 @@ var configSetCmd = &cobra.Command{ | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| switch key { | ||||||||||||||||||||||||||||||||||
| case "api-key": | ||||||||||||||||||||||||||||||||||
| cfg.APIKey = value | ||||||||||||||||||||||||||||||||||
| cfg.APICredential = value | ||||||||||||||||||||||||||||||||||
| case "api-url": | ||||||||||||||||||||||||||||||||||
| cfg.APIURL = value | ||||||||||||||||||||||||||||||||||
| case "output": | ||||||||||||||||||||||||||||||||||
|
|
@@ -127,7 +149,7 @@ var configUnsetCmd = &cobra.Command{ | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| switch key { | ||||||||||||||||||||||||||||||||||
| case "api-key": | ||||||||||||||||||||||||||||||||||
| cfg.APIKey = "" | ||||||||||||||||||||||||||||||||||
| cfg.APICredential = "" | ||||||||||||||||||||||||||||||||||
| case "api-url": | ||||||||||||||||||||||||||||||||||
| cfg.APIURL = "" | ||||||||||||||||||||||||||||||||||
| case "output": | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an explicit readiness check for
mockhttpserverbefore running tests.The workflow waits for API health but not for the mock backend. Early gateway tests can race the mock container startup and intermittently fail.
Proposed change
# Wait for API to be ready echo "Waiting for API to be ready..." timeout 90 bash -c 'until curl -sf http://localhost:8080/health > /dev/null; do sleep 2; done' || { echo "API failed to start or become healthy within 90s" docker compose logs api exit 1 } + + # Wait for mock HTTP server to be ready + echo "Waiting for mock HTTP server..." + timeout 60 bash -c 'until curl -sf http://localhost:8089/ > /dev/null; do sleep 1; done' || { + echo "mockhttpserver failed to become ready within 60s" + docker compose logs mockhttpserver + exit 1 + }📝 Committable suggestion
🤖 Prompt for AI Agents