Skip to content

Commit

Permalink
feat!: remove legacy client run-examples command (#729)
Browse files Browse the repository at this point in the history
- New "csb run-examples" and "csb examples" commands have been
introduced and we have got good feedback on them
- This commit removes the "csb client run-examples" and
"csb client examples" commands since we believe they are now superfluous
- The commands can be added back by setting the feature flag
`CSB_ENABLE_LEGACY_EXAMPLES_COMMANDS=1`, but if you do this,
please raise an issue to let us know as otherwise we will remove
the functionality completely in a future release

Co-authored-by: Andrea Zucchini <zandrea@vmware.com>
  • Loading branch information
blgm and zucchinidev authored Feb 13, 2023
1 parent b2d26f2 commit cdbe5c7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 41 deletions.
13 changes: 8 additions & 5 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"encoding/json"
"log"

"github.com/pborman/uuid"
"github.com/pivotal-cf/brokerapi/v8/domain"
"github.com/spf13/cobra"

"github.com/cloudfoundry/cloud-service-broker/pkg/client"
"github.com/cloudfoundry/cloud-service-broker/pkg/featureflags"
"github.com/cloudfoundry/cloud-service-broker/pkg/server"
"github.com/cloudfoundry/cloud-service-broker/utils"
"github.com/pborman/uuid"
"github.com/pivotal-cf/brokerapi/v8/domain"
"github.com/spf13/cobra"
)

var (
Expand Down Expand Up @@ -150,7 +150,10 @@ user-defined plans.
},
}

clientCmd.AddCommand(clientCatalogCmd, provisionCmd, deprovisionCmd, bindCmd, unbindCmd, lastCmd, runExamplesCmd, updateCmd, examplesCmd)
clientCmd.AddCommand(clientCatalogCmd, provisionCmd, deprovisionCmd, bindCmd, unbindCmd, lastCmd, updateCmd)
if featureflags.Enabled(featureflags.EnableLegacyExamplesCommands) {
clientCmd.AddCommand(runExamplesCmd, examplesCmd)
}

bindFlag := func(dest *string, name, description string, commands ...*cobra.Command) {
for _, sc := range commands {
Expand Down
26 changes: 6 additions & 20 deletions docs/brokerpak-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,34 +227,20 @@ If the *examples* section of the brokerpak is not empty, it is possible (and adv

> For example purposes, this is the AWS broker, so AWS credentials are provided through environment variables. See [AWS brokerpak readme](../aws-brokerpak/README.md).
#### Run Broker

In one command shell, start the broker:
In the brokerpak repo root, run:
```bash
csb run-examples --all
```

Or when using Docker:
```bash
docker run --rm -v ${BROKERPAK_SRC_DIR}:/brokerpak -w /brokerpak \
-p 8080:8080 \
-e "SECURITY_USER_NAME=csb-un" \
-e "SECURITY_USER_PASSWORD=csb-pw" \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_ACCESS_KEY \
-e "DB_TYPE=sqlite3" \
-e "DB_PATH=/tmp/csb-db" \
cfplatformeng/csb serve
```

#### Run Example Tests

In a second command shell, run the examples:

```bash
docker run --rm -v ${BROKERPAK_SRC_DIR}:/brokerpak -w /brokerpak \
-e "SECURITY_USER_NAME=csb-un" \
-e "SECURITY_USER_PASSWORD=csb-pw" \
-e "GSB_API_HOSTNAME=host.docker.internal" \
-e "GSB_API_PORT=8080" \
-e USER \
cfplatformeng/csb pak run-examples /brokerpak/$(ls *.brokerpak)
cfplatformeng/csb run-examples --all
```

If this completes successfully, it means all the examples in the brokerpak successfully completed a provision, bind, unbind and deprovision lifecycle.
14 changes: 0 additions & 14 deletions k8s/run-client-examples.sh

This file was deleted.

11 changes: 9 additions & 2 deletions pkg/featureflags/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ const (
TfUpgradeEnabled FeatureFlagName = "brokerpak.terraform.upgrades.enabled"
DynamicHCLEnabled FeatureFlagName = "brokerpak.updates.enabled"
DisableRequestPropertyValidation FeatureFlagName = "request.property.validation.disabled"

// EnableLegacyExamplesCommands enabled the old way of running example tests
// IF YOU USE THIS, PLEASE RAISE AN ISSUE. Since the new way of running examples was added,
// the authors don't expect anyone to use the legacy method. Please let us know if you need
// the old way to stay around.
EnableLegacyExamplesCommands FeatureFlagName = "legacy.examples.enabled"
)

func init() {
for ffName, varName := range map[FeatureFlagName]string{
TfUpgradeEnabled: "TERRAFORM_UPGRADES_ENABLED",
DynamicHCLEnabled: "BROKERPAK_UPDATES_ENABLED",
TfUpgradeEnabled: "TERRAFORM_UPGRADES_ENABLED", // deprecated pattern - future variables should start CSB_
DynamicHCLEnabled: "BROKERPAK_UPDATES_ENABLED", // deprecated pattern - future variables should start CSB_
DisableRequestPropertyValidation: "CSB_DISABLE_REQUEST_PROPERTY_VALIDATION",
EnableLegacyExamplesCommands: "CSB_ENABLE_LEGACY_EXAMPLES_COMMANDS",
} {
viper.BindEnv(string(ffName), varName)
viper.SetDefault(string(ffName), false)
Expand Down

0 comments on commit cdbe5c7

Please sign in to comment.