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 field-selector argument to installations list #2888

Conversation

maniSbindra
Copy link
Contributor

@maniSbindra maniSbindra commented Aug 28, 2023

What does this change

Filter output of porter installation list based on any field/combination of fields using the --field-selector". Supports '=' ,e.g. --field-selector bundle.version=0.2.0,status.action=install. All fields from the json output are supported.

Output below

# output without field selector
$ porter installation list                                                                                                                        
--------------------------------------------------------------------------------
  NAMESPACE  NAME                    VERSION  STATE      STATUS     MODIFIED    
--------------------------------------------------------------------------------
             differentporterinstall  0.2.0    installed  succeeded  2023-08-24  
             porter-hello            0.2.0    installed  succeeded  2023-08-21

# output using field selector
$ porter installation list --field-selector  "name=porter-hello,bundle.version=0.2.0,status.action=install,status.resultStatus=succeeded" 
----------------------------------------------------------------------
  NAMESPACE  NAME          VERSION  STATE      STATUS     MODIFIED    
----------------------------------------------------------------------
             porter-hello  0.2.0    installed  succeeded  2023-08-21

# json output using field selector
$  porter installation list --field-selector  "name=porter-hello,bundle.version=0.2.0,status.action=install,status.resultStatus=succeeded"  -o json
[
  {
    "schemaType": "Installation",
    "schemaVersion": "1.0.2",
    "id": "01H8C1V1G19AH4PMQHAJ8PZBX9",
    "name": "porter-hello",
    "namespace": "",
    "bundle": {
      "repository": "ghcr.io/getporter/examples/porter-hello",
      "version": "0.2.0"
    },
    "status": {
      "runId": "01H8C1V4YEPKQK098NRFKD4AYQ",
      "action": "install",
      "resultId": "01H8C1VGHPZCEZRP3J4ATYCX3X",
      "resultStatus": "succeeded",
      "created": "2023-08-21T18:11:42.657996+05:30",
      "modified": "2023-08-21T18:11:46.125495+05:30",
      "installed": "2023-08-21T18:11:58.070842+05:30",
      "uninstalled": null,
      "bundleReference": "ghcr.io/getporter/examples/porter-hello:v0.2.0",
      "bundleVersion": "0.2.0",
      "bundleDigest": "sha256:276b44be3f478b4c8d1f99c1925386d45a878a853f22436ece5589f32e9df384"
    },
    "_calculated": {
      "resolvedParameters": null,
      "displayInstallationState": "installed",
      "displayInstallationStatus": "succeeded"
    }
  }
]

What issue does it fix

Closes #2871 and #2773

Notes for the reviewer

This implementation filters to be displayed installations based on the --field-selector argument, which supports filtering by all fields in the json output of porter installation list.

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

@ludfjig
Copy link
Contributor

ludfjig commented Aug 28, 2023

/azp run porter-integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

CONTRIBUTORS.md Outdated Show resolved Hide resolved
pkg/porter/list.go Outdated Show resolved Hide resolved
Signed-off-by: Maninderjit Bindra <[email protected]>
Signed-off-by: Maninderjit Bindra <[email protected]>
@maniSbindra maniSbindra force-pushed the manisbindra/porter-installations-list-add-field-selector-argument branch from 20332aa to 245337f Compare August 29, 2023 06:22
Copy link
Member

@troy0820 troy0820 left a comment

Choose a reason for hiding this comment

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

Some nits and some comments to request changes around using reflect with installation/displayinstallation, etc.

The splitting on . and , and interface{}.

pkg/porter/list.go Show resolved Hide resolved
pkg/porter/list.go Outdated Show resolved Hide resolved
pkg/porter/list.go Show resolved Hide resolved
pkg/porter/list.go Show resolved Hide resolved
pkg/porter/list.go Outdated Show resolved Hide resolved
pkg/porter/list.go Show resolved Hide resolved
pkg/porter/list.go Show resolved Hide resolved
pkg/porter/list.go Show resolved Hide resolved
Signed-off-by: Maninderjit Bindra <[email protected]>
@maniSbindra
Copy link
Contributor Author

maniSbindra commented Sep 4, 2023

Some nits and some comments to request changes around using reflect with installation/displayinstallation, etc.

The splitting on . and , and interface{}.

@troy0820 I have made modifications as per our discussion. Thanks

Copy link
Member

@schristoff schristoff left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you so much!!

@schristoff schristoff merged commit 513c0a0 into getporter:main Sep 14, 2023
14 checks passed
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.

porter installation list advanced filtering
4 participants