Skip to content

Commit 241f9ba

Browse files
authored
Add new Revision Name Flags (#5)
Add new flags to pass revision name to dotcom APIs
1 parent d40f13a commit 241f9ba

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

cmd/create.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"strings"
8-
8+
"net/url"
99
"github.com/MakeNowJust/heredoc"
1010
"github.com/cli/go-gh/v2/pkg/api"
1111
"github.com/spf13/cobra"
@@ -15,6 +15,7 @@ type createCmdFlags struct {
1515
app string
1616
EnvironmentVariables []string
1717
Secrets []string
18+
RevisionName string
1819
}
1920

2021
type createReq struct {
@@ -80,6 +81,14 @@ func init() {
8081
}
8182

8283
createUrl := fmt.Sprintf("runtime/%s/deployment", createCmdFlags.app)
84+
params := url.Values{}
85+
if createCmdFlags.RevisionName != "" {
86+
params.Add("revision_name", createCmdFlags.RevisionName)
87+
}
88+
if len(params) > 0 {
89+
createUrl += "?" + params.Encode()
90+
}
91+
8392
client, err := api.DefaultRESTClient()
8493
if err != nil {
8594
fmt.Println(err)
@@ -99,5 +108,6 @@ func init() {
99108
createCmd.Flags().StringVarP(&createCmdFlags.app, "app", "a", "", "The app to create")
100109
createCmd.Flags().StringSliceVarP(&createCmdFlags.EnvironmentVariables, "env", "e", []string{}, "Environment variables to set on the app in the form 'key=value'")
101110
createCmd.Flags().StringSliceVarP(&createCmdFlags.Secrets, "secret", "s", []string{}, "Secrets to set on the app in the form 'key=value'")
111+
createCmd.Flags().StringVarP(&createCmdFlags.RevisionName, "revision-name", "r", "", "The revision name to use for the app")
102112
rootCmd.AddCommand(createCmd)
103113
}

cmd/deploy.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io"
88
"os"
99
"path/filepath"
10-
10+
"net/url"
1111
"github.com/MakeNowJust/heredoc"
1212
"github.com/cli/go-gh/v2/pkg/api"
1313
"github.com/spf13/cobra"
@@ -16,6 +16,7 @@ import (
1616
type deployCmdFlags struct {
1717
dir string
1818
app string
19+
revisionName string
1920
}
2021

2122
func zipDirectory(sourceDir, destinationZip string) error {
@@ -131,6 +132,14 @@ func init() {
131132
}
132133

133134
deploymentsUrl := fmt.Sprintf("runtime/%s/deployment/bundle", deployCmdFlags.app)
135+
params := url.Values{}
136+
if deployCmdFlags.revisionName != "" {
137+
params.Add("revision_name", deployCmdFlags.revisionName)
138+
}
139+
if len(params) > 0 {
140+
deploymentsUrl += "?" + params.Encode()
141+
}
142+
134143
fmt.Printf("Deploying app to %s\n", deploymentsUrl)
135144

136145
// body is the full zip RAW
@@ -151,5 +160,6 @@ func init() {
151160
}
152161
deployCmd.Flags().StringVarP(&deployCmdFlags.dir, "dir", "d", "", "The directory to deploy")
153162
deployCmd.Flags().StringVarP(&deployCmdFlags.app, "app", "a", "", "The app to deploy")
163+
deployCmd.Flags().StringVarP(&deployCmdFlags.revisionName, "revision-name", "r", "", "The revision name to deploy")
154164
rootCmd.AddCommand(deployCmd)
155165
}

0 commit comments

Comments
 (0)