Skip to content

Commit

Permalink
Changed interval separator to comma, and added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
peterklijn committed Jul 26, 2022
1 parent b02da54 commit 0dcb5d3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
3 changes: 2 additions & 1 deletion commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func defineDeployCommand() *cobra.Command {
}

deployCmd.Flags().StringVar(&releaseOffset, "releaseOffset", "1m", "Duration to wait before the first release ('5m', '1h25m', '30s')")
deployCmd.Flags().StringVar(&releaseInterval, "releaseInterval", "25m", "Duration to wait between releases. ('5m', '1h25m', '30s')")
deployCmd.Flags().StringVar(&releaseInterval, "releaseInterval", "25m", "Duration to wait between releases. ('5m', '1h25m', '30s')\n"+
"You can do a non-linear interval by supplying more values: ('15m,10m,5m,5m,5m')")
deployCmd.Flags().BoolVar(&allowForcePush, "force", false, "Allow force push if deploy branch has diverged from base")
deployCmd.Flags().StringVar(&branchesString, "branches", "", "Comma separated list of branches")
deployCmd.Flags().BoolVar(&skipConfirm, "skip-confirmation", false, "Create the draft without asking for user confirmation.")
Expand Down
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ ergo deploy \
--branches release-pe,release-mx,release-co,release-cl,release-gr
```

##### Deploy with custom intervals

If you don't want a linear release interval, for example you want more time between the first and second deployment, you can specify multiple release intervals.

```bash
ergo deploy \
--owner dbaltas \
--repo ergo \
--releaseInterval 15m,5m,5m,5m \
--branches release-pe,release-mx,release-co,release-cl,release-gr
```

Each release will add the next interval, and starts reading the list from the beginning in case releaseInterval list is shorter than the number of branches.

```bash
Branch Start Time
release-pe 12:59 CEST
release-mx 13:14 CEST
release-co 13:19 CEST
release-cl 13:24 CEST
release-gr 13:29 CEST
Deployment? [y/N]:
```

## Github Access
To communicate with github you will need a [personal access token](https://github.com/settings/tokens) added on the configuration file as `access-token` on github

Expand Down
2 changes: 1 addition & 1 deletion release/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (r *Deploy) deployToAllReleaseBranches(

// calculateReleaseTime calculate from string the interval between the releases.
func (r *Deploy) calculateReleaseTime(releaseInterval, releaseOffset string) ([]time.Duration, *time.Time, error) {
intervalStrings := strings.Split(releaseInterval, " ")
intervalStrings := strings.Split(releaseInterval, ",")
intervalDurations := make([]time.Duration, 0, len(intervalStrings))
for _, interval := range intervalStrings {
intervalDuration, err := time.ParseDuration(interval)
Expand Down
8 changes: 4 additions & 4 deletions release/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ func TestNonLinearIntervals(t *testing.T) {
{
name: "multiple branches, nonlinear intervals",
branches: []string{"b1", "b2", "b3", "b4"},
intervals: "10ms 5ms 1ms 1ms",
intervals: "10ms,5ms,1ms,1ms",
},
{
name: "multiple branches, fewer intervals",
branches: []string{"b1", "b2", "b3", "b4"},
intervals: "10ms 5ms",
intervals: "10ms,5ms",
},
}

Expand Down Expand Up @@ -386,7 +386,7 @@ func TestNonLinearIntervalHandling(t *testing.T) {
{
name: "multiple branches, nonlinear intervals",
branches: []string{"branch1", "branch2", "branch3", "branch4"},
intervals: "10m 5m 1m",
intervals: "10m,5m,1m",
expectedPrintRows: [][]string{
{"branch1", ts(time.Now())},
{"branch2", ts(time.Now().Add(10 * time.Minute))},
Expand All @@ -397,7 +397,7 @@ func TestNonLinearIntervalHandling(t *testing.T) {
{
name: "multiple branches, fewer intervals",
branches: []string{"branch1", "branch2", "branch3", "branch4"},
intervals: "10m 5m",
intervals: "10m,5m",
expectedPrintRows: [][]string{
{"branch1", ts(time.Now())},
{"branch2", ts(time.Now().Add(10 * time.Minute))},
Expand Down

0 comments on commit 0dcb5d3

Please sign in to comment.