Skip to content

Commit

Permalink
Merge branch 'v8' into update-v2-docs-links-v8
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotalgeorge authored Jul 30, 2024
2 parents 6a37d85 + e22adbf commit 0035da1
Show file tree
Hide file tree
Showing 12 changed files with 293 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .github/ops-files/replace-redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- type: replace
path: /instance_groups/name=api/jobs/name=redis?
value:
name: valkey
release: capi
1 change: 1 addition & 0 deletions .github/workflows/tests-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ jobs:
bosh -d cf manifest > /tmp/manifest.yml
bosh interpolate /tmp/manifest.yml \
-o .github/ops-files/use-cflinuxfs3.yml \
-o .github/ops-files/replace-redis.yml \
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
-o cf-deployment/operations/add-persistent-isolation-segment-diego-cell.yml \
-o cli-ci/ci/infrastructure/operations/use-latest-capi.yml \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@ jobs:
run-with-client-creds: false
os: ubuntu-latest
name: cats
is-pr: ${{ github.event_name != 'workflow_dispatch' }}
secrets: inherit

22 changes: 22 additions & 0 deletions actor/v7action/application_summary.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v7action

import (
"errors"

"code.cloudfoundry.org/cli/actor/actionerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
Expand All @@ -18,6 +20,7 @@ type ApplicationSummary struct {
type DetailedApplicationSummary struct {
ApplicationSummary
CurrentDroplet resources.Droplet
Deployment resources.Deployment
}

func (a ApplicationSummary) GetIsolationSegmentName() (string, bool) {
Expand Down Expand Up @@ -120,6 +123,12 @@ func (actor Actor) GetDetailedAppSummary(appName, spaceGUID string, withObfuscat
return DetailedApplicationSummary{}, allWarnings, err
}

detailedSummary, warnings, err = actor.addDeployment(detailedSummary)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return DetailedApplicationSummary{}, allWarnings, err
}

return detailedSummary, allWarnings, err
}

Expand Down Expand Up @@ -206,6 +215,19 @@ func (actor Actor) addDroplet(summary ApplicationSummary) (DetailedApplicationSu
}, allWarnings, nil
}

func (actor Actor) addDeployment(detailedSummary DetailedApplicationSummary) (DetailedApplicationSummary, Warnings, error) {
var allWarnings Warnings

deployment, warnings, err := actor.GetLatestActiveDeploymentForApp(detailedSummary.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil && !errors.Is(err, actionerror.ActiveDeploymentNotFoundError{}) {
return DetailedApplicationSummary{}, allWarnings, err
}

detailedSummary.Deployment = deployment
return detailedSummary, allWarnings, nil
}

func toAppGUIDs(apps []resources.Application) []string {
guids := make([]string, len(apps))

Expand Down
114 changes: 111 additions & 3 deletions actor/v7action/application_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"

"code.cloudfoundry.org/cli/actor/v7action"
. "code.cloudfoundry.org/cli/actor/v7action"
"code.cloudfoundry.org/cli/actor/v7action/v7actionfakes"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
Expand Down Expand Up @@ -574,6 +573,115 @@ var _ = Describe("Application Summary Actions", func() {
)
})

When("getting application deployment succeeds", func() {
When("the deployment is active", func() {
When("the deployment strategy is rolling", func() {
When("the deployment is in progress", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetDeploymentsReturns(
[]resources.Deployment{
{
GUID: "some-deployment-guid",
Strategy: "rolling",
StatusValue: "ACTIVE",
StatusReason: "DEPLOYING",
},
},
nil,
nil,
)
})
It("returns the deployment information", func() {
Expect(summary.Deployment).To(Equal(resources.Deployment{
GUID: "some-deployment-guid",
Strategy: "rolling",
StatusValue: "ACTIVE",
StatusReason: "DEPLOYING",
}))
})
})

When("the deployment is canceled", func() {
When("the deployment is in progress", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetDeploymentsReturns(
[]resources.Deployment{
{
GUID: "some-deployment-guid",
Strategy: "rolling",
StatusValue: "ACTIVE",
StatusReason: "CANCELLING",
},
},
nil,
nil,
)
})
It("returns the deployment information", func() {
Expect(summary.Deployment).To(Equal(resources.Deployment{
GUID: "some-deployment-guid",
Strategy: "rolling",
StatusValue: "ACTIVE",
StatusReason: "CANCELLING",
}))
})
})
})
})
})

When("the deployment is not active", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetDeploymentsReturns(
[]resources.Deployment{
{
GUID: "",
Strategy: "",
StatusValue: "",
StatusReason: "",
},
},
nil,
nil,
)
})
It("returns no deployment information", func() {
Expect(summary.Deployment).To(Equal(resources.Deployment{
GUID: "",
Strategy: "",
StatusValue: "",
StatusReason: "",
}))
})
})
})

When("getting application deployment fails", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetDeploymentsReturns(
nil,
ccv3.Warnings{"get-deployments-warning"},
errors.New("some-error"),
)
})

It("returns the warnings and error", func() {
Expect(executeErr).To(MatchError("some-error"))
Expect(warnings).To(ConsistOf(
"get-apps-warning",
"get-app-processes-warning",
"get-process-by-type-warning",
"get-process-sidecars-warning",
"get-process-instances-warning",
"get-process-by-type-warning",
"get-process-sidecars-warning",
"get-process-instances-warning",
"get-app-droplet-warning",
"get-deployments-warning",
))
})
})

