chore: update main.go
This commit is contained in:
18
main.go
18
main.go
@@ -75,6 +75,12 @@ type Env struct {
|
|||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EnvPayload struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
NeedsDeletion bool `json:"needsDeletion"`
|
||||||
|
}
|
||||||
|
|
||||||
type GitConfig struct {
|
type GitConfig struct {
|
||||||
Authentication Authentication `json:"authentication"`
|
Authentication Authentication `json:"authentication"`
|
||||||
ConfigFilePath string `json:"configFilePath"`
|
ConfigFilePath string `json:"configFilePath"`
|
||||||
@@ -159,12 +165,22 @@ func Deploy(cfg Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var envVars []Env
|
var envVars []Env
|
||||||
|
var envPayloads []EnvPayload
|
||||||
if cfg.EnvData != "" {
|
if cfg.EnvData != "" {
|
||||||
if err := json.Unmarshal([]byte(cfg.EnvData), &envVars); err != nil {
|
if err := json.Unmarshal([]byte(cfg.EnvData), &envVars); err != nil {
|
||||||
return fmt.Errorf("invalid env data: %w", err)
|
return fmt.Errorf("invalid env data: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
envPayloads = make([]EnvPayload, len(envVars))
|
||||||
|
for i := range envVars {
|
||||||
|
envPayloads[i] = EnvPayload{
|
||||||
|
Name: envVars[i].Name,
|
||||||
|
Value: envVars[i].Value,
|
||||||
|
NeedsDeletion: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
|
|
||||||
payload := map[string]interface{}{
|
payload := map[string]interface{}{
|
||||||
@@ -178,7 +194,7 @@ func Deploy(cfg Config) error {
|
|||||||
"RepositoryAuthentication": true,
|
"RepositoryAuthentication": true,
|
||||||
"RepositoryUsername": cfg.RepoUsername,
|
"RepositoryUsername": cfg.RepoUsername,
|
||||||
"RepositoryPassword": cfg.RepoPassword,
|
"RepositoryPassword": cfg.RepoPassword,
|
||||||
"Env": envVars,
|
"env": envPayloads,
|
||||||
"TLSSkipVerify": cfg.TLSSkipVerify,
|
"TLSSkipVerify": cfg.TLSSkipVerify,
|
||||||
"AutoUpdate": map[string]interface{}{
|
"AutoUpdate": map[string]interface{}{
|
||||||
"Interval": "",
|
"Interval": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user