Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

[feat-633-bundle-actions-cmd] Add bundle actions command #666

Merged
merged 3 commits into from Apr 6, 2019

Conversation

radu-matei
Copy link
Member

close #633

This PR adds a duffle bundle actions command that reads all actions from a bundle and displays them.

To test this, the following bundle file can be used:

{
  "actions": {
    "dry-run": {
      "description": "prints what install would do with the given parameters values",
      "modifies": false,
      "stateless": true
    },
    "migrate": {
      "description": "migration action",
      "modifies": false
    },
    "status": {
      "description": "retrieves the status of an installation",
      "modifies": false
    }
  },
  "credentials": null,
  "description": "A short description of your bundle",
  "images": null,
  "invocationImages": [
    {
      "image": "padme/awesome-bundle-cnab:acff9ea424b7735b7cd6c342b7a6073f35337658",
      "imageType": "docker",
      "platform": {}
    }
  ],
  "keywords": [
    "cnab"
  ],
  "maintainers": [
    {
      "email": "padme@admidala.dev",
      "name": "Padme Amidala",
      "url": ""
    }
  ],
  "name": "awesome-bundle",
  "parameters": null,
  "version": "0.1.0"
}

Alternatively, the bundle can be build, and/or signed using duffle build.

$ duffle bundle actions -f bundle.json --insecure
ACTION 	STATELESS	MODIFIES	DESCRIPTION                                                  
migrate	false    	false   	migration action                                             
status 	false    	false   	retrieves the status of an installation                      
dry-run	true     	false   	prints what install would do with the given parameters values

cc @itowlson -- do you need this command to output JSON / other formats for the VS Code extension?

@ghost ghost assigned radu-matei Mar 15, 2019
@ghost ghost added the review label Mar 15, 2019
Rebase from master and add all action fields

Remove unused home field from actions cmd

Remove unused skipValidation field in actions cmd
@itowlson
Copy link
Contributor

JSON output would be useful, thanks - I can parse space-separated lines, but when a value can contain spaces (here the description) it gets a bit messier.

As a heads up, I believe users will find a field named 'stateless' a bit enigmatic; can we find a better name for this? If not, we should consider flipping it to 'stateful', because 'stateless: false' requires the reader to parse a double negative. 'modifies' is also a bit non-obvious though struggling to think of anything better.

Finally what order guarantees do you give in this command? Is it the order of the JSON, alphabetical order, the order in which the Go map decides to spit them out this week? If we display these in a UI we will want a stable order though I can add that in the UI if we don't offer it in the CLI.

@radu-matei
Copy link
Member Author

radu-matei commented Mar 15, 2019

  • giving this another thought, the bundle itself is already JSON (or can be retrieved through duffle bundle show) -- so is this command outputting JSON really helpful after all? It's really not difficult to implement, though.

  • I agree that stateless and modifies are a bit messy -- the decision here was to be consistent with the spec -- that being said, I'm open to changing the display name for these properties -- but there is still some mental gymnastics involved anyway -- you get a value here (let's say for STATEFUL), and you want to change it, then you have to flip the value twice when creating the bundle. If we think other names are more suitable for this, maybe let's have the conversation in the spec?

  • this command ranges over a Go map, so there are no guarantees of the order. We could sort the keys and then display them.

@itowlson
Copy link
Contributor

Good point about the JSON - I can just do a duffle show and parse the JSON directly.

Copy link
Contributor

@michelleN michelleN left a comment

Choose a reason for hiding this comment

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

oh this will be very helpful! two things:

  1. would you mind adding a tiny test?
  2. I refactored the UX on export & install to always require an argument to the bundle. Someone can override the bundle argument to be a path with the -f flag like here. Would it be okay to follow the same UX on this command as well?

@radu-matei
Copy link
Member Author

@michelleN -- updated the UX for bundle reference and file, and added a tiny test.

@radu-matei radu-matei merged commit ae6a7ca into cnabio:master Apr 6, 2019
@ghost ghost removed the review label Apr 6, 2019
@radu-matei radu-matei deleted the feat-633-actions-cmd branch April 6, 2019 15:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add duffle actions command to list actions in a bundle
3 participants