Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add products command #516

Merged
merged 4 commits into from
Oct 16, 2020
Merged

Add products command #516

merged 4 commits into from
Oct 16, 2020

Conversation

iplay88keys
Copy link

@iplay88keys iplay88keys commented Oct 14, 2020

  • Lists available, staged, and deployed products
  • Replaces 'available-products', 'staged-products', and 'deployed-products' commands
  • Update docs around products command
  • Add deprecation notices to 'available-products', 'staged-products', and 'deployed-products' commands

Resolves #466

* Lists available, staged, and deployed products
* Replaces 'available-products', 'staged-products', and 'deployed-products' commands
* Update docs around products command
* Add deprecation notices to 'available-products', 'staged-products', and 'deployed-products' commands
@cf-gitbot
Copy link
Member

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

@iplay88keys
Copy link
Author

iplay88keys commented Oct 14, 2020

Supports any combination of --available/-a, --staged/-s, and --deployed/-d with the default command showing all three columns. The list of products is sorted alphabetically.

om products

+-----------------------------+-----------------+-----------------+-----------------+
|            NAME             |    AVAILABLE    |     STAGED      |    DEPLOYED     |
+-----------------------------+-----------------+-----------------+-----------------+
| appMetrics                  | 2.0.6-dev.005   | 2.0.6-dev.005   | 2.0.6-dev.005   |
| cf                          | 2.8.16          | 2.8.16          | 2.8.16          |
| metric-store                | 1.4.4           | 1.4.4           | 1.4.4           |
| p-bosh                      |                 | 2.8.2-build.203 | 2.8.2-build.203 |
| p-event-alerts              | 1.2.9-build.1   | 1.2.9-build.1   | 1.2.9-build.1   |
| p-healthwatch               | 1.8.2-build.1   | 1.8.3-build.3   | 1.8.2-build.1   |
| p-healthwatch2              | 2.0.5-build.84  | 2.0.5-build.84  | 2.0.5-build.84  |
| p-healthwatch2-pas-exporter | 2.0.5-build.84  | 2.0.5-build.84  | 2.0.5-build.84  |
| p-isolation-segment         | 2.8.2           | 2.8.2           | 2.8.2           |
| p-rabbitmq                  | 1.19.1-build.22 | 1.19.1-build.22 | 1.19.1-build.22 |
| p-redis                     | 2.3.1-build.36  | 2.3.1-build.36  | 2.3.1-build.36  |
| pivotal-mysql               | 2.8.0-build.111 | 2.8.0-build.111 | 2.8.0-build.111 |
| pivotal-telemetry-om        | 1.0.1-build.2   | 1.0.1-build.2   | 1.0.1-build.2   |
+-----------------------------+-----------------+-----------------+-----------------+
om products --deployed
+-----------------------------+-----------------+
|            NAME             |    DEPLOYED     |
+-----------------------------+-----------------+
| appMetrics                  | 2.0.6-dev.005   |
| cf                          | 2.8.16          |
| metric-store                | 1.4.4           |
| p-bosh                      | 2.8.2-build.203 |
| p-event-alerts              | 1.2.9-build.1   |
| p-healthwatch               | 1.8.2-build.1   |
| p-healthwatch2              | 2.0.5-build.84  |
| p-healthwatch2-pas-exporter | 2.0.5-build.84  |
| p-isolation-segment         | 2.8.2           |
| p-rabbitmq                  | 1.19.1-build.22 |
| p-redis                     | 2.3.1-build.36  |
| pivotal-mysql               | 2.8.0-build.111 |
| pivotal-telemetry-om        | 1.0.1-build.2   |
+-----------------------------+-----------------+

@iplay88keys
Copy link
Author

There are probably some edge cases that need to be thought through.

@jtarchie
Copy link
Contributor

jtarchie commented Oct 14, 2020

We just tried with available-products on our test environment.

With -a,

+---------------------------+----------------+
|           NAME            |   AVAILABLE    |
+---------------------------+----------------+
| cf                        | 2.9.8          |
| p-bosh                    |                |
| p-healthwatch             | 1.8.2-build.1  |
| pivotal-container-service | 1.7.0-build.26 |
| pivotal-telemetry-om      | 1.1.1-build.5  |
+---------------------------+----------------+

When we run it with the command available-products,

