-
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.
fix: make deploy a slice, use it to config multiple environments (#12)
* fix: make deploy a slice, use it to config multiple environments * docs: add info on the .bcignore file * fix: update deploy default role ARN to reflect standard GHA role naming
- Loading branch information
Showing
11 changed files
with
126 additions
and
32 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
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,3 @@ | ||
**/* | ||
!.gitignore | ||
!build-configs.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
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
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
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
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 |
---|---|---|
@@ -1,12 +1,56 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
const ( | ||
DefaultEnvironment = "unspecified" | ||
DefaultAccount = "677459762413" | ||
DefaultRegion = "us-west-2" | ||
) | ||
|
||
type DeployConfig struct { | ||
// Environment is the name of the environment to deploy to. | ||
Environment string `json:"environment" yaml:"environment"` | ||
|
||
// Account is the AWS account ID used to deploy to this environment. | ||
Account string `json:"account,omitempty" yaml:"account,omitempty"` | ||
|
||
// RoleARN is the ARN of the role used to deploy to this environment. | ||
RoleARN string `json:"roleArn,omitempty" yaml:"roleArn,omitempty"` | ||
Region string `json:"region,omitempty" yaml:"region,omitempty"` | ||
|
||
// Region is the AWS region this environment will be deployed into. | ||
Region string `json:"region,omitempty" yaml:"region,omitempty"` | ||
|
||
// If is the value of the `if` field for the GitHub Actions job that will | ||
// deploy this application. | ||
If string `json:"if,omitempty" yaml:"if,omitempty"` | ||
} | ||
|
||
func NewDeployConfig() DeployConfig { | ||
return DeployConfig{ | ||
Region: "us-west-2", | ||
// UnmarshalJSON unmarshals the JSON blob while adding default values | ||
// contextually | ||
func (c *DeployConfig) UnmarshalJSON(data []byte) error { | ||
defaultRole := fmt.Sprintf( | ||
"arn:aws:iam::%s:role/altf4llc-gha-%s-deploy-%s", | ||
DefaultAccount, | ||
Cfg.Name, | ||
DefaultEnvironment, | ||
) | ||
|
||
type Alias DeployConfig | ||
deploy := Alias{ | ||
Environment: DefaultEnvironment, | ||
Account: DefaultAccount, | ||
RoleARN: defaultRole, | ||
Region: DefaultRegion, | ||
} | ||
|
||
if err := json.Unmarshal(data, &deploy); err != nil { | ||
return err | ||
} | ||
*c = DeployConfig(deploy) | ||
|
||
return nil | ||
} |
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,4 @@ | ||
package config | ||
|
||
var Cfg Config | ||
var Debug bool = false |
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
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
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