Skip to content

Commit

Permalink
v7: Replace DisplayWarnings with DisplayWarningsV7
Browse files Browse the repository at this point in the history
- This gives us a consistent way of displaying warnings across all v7
commands and their unit tests

[#168703025]

Co-authored-by: Reid Mitchell <rmitchell@pivotal.io>
Co-authored-by: Supraja Narasimhan <snarasimhan@pivotal.io>
  • Loading branch information
reidmit and suprajanarasimhan committed Oct 15, 2019
1 parent 6b953a1 commit 4762b0f
Show file tree
Hide file tree
Showing 74 changed files with 134 additions and 134 deletions.
4 changes: 2 additions & 2 deletions command/v7/app_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (cmd AppCommand) Execute(args []string) error {

appSummaryDisplayer := shared.NewAppSummaryDisplayer(cmd.UI)
summary, warnings, err := cmd.Actor.GetDetailedAppSummary(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID, false)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand All @@ -80,7 +80,7 @@ func (cmd AppCommand) Execute(args []string) error {

func (cmd AppCommand) displayAppGUID() error {
app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/apply_manifest_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (cmd ApplyManifestCommand) Execute(args []string) error {
}

warnings, err := cmd.Actor.SetSpaceManifest(cmd.Config.TargetedSpace().GUID, cmd.Parser.FullRawManifest())
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/apps_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (cmd AppsCommand) Execute(args []string) error {
cmd.UI.DisplayNewline()

summaries, warnings, err := cmd.Actor.GetAppSummariesForSpace(cmd.Config.TargetedSpace().GUID, cmd.Labels)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/buildpacks_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (cmd BuildpacksCommand) Execute(args []string) error {
cmd.UI.DisplayNewline()

buildpacks, warnings, err := cmd.Actor.GetBuildpacks(cmd.Labels)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions command/v7/cancel_deployment_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ func (cmd *CancelDeploymentCommand) Execute(args []string) error {
)

application, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}

deployment, warnings, err := cmd.Actor.GetLatestActiveDeploymentForApp(application.GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}

warnings, err = cmd.Actor.CancelDeployment(deployment.GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/check_route_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (cmd CheckRouteCommand) Execute(args []string) error {

path := cmd.Path.Path
matches, warnings, err := cmd.Actor.CheckRoute(cmd.RequiredArgs.Domain, cmd.Hostname, path)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_app_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (cmd CreateAppCommand) Execute(args []string) error {
},
cmd.Config.TargetedSpace().GUID,
)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
switch err.(type) {
case ccerror.NameNotUniqueInSpaceError:
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_app_manifest_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd CreateAppManifestCommand) Execute(args []string) error {

spaceGUID := cmd.Config.TargetedSpace().GUID
manifestBytes, warnings, err := cmd.Actor.GetRawApplicationManifestByNameAndSpace(appName, spaceGUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions command/v7/create_buildpack_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (cmd CreateBuildpackCommand) Execute(args []string) error {
Position: types.NullInt{IsSet: true, Value: cmd.RequiredArgs.Position},
Enabled: types.NullBool{IsSet: true, Value: !cmd.Disable},
})
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand All @@ -102,10 +102,10 @@ func (cmd CreateBuildpackCommand) Execute(args []string) error {
})
jobURL, warnings, err := cmd.Actor.UploadBuildpack(createdBuildpack.GUID, pathToBuildpackBits, cmd.ProgressBar)
if _, ok := err.(ccerror.InvalidAuthTokenError); ok {
cmd.UI.DisplayWarnings([]string{"Failed to upload buildpack due to auth token expiration, retrying..."})
cmd.UI.DisplayWarningsV7([]string{"Failed to upload buildpack due to auth token expiration, retrying..."})
jobURL, warnings, err = cmd.Actor.UploadBuildpack(createdBuildpack.GUID, pathToBuildpackBits, cmd.ProgressBar)
}
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return cmd.wrapWithTip(err)
}
Expand All @@ -115,7 +115,7 @@ func (cmd CreateBuildpackCommand) Execute(args []string) error {
"BuildpackName": cmd.RequiredArgs.Buildpack,
})
warnings, err = cmd.Actor.PollUploadBuildpackJob(jobURL)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err != nil {
return cmd.wrapWithTip(err)
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_org_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (cmd CreateOrgCommand) Execute(args []string) error {

_, warnings, err := cmd.Actor.CreateOrganization(orgName)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
if _, ok := err.(ccerror.OrganizationNameTakenError); ok {
cmd.UI.DisplayText(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_package_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (cmd CreatePackageCommand) Execute(args []string) error {
pkg, warnings, err = cmd.Actor.CreateAndUploadBitsPackageByApplicationNameAndSpace(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID, string(cmd.AppPath))
}

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_private_domain_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (cmd CreatePrivateDomainCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.CreatePrivateDomain(domain, orgName)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_route_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (cmd CreateRouteCommand) Execute(args []string) error {

_, warnings, err := cmd.Actor.CreateRoute(spaceGUID, domain, hostname, pathName)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
if _, ok := err.(actionerror.RouteAlreadyExistsError); ok {
cmd.UI.DisplayWarningV7(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_service_broker_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (cmd *CreateServiceBrokerCommand) Execute(args []string) error {
}

warnings, err := cmd.Actor.CreateServiceBroker(cmd.RequiredArgs.ServiceBroker, cmd.RequiredArgs.Username, cmd.RequiredArgs.Password, cmd.RequiredArgs.URL, space.GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err == nil {
cmd.UI.DisplayOK()
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_shared_domain_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (cmd CreateSharedDomainCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.CreateSharedDomain(domain, cmd.Internal)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions command/v7/create_space_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (cmd CreateSpaceCommand) Execute(args []string) error {
} else {
orgName = cmd.Organization
org, warnings, err := cmd.Actor.GetOrganizationByName(orgName)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand All @@ -86,7 +86,7 @@ func (cmd CreateSpaceCommand) Execute(args []string) error {

_, warnings, err := cmd.Actor.CreateSpace(spaceName, orgGUID)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
if _, ok := err.(actionerror.SpaceAlreadyExistsError); ok {
cmd.UI.DisplayText(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion command/v7/create_user_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (cmd *CreateUserCommand) Execute(args []string) error {
})

_, warnings, err := cmd.Actor.CreateUser(cmd.Args.Username, password, cmd.Origin)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err != nil {
if _, ok := err.(uaa.ConflictError); ok {
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_buildpack_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (cmd DeleteBuildpackCommand) Execute(args []string) error {
})
}
warnings, err := cmd.Actor.DeleteBuildpackByNameAndStack(cmd.RequiredArgs.Buildpack, cmd.Stack)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err != nil {
switch err.(type) {
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (cmd DeleteCommand) Execute(args []string) error {
cmd.Config.TargetedSpace().GUID,
cmd.DeleteMappedRoutes,
)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
switch err.(type) {
case actionerror.ApplicationNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_org_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (cmd *DeleteOrgCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.DeleteOrganization(cmd.RequiredArgs.Organization)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
switch err.(type) {
case actionerror.OrganizationNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_orphaned_routes_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd DeleteOrphanedRoutesCommand) Execute(args []string) error {

warnings, err := cmd.Actor.DeleteOrphanedRoutes(cmd.Config.TargetedSpace().GUID)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions command/v7/delete_service_broker_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (cmd DeleteServiceBrokerCommand) Execute(args []string) error {

serviceBroker, warnings, err := cmd.Actor.GetServiceBrokerByName(serviceBrokerName)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
if _, ok := err.(actionerror.ServiceBrokerNotFoundError); ok {
// TODO: Verify the correct error message to display for idempotent case
Expand All @@ -90,7 +90,7 @@ func (cmd DeleteServiceBrokerCommand) Execute(args []string) error {

warnings, err = cmd.Actor.DeleteServiceBroker(serviceBroker.GUID)

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions command/v7/delete_shared_domain_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (cmd DeleteSharedDomainCommand) Execute(args []string) error {
})

domain, warnings, err := cmd.Actor.GetDomainByName(domainName)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)

if err != nil {
if _, ok := err.(actionerror.DomainNotFoundError); ok {
Expand All @@ -99,7 +99,7 @@ func (cmd DeleteSharedDomainCommand) Execute(args []string) error {
}

warnings, err = cmd.Actor.DeleteDomain(domain)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_space_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (cmd DeleteSpaceCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.DeleteSpaceByNameAndOrganizationName(cmd.RequiredArgs.Space, orgName)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
switch err.(type) {
case actionerror.SpaceNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion command/v7/delete_user_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (cmd *DeleteUserCommand) Execute(args []string) error {
return err
}

cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
cmd.UI.DisplayOK()

return nil
Expand Down
2 changes: 1 addition & 1 deletion command/v7/disable_feature_flag_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (cmd DisableFeatureFlagCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.DisableFeatureFlag(cmd.RequiredArgs.Feature)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions command/v7/disable_ssh_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ func (cmd *DisableSSHCommand) Execute(args []string) error {
if err != nil {
return err
}
cmd.UI.DisplayWarnings(getAppWarnings)
cmd.UI.DisplayWarningsV7(getAppWarnings)

appFeature, getAppFeatureWarnings, err := cmd.Actor.GetAppFeature(app.GUID, "ssh")
if err != nil {
return err
}

cmd.UI.DisplayWarnings(getAppFeatureWarnings)
cmd.UI.DisplayWarningsV7(getAppFeatureWarnings)

if !appFeature.Enabled {
cmd.UI.DisplayTextWithFlavor("ssh support for app '{{.AppName}}' is already disabled.", map[string]interface{}{
Expand All @@ -83,7 +83,7 @@ func (cmd *DisableSSHCommand) Execute(args []string) error {
return err
}

cmd.UI.DisplayWarnings(updateSSHWarnings)
cmd.UI.DisplayWarningsV7(updateSSHWarnings)
cmd.UI.DisplayOK()
return nil
}
2 changes: 1 addition & 1 deletion command/v7/domains_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (cmd DomainsCommand) Execute(args []string) error {
})

domains, warnings, err := cmd.Actor.GetOrganizationDomains(targetedOrg.GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/droplets_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (cmd DropletsCommand) Execute(args []string) error {
cmd.UI.DisplayNewline()

droplets, warnings, err := cmd.Actor.GetApplicationDroplets(cmd.RequiredArgs.AppName, cmd.Config.TargetedSpace().GUID)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion command/v7/enable_feature_flag_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (cmd EnableFeatureFlagCommand) Execute(args []string) error {
})

warnings, err := cmd.Actor.EnableFeatureFlag(cmd.RequiredArgs.Feature)
cmd.UI.DisplayWarnings(warnings)
cmd.UI.DisplayWarningsV7(warnings)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions command/v7/enable_ssh_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ func (cmd *EnableSSHCommand) Execute(args []string) error {
if err != nil {
return err
}
cmd.UI.DisplayWarnings(getAppWarnings)
cmd.UI.DisplayWarningsV7(getAppWarnings)

appFeature, getAppFeatureWarnings, err := cmd.Actor.GetAppFeature(app.GUID, "ssh")
if err != nil {
return err
}

cmd.UI.DisplayWarnings(getAppFeatureWarnings)
cmd.UI.DisplayWarningsV7(getAppFeatureWarnings)

if appFeature.Enabled {
cmd.UI.DisplayTextWithFlavor("ssh support for app '{{.AppName}}' is already enabled.", map[string]interface{}{
Expand All @@ -83,13 +83,13 @@ func (cmd *EnableSSHCommand) Execute(args []string) error {
if err != nil {
return err
}
cmd.UI.DisplayWarnings(updateSSHWarnings)
cmd.UI.DisplayWarningsV7(updateSSHWarnings)

sshEnabled, getSSHEnabledWarnings, err := cmd.Actor.GetSSHEnabled(app.GUID)
if err != nil {
return err
}
cmd.UI.DisplayWarnings(getSSHEnabledWarnings)
cmd.UI.DisplayWarningsV7(getSSHEnabledWarnings)

cmd.UI.DisplayOK()

Expand Down
Loading

0 comments on commit 4762b0f

Please sign in to comment.