+---------------------------+----------------+
|           NAME            |    VERSION     |
+---------------------------+----------------+
| p-healthwatch             | 1.8.1-build.1  |
| pivotal-telemetry-om      | 1.1.0-build.4  |
| p-healthwatch             | 1.8.2-build.1  |
| pivotal-container-service | 1.7.0-build.26 |
| cf                        | 2.9.8          |
| pivotal-telemetry-om      | 1.1.1-build.5  |
+---------------------------+----------------+

There is a difference of:

  • the -a shows p-bosh, the other does not
  • the command available-products shows to versions of p-healthwatch

@iplay88keys
Copy link
Author

Cool, I'll look into those and push a change with the fixes!

@kcboyle
Copy link
Contributor

kcboyle commented Oct 14, 2020

Keep in mind the combined view @eitansuez linked in the issue for as well (the empty line so that everything organizes nice)
so for available products:

+---------------------------+----------------+
|           NAME            |    VERSION     |
+---------------------------+----------------+
| p-healthwatch             | 1.8.1-build.1  |
|                           | 1.8.2-build.1  |
| pivotal-telemetry-om      | 1.1.0-build.4  |
| pivotal-container-service | 1.7.0-build.26 |
| cf                        | 2.9.8          |
| pivotal-telemetry-om      | 1.1.1-build.5  |
+---------------------------+----------------+

- Hide products if they have no versions that satisfy the requested columns
- Display multiple available product versions
@iplay88keys
Copy link
Author

Here's the updated output for om products:

+-----------------------------+-----------------+-----------------+-----------------+
|            NAME             |    AVAILABLE    |     STAGED      |    DEPLOYED     |
+-----------------------------+-----------------+-----------------+-----------------+
| appMetrics                  | 2.0.6-dev.005   | 2.0.6-dev.005   | 2.0.6-dev.005   |
| cf                          | 2.8.16          | 2.8.16          | 2.8.16          |
| metric-store                | 1.4.4           | 1.4.4           | 1.4.4           |
| p-event-alerts              | 1.2.9-build.1   | 1.2.9-build.1   | 1.2.9-build.1   |
| p-healthwatch               | 1.8.2-build.1   | 1.8.3-build.3   | 1.8.2-build.1   |
|                             | 1.8.3-build.3   |                 |                 |
| p-healthwatch2              | 2.0.5-build.84  | 2.0.5-build.84  | 2.0.5-build.84  |
| p-healthwatch2-pas-exporter | 2.0.5-build.84  | 2.0.5-build.84  | 2.0.5-build.84  |
| p-isolation-segment         | 2.8.2           | 2.8.2           | 2.8.2           |
| p-rabbitmq                  | 1.19.1-build.22 | 1.19.1-build.22 | 1.19.1-build.22 |
| p-redis                     | 2.3.1-build.36  | 2.3.1-build.36  | 2.3.1-build.36  |
| pivotal-mysql               | 2.8.0-build.111 | 2.8.0-build.111 | 2.8.0-build.111 |
| pivotal-telemetry-om        | 1.0.1-build.2   | 1.0.1-build.2   | 1.0.1-build.2   |
+-----------------------------+-----------------+-----------------+-----------------+

And om products -a:

+-----------------------------+-----------------+
|            NAME             |    AVAILABLE    |
+-----------------------------+-----------------+
| appMetrics                  | 2.0.6-dev.005   |
| cf                          | 2.8.16          |
| metric-store                | 1.4.4           |
| p-event-alerts              | 1.2.9-build.1   |
| p-healthwatch               | 1.8.2-build.1   |
|                             | 1.8.3-build.3   |
| p-healthwatch2              | 2.0.5-build.84  |
| p-healthwatch2-pas-exporter | 2.0.5-build.84  |
| p-isolation-segment         | 2.8.2           |
| p-rabbitmq                  | 1.19.1-build.22 |
| p-redis                     | 2.3.1-build.36  |
| pivotal-mysql               | 2.8.0-build.111 |
| pivotal-telemetry-om        | 1.0.1-build.2   |
+-----------------------------+-----------------+

@iplay88keys
Copy link
Author

Seems like I dropped the p-bosh from the overall product view. I'll look into why that is.

@kcboyle
Copy link
Contributor

kcboyle commented Oct 15, 2020

