Skip to content

Standardize table printing#1876

Merged
carolynvs merged 3 commits intogetporter:release/v1from
carolynvs:line-wrap
Jan 28, 2022
Merged

Standardize table printing#1876
carolynvs merged 3 commits intogetporter:release/v1from
carolynvs:line-wrap

Conversation

@carolynvs
Copy link
Copy Markdown
Member

What does this change

Only use a single table printing library, with support for proper column
wrapping when data is a column is very long. We have been having trouble
with column data being so wide the table is unreadable when the terminal
forces the text to wrap.

This also updates all of Porter to use the single library, which has a
slightly different output (it adds a line under the table headers). When
I went through and updated all the expected console output tests, I took
the opportuntity to use the improved test.CompareToGoldenFile helper,
which makes syncing the expected test output much easier.

What issue does it fix

Fixes #1448

Notes for the reviewer

I split this into 3 commits for easier reviewing and will squash when I merge.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

Only use a single table printing library, with support for proper column
wrapping when data is a column is very long. We have been having trouble
with column data being so wide the table is unreadable when the terminal
forces the text to wrap.

This also updates all of Porter to use the single library, which has a
slightly different output (it adds a line under the table headers). When
I went through and updated all the expected console output tests, I took
the opportuntity to use the improved test.CompareToGoldenFile helper,
which makes syncing the expected test output much easier.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Update tests to use test.CompareGoldenFile

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
When the golden file for a test doesn't exist, create it. This makes it
easier to get started using golden files without having to create the
empty file first. You can just edit the test to use that helper and it
will make the file for you when run with mage updatetestfiles

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs
Copy link
Copy Markdown
Member Author

Here is what the output looks like for a reasonably complex bundle now:

$ porter explain -r ghcr.io/getporter/porter-operator:v0.3.0
Name: porter-operator
Description: The Porter Operator for Kubernetes. Execute bundles on a Kubernetes cluster.
Version: 0.3.0
Porter Version: v1.0.0-alpha.8

Credentials:
---------------------------------------------------------------------
  Name        Description                     Required  Applies To
---------------------------------------------------------------------
  kubeconfig  Kubeconfig file for cluster     true      All Actions
              where the operator should be
              installed

Parameters:
------------------------------------------------------------------------------------------------------------------
  Name                        Description                     Type    Default       Required  Applies To
------------------------------------------------------------------------------------------------------------------
  installationServiceAccount  Name of the service account     string                false     configureNamespace
                              to run installation with.
                              If set, you are responsible
                              for creating this service
                              account and giving it required
                              permissions.
  namespace                   Setup Porter in this namespace  string  <nil>         true      configureNamespace
  porterConfig                Porter config file, in yaml,    file                  false     configureNamespace
                              same as ~/.porter/config.yaml
  porterRepository            Docker image repository of      string                false     configureNamespace
                              the Porter agent. Defaults to
                              ghcr.io/getporter/porter.
  porterVersion               Version of the Porter agent,    string                false     configureNamespace
                              e.g. latest, canary, v0.33.0.
                              Defaults to latest.
  pullPolicy                  Specifies how the Porter agent  string                false     configureNamespace
                              image should be pulled. Does
                              not affect how bundles are
                              pulled. Defaults to PullAlways
                              for latest and canary, and
                              PullIfNotPresent otherwise.
  serviceAccount              Name of the service account     string  porter-agent  false     configureNamespace
                              to run the Porter agent.
                              If set, you are responsible
                              for creating this service
                              account and binding it to
                              the porter-agent ClusterRole.
                              Defaults to the porter-agent
                              account created by the
                              configureNamespace custom
                              action.
  volumeSize                  Size of the volume shared       string                false     configureNamespace
                              between Porter and the bundles
                              it executes. Defaults to 64Mi.

Actions:
----------------------------------------------------------------------------------------
  Name                Description                     Modifies Installation  Stateless
----------------------------------------------------------------------------------------
  configureNamespace  Add necessary rbac, service     false                  false
                      account and configuration
                      to use Porter Operator in
                      a namespace. Creates the
                      namespace if it does not
                      already exist.
  removeData          Remove Porter Operator data,    false                  false
                      such as namespaces used
                      with configureNamespace,
                      configuration, jobs, etc.
                      These are not removed during
                      uninstall.

This bundle uses the following tools: exec, helm3, kubernetes.

To install this bundle run the following command, passing --param KEY=VALUE for any parameters you want to customize:
porter credentials generate mycreds --reference ghcr.io/getporter/porter-operator:v0.3.0
porter install --reference ghcr.io/getporter/porter-operator:v0.3.0 --param namespace=TODO --cred mycreds

@carolynvs carolynvs marked this pull request as ready for review January 27, 2022 20:56
@carolynvs carolynvs requested review from VinozzZ, joshuabezaleel and vdice and removed request for jeremyrickard and vdice January 27, 2022 20:56
@carolynvs carolynvs merged commit 01ff3a7 into getporter:release/v1 Jan 28, 2022
@carolynvs carolynvs deleted the line-wrap branch January 28, 2022 20:43
joshuabezaleel pushed a commit to joshuabezaleel/porter that referenced this pull request Feb 8, 2022
* Standardize table printing

Only use a single table printing library, with support for proper column
wrapping when data is a column is very long. We have been having trouble
with column data being so wide the table is unreadable when the terminal
forces the text to wrap.

This also updates all of Porter to use the single library, which has a
slightly different output (it adds a line under the table headers). When
I went through and updated all the expected console output tests, I took
the opportuntity to use the improved test.CompareToGoldenFile helper,
which makes syncing the expected test output much easier.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

* Update code to use new table printer

Update tests to use test.CompareGoldenFile

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

* Improve test.CompareGoldenFile

When the golden file for a test doesn't exist, create it. This makes it
easier to get started using golden files without having to create the
empty file first. You can just edit the test to use that helper and it
will make the file for you when run with mage updatetestfiles

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Signed-off-by: joshuabezaleel <joshua.bezaleel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants