Skip to content
Permalink
Browse files
add the option to force build a new deployment (#913)
  • Loading branch information
kamaln7 committed Nov 10, 2020
1 parent 4b8d28e commit af5bae4c4a6bdbe0492cc006f76c638bbac63578
@@ -42,6 +42,8 @@ const (
ArgAppDeployment = "deployment"
// ArgAppLogFollow follow logs.
ArgAppLogFollow = "follow"
// ArgAppForceRebuild forces a deployment rebuild
ArgAppForceRebuild = "force-rebuild"
// ArgClusterName is a cluster name argument.
ArgClusterName = "cluster-name"
// ArgClusterVersionSlug is a cluster version argument.
@@ -103,7 +103,7 @@ This permanently deletes the app and all its associated deployments.`,
)
AddBoolFlag(deleteApp, doctl.ArgForce, doctl.ArgShortForce, false, "Delete the App without a confirmation prompt")

CmdBuilder(
deploymentCreate := CmdBuilder(
cmd,
RunAppsCreateDeployment,
"create-deployment <app id>",
@@ -115,6 +115,7 @@ The deployment will be created using the provided app spec. For more informatio
aliasOpt("cd"),
displayerType(&displayers.Deployments{}),
)
AddBoolFlag(deploymentCreate, doctl.ArgAppForceRebuild, "", false, "Force a re-build even if a previous build is eligible for reuse")

CmdBuilder(
cmd,
@@ -307,8 +308,12 @@ func RunAppsCreateDeployment(c *CmdConfig) error {
return doctl.NewMissingArgsErr(c.NS)
}
appID := c.Args[0]
forceRebuild, err := c.Doit.GetBool(c.NS, doctl.ArgAppForceRebuild)
if err != nil {
return err
}

deployment, err := c.Apps().CreateDeployment(appID)
deployment, err := c.Apps().CreateDeployment(appID, forceRebuild)
if err != nil {
return err
}
@@ -572,7 +577,7 @@ func appsTier() *Command {
CmdBuilder(cmd, RunAppsTierGet, "get <tier slug>", "Retrieve an app tier", `Use this command to retrieve information about a specific app tier.`, Writer)

cmd.AddCommand(appsTierInstanceSize())

return cmd
}

@@ -213,9 +213,10 @@ func TestRunAppsCreateDeployment(t *testing.T) {
UpdatedAt: time.Now(),
}

tm.apps.EXPECT().CreateDeployment(appID).Times(1).Return(deployment, nil)
tm.apps.EXPECT().CreateDeployment(appID, true).Times(1).Return(deployment, nil)

config.Args = append(config.Args, appID)
config.Doit.Set(config.NS, doctl.ArgAppForceRebuild, true)

err := RunAppsCreateDeployment(config)
require.NoError(t, err)
@@ -27,7 +27,7 @@ type AppsService interface {
Update(appID string, req *godo.AppUpdateRequest) (*godo.App, error)
Delete(appID string) error

CreateDeployment(appID string) (*godo.Deployment, error)
CreateDeployment(appID string, forceRebuild bool) (*godo.Deployment, error)
GetDeployment(appID, deploymentID string) (*godo.Deployment, error)
ListDeployments(appID string) ([]*godo.Deployment, error)

@@ -94,8 +94,10 @@ func (s *appsService) Delete(appID string) error {
return err
}

func (s *appsService) CreateDeployment(appID string) (*godo.Deployment, error) {
deployment, _, err := s.client.Apps.CreateDeployment(s.ctx, appID)
func (s *appsService) CreateDeployment(appID string, forceRebuild bool) (*godo.Deployment, error) {
deployment, _, err := s.client.Apps.CreateDeployment(s.ctx, appID, &godo.DeploymentCreateRequest{
ForceBuild: forceRebuild,
})
if err != nil {
return nil, err
}

Some generated files are not rendered by default. Learn more.

2 go.mod
@@ -8,7 +8,7 @@ require (
github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/creack/pty v1.1.11
github.com/digitalocean/godo v1.51.0
github.com/digitalocean/godo v1.52.0
github.com/docker/cli v0.0.0-20200622130859-87db43814b48
github.com/docker/docker v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect
4 go.sum
@@ -95,8 +95,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/digitalocean/godo v1.51.0 h1:Hn+O5Hiy7SrRhuJXFaojkPe38OjgQU8L0sIV09ViI3U=
github.com/digitalocean/godo v1.51.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU=
github.com/digitalocean/godo v1.52.0 h1:1QSUC0w5T1wS1d/1uvPtG8GLeD0p/4zhx1Q+Fxtna+k=
github.com/digitalocean/godo v1.52.0/go.mod h1:p7dOjjtSBqCTUksqtA5Fd3uaKs9kyTq2xcz76ulEJRU=
github.com/docker/cli v0.0.0-20200622130859-87db43814b48 h1:AC8qbhi/SjYf4iN2W3jSsofZGHWPjG8pjf5P143KUM8=
github.com/docker/cli v0.0.0-20200622130859-87db43814b48/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/docker v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible h1:PmGHHCZ43l6h8aZIi+Xa+z1SWe4dFImd5EK3TNp1jlo=
@@ -441,6 +441,14 @@ var _ = suite("apps/create-deployment", func(t *testing.T, when spec.G, it spec.
return
}

var r godo.DeploymentCreateRequest
err := json.NewDecoder(req.Body).Decode(&r)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
assert.Equal(t, true, r.ForceBuild)

json.NewEncoder(w).Encode(testDeploymentResponse)
default:
dump, err := httputil.DumpRequest(req, true)
@@ -459,6 +467,7 @@ var _ = suite("apps/create-deployment", func(t *testing.T, when spec.G, it spec.
"-u", server.URL,
"apps",
"create-deployment",
"--force-rebuild",
testAppUUID,
)

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -18,7 +18,7 @@ github.com/cpuguy83/go-md2man/md2man
github.com/creack/pty
# github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew/spew
# github.com/digitalocean/godo v1.51.0
# github.com/digitalocean/godo v1.52.0
## explicit
github.com/digitalocean/godo
github.com/digitalocean/godo/util

0 comments on commit af5bae4

Please sign in to comment.