All Comparison outputs (for documentation purposes):

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml deployed-products
+---------------------------+-----------------+
|           NAME            |     VERSION     |
+---------------------------+-----------------+
| pivotal-container-service | 1.7.0-build.26  |
| cf                        | 2.9.8           |
| p-healthwatch             | 1.8.1-build.1   |
| p-bosh                    | 2.9.6-build.148 |
| pivotal-telemetry-om      | 1.1.1-build.5   |
+---------------------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products -d
+---------------------------+-----------------+
|           NAME            |    DEPLOYED     |
+---------------------------+-----------------+
| cf                        | 2.9.8           |
| p-bosh                    | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1   |
| pivotal-container-service | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.1-build.5   |
+---------------------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml available-products
+---------------------------+----------------+
|           NAME            |    VERSION     |
+---------------------------+----------------+
| p-healthwatch             | 1.8.1-build.1  |
| pivotal-telemetry-om      | 1.1.0-build.4  |
| p-healthwatch             | 1.8.2-build.1  |
| pivotal-container-service | 1.7.0-build.26 |
| cf                        | 2.9.8          |
| pivotal-telemetry-om      | 1.1.1-build.5  |
+---------------------------+----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products -a
+---------------------------+----------------+
|           NAME            |   AVAILABLE    |
+---------------------------+----------------+
| cf                        | 2.9.8          |
| p-healthwatch             | 1.8.1-build.1  |
|                           | 1.8.2-build.1  |
| pivotal-container-service | 1.7.0-build.26 |
| pivotal-telemetry-om      | 1.1.0-build.4  |
|                           | 1.1.1-build.5  |
+---------------------------+----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml staged-products
+---------------------------+-----------------+
|           NAME            |     VERSION     |
+---------------------------+-----------------+
| pivotal-container-service | 1.7.0-build.26  |
| cf                        | 2.9.8           |
| p-healthwatch             | 1.8.1-build.1   |
| p-bosh                    | 2.9.6-build.148 |
| pivotal-telemetry-om      | 1.1.1-build.5   |
+---------------------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products -s
+---------------------------+-----------------+
|           NAME            |     STAGED      |
+---------------------------+-----------------+
| cf                        | 2.9.8           |
| p-bosh                    | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1   |
| pivotal-container-service | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.1-build.5   |
+---------------------------+-----------------+

 → go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products
+---------------------------+----------------+-----------------+-----------------+
|           NAME            |   AVAILABLE    |     STAGED      |    DEPLOYED     |
+---------------------------+----------------+-----------------+-----------------+
| cf                        | 2.9.8          | 2.9.8           | 2.9.8           |
| p-bosh                    |                | 2.9.6-build.148 | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1  | 1.8.1-build.1   | 1.8.1-build.1   |
|                           | 1.8.2-build.1  |                 |                 |
| pivotal-container-service | 1.7.0-build.26 | 1.7.0-build.26  | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.0-build.4  | 1.1.1-build.5   | 1.1.1-build.5   |
|                           | 1.1.1-build.5  |                 |                 |
+---------------------------+----------------+-----------------+-----------------+

It looks real good (in terms of output) IMO. It takes the same display and functionality, and makes it easier to read and look at. Thanks for alphabetizing the products, too. that adds a lot.

Looking at the commits now

productVersionsCombiner[product.Name] = productVersions
}