When("getting application routes succeeds", func() {
BeforeEach(func() {
fakeCloudControllerClient.GetApplicationRoutesReturns(
Expand All @@ -589,7 +697,7 @@ var _ = Describe("Application Summary Actions", func() {
It("returns the summary and warnings with droplet information", func() {
Expect(executeErr).ToNot(HaveOccurred())
Expect(summary).To(Equal(DetailedApplicationSummary{
ApplicationSummary: v7action.ApplicationSummary{
ApplicationSummary: ApplicationSummary{
Application: resources.Application{
Name: "some-app-name",
GUID: "some-app-guid",
Expand Down Expand Up @@ -733,7 +841,7 @@ var _ = Describe("Application Summary Actions", func() {
It("returns the summary and warnings without droplet information", func() {
Expect(executeErr).ToNot(HaveOccurred())
Expect(summary).To(Equal(DetailedApplicationSummary{
ApplicationSummary: v7action.ApplicationSummary{
ApplicationSummary: ApplicationSummary{
Application: resources.Application{
Name: "some-app-name",
GUID: "some-app-guid",
Expand Down
6 changes: 6 additions & 0 deletions api/cloudcontroller/ccv3/constant/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const (
type DeploymentStatusReason string

const (
// DeploymentStatusReasonDeploying means the deployment is in state 'DEPLOYING'
DeploymentStatusReasonDeploying DeploymentStatusReason = "DEPLOYING"

// DeploymentCanceling means the deployment is in state 'CANCELING'
DeploymentStatusReasonCanceling DeploymentStatusReason = "CANCELING"

// DeploymentStatusReasonDeployed means the deployment's status.value is
// 'DEPLOYED'
DeploymentStatusReasonDeployed DeploymentStatusReason = "DEPLOYED"
Expand Down
9 changes: 9 additions & 0 deletions command/v7/shared/app_summary_displayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"code.cloudfoundry.org/cli/types"
"code.cloudfoundry.org/cli/util/ui"
log "github.com/sirupsen/logrus"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

type AppSummaryDisplayer struct {
Expand Down Expand Up @@ -159,6 +161,13 @@ func (display AppSummaryDisplayer) displayProcessTable(summary v7action.Detailed
}
display.displayAppInstancesTable(process)
}

if summary.Deployment.StatusValue == constant.DeploymentStatusValueActive {
display.UI.DisplayNewline()
display.UI.DisplayText(fmt.Sprintf("%s deployment currently %s.",
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
summary.Deployment.StatusReason))
}
}

func (display AppSummaryDisplayer) getCreatedTime(summary v7action.DetailedApplicationSummary) string {
Expand Down
57 changes: 57 additions & 0 deletions command/v7/shared/app_summary_displayer_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shared_test

import (
"fmt"
"time"

"code.cloudfoundry.org/cli/actor/v7action"
Expand All @@ -13,6 +14,8 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

var _ = Describe("app summary displayer", func() {
Expand Down Expand Up @@ -652,5 +655,59 @@ var _ = Describe("app summary displayer", func() {
Expect(testUI.Out).To(Say(`some-buildpack`))
})
})

When("there is an active deployment", func() {
When("the deployment strategy is rolling", func() {
When("the deployment is in progress", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Deployment: resources.Deployment{
Strategy: constant.DeploymentStrategyRolling,
StatusValue: constant.DeploymentStatusValueActive,
StatusReason: constant.DeploymentStatusReasonDeploying,
},
}
})

It("displays the message", func() {
Expect(testUI.Out).To(Say("Rolling deployment currently DEPLOYING."))
})
})

When("the deployment is cancelled", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Deployment: resources.Deployment{
Strategy: constant.DeploymentStrategyRolling,
StatusValue: constant.DeploymentStatusValueActive,
StatusReason: constant.DeploymentStatusReasonCanceling,
},
}
})

It("displays the message", func() {
Expect(testUI.Out).To(Say("Rolling deployment currently CANCELING."))
})
})
})
})

When("there is no active deployment", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Deployment: resources.Deployment{
Strategy: "",
StatusValue: "",
StatusReason: "",
},
}
})

It("does not display deployment info", func() {
Expect(testUI.Out).NotTo(Say(fmt.Sprintf("%s deployment currently %s",
cases.Title(language.English, cases.NoLower).String(string(summary.Deployment.Strategy)),
summary.Deployment.StatusReason)))
})
})
})
})
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/cloudfoundry/bosh-cli v6.4.1+incompatible
github.com/creack/pty v1.1.21
github.com/cyphar/filepath-securejoin v0.2.5
github.com/cyphar/filepath-securejoin v0.3.1
github.com/distribution/reference v0.6.0
github.com/fatih/color v1.17.0
github.com/google/go-querystring v1.1.0
github.com/jessevdk/go-flags v1.6.1
github.com/lunixbochs/vtclean v1.0.0
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-runewidth v0.0.15
github.com/mattn/go-runewidth v0.0.16
github.com/maxbrunsfeld/counterfeiter/v6 v6.8.1
github.com/moby/term v0.5.0
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/onsi/ginkgo/v2 v2.19.1
github.com/onsi/gomega v1.34.0
github.com/pkg/errors v0.9.1
github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f
github.com/sajari/fuzzy v1.0.0
github.com/sirupsen/logrus v1.9.3
github.com/tedsuo/rata v1.0.1-0.20170830210128-07d200713958
github.com/vito/go-interact v0.0.0-20171111012221-fa338ed9e9ec
golang.org/x/crypto v0.25.0
golang.org/x/net v0.26.0
golang.org/x/net v0.27.0
golang.org/x/term v0.22.0
golang.org/x/text v0.16.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
)

require (
Expand Down Expand Up @@ -88,7 +88,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
Expand Down
Loading

0 comments on commit 0035da1

Please sign in to comment.