for _, product := range deployedProducts {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section is clear, and easy to read. If I'm trying to be nitpicky, I'd love to see these for loops in functions (combineStagedProducts, combineAvailableProducts, combineDeployedProducts or something similar)
Just to let this flow top->bottom a little faster without the for loop break

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if these functions also have the sp receiver like Execute, you can also clean up some of the earlier setup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason I didn't pull these into separate functions was the complexity of their signatures when using Intellij's extract method feature. It might not have actually needed to be that complicated, though. I just didn't dig further at that point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had a quick additional commit to implement this.

@kcboyle
Copy link
Contributor

kcboyle commented Oct 15, 2020

Added a couple more display check tests. Adding the outputs here for documentation
Notes:

  • the list headers will display in alphabetical order, no matter what order you give the flags in
  • combining flags is 100% allowed
  • duplicated flags don't break
→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --staged --deployed
+---------------------------+-----------------+-----------------+
|           NAME            |     STAGED      |    DEPLOYED     |
+---------------------------+-----------------+-----------------+
| cf                        | 2.9.8           | 2.9.8           |
| p-bosh                    | 2.9.6-build.148 | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1   | 1.8.1-build.1   |
| pivotal-container-service | 1.7.0-build.26  | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.1-build.5   | 1.1.1-build.5   |
+---------------------------+-----------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --staged --available
+---------------------------+----------------+-----------------+
|           NAME            |   AVAILABLE    |     STAGED      |
+---------------------------+----------------+-----------------+
| cf                        | 2.9.8          | 2.9.8           |
| p-bosh                    |                | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1  | 1.8.1-build.1   |
|                           | 1.8.2-build.1  |                 |
| pivotal-container-service | 1.7.0-build.26 | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.0-build.4  | 1.1.1-build.5   |
|                           | 1.1.1-build.5  |                 |
+---------------------------+----------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --available --deployed
+---------------------------+----------------+-----------------+
|           NAME            |   AVAILABLE    |    DEPLOYED     |
+---------------------------+----------------+-----------------+
| cf                        | 2.9.8          | 2.9.8           |
| p-bosh                    |                | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1  | 1.8.1-build.1   |
|                           | 1.8.2-build.1  |                 |
| pivotal-container-service | 1.7.0-build.26 | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.0-build.4  | 1.1.1-build.5   |
|                           | 1.1.1-build.5  |                 |
+---------------------------+----------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --deployed --staged
+---------------------------+-----------------+-----------------+
|           NAME            |     STAGED      |    DEPLOYED     |
+---------------------------+-----------------+-----------------+
| cf                        | 2.9.8           | 2.9.8           |
| p-bosh                    | 2.9.6-build.148 | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1   | 1.8.1-build.1   |
| pivotal-container-service | 1.7.0-build.26  | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.1-build.5   | 1.1.1-build.5   |
+---------------------------+-----------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --deployed --staged --deployed
+---------------------------+-----------------+-----------------+
|           NAME            |     STAGED      |    DEPLOYED     |
+---------------------------+-----------------+-----------------+
| cf                        | 2.9.8           | 2.9.8           |
| p-bosh                    | 2.9.6-build.148 | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1   | 1.8.1-build.1   |
| pivotal-container-service | 1.7.0-build.26  | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.1-build.5   | 1.1.1-build.5   |
+---------------------------+-----------------+-----------------+

→ go run main.go --env ~/workspace/platform-automation-deployments/reference-gcp/env.yml products --deployed --staged --available
+---------------------------+----------------+-----------------+-----------------+
|           NAME            |   AVAILABLE    |     STAGED      |    DEPLOYED     |
+---------------------------+----------------+-----------------+-----------------+
| cf                        | 2.9.8          | 2.9.8           | 2.9.8           |
| p-bosh                    |                | 2.9.6-build.148 | 2.9.6-build.148 |
| p-healthwatch             | 1.8.1-build.1  | 1.8.1-build.1   | 1.8.1-build.1   |
|                           | 1.8.2-build.1  |                 |                 |
| pivotal-container-service | 1.7.0-build.26 | 1.7.0-build.26  | 1.7.0-build.26  |
| pivotal-telemetry-om      | 1.1.0-build.4  | 1.1.1-build.5   | 1.1.1-build.5   |
|                           | 1.1.1-build.5  |                 |                 |
+---------------------------+----------------+-----------------+-----------------+

var outputData []string

moreAvailableProducts = false
if products.Available {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lost of nested ifs in these for loops.
This is still clear, but aesthetically could put the logic of these if blocks into functions to make the nesting a little less crazy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I was definitely running short on time when doing this and wanted something working before the refactoring step.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking into this now, and refactoring is a little more complicated. We looked into it and are not going to refactor. Maybe there's a good way to do it, but not as simple as originally thought

@kcboyle
Copy link
Contributor

kcboyle commented Oct 15, 2020

Added a couple refactor suggestions in the commits @iplay88keys
Nothing major, just a couple minor things if you're so inclined.

Thank you for re-generating docs 👍

@kcboyle kcboyle merged commit e78c22f into pivotal-cf:main Oct 16, 2020
@kcboyle
Copy link
Contributor

kcboyle commented Oct 16, 2020

Merged

@iplay88keys iplay88keys deleted the products-command branch October 19, 2020 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a command to display available, staged, and deployed products alongside each other
4 participants