Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Image inspect non-app CNABs #753

Merged
merged 4 commits into from
Nov 21, 2019

Conversation

zappy-shu
Copy link
Contributor

@zappy-shu zappy-shu commented Nov 19, 2019

- What I did

Allow image inspect of CNABs not created with docker app. The command will output basic information that is read from the bundle.json file including:

  • metadata (version, name, description, maintainers)
  • services (name and image)
  • parameters (including default values if present)

Metadata fields are now printed in PascalCase to match the other fields

- How I did it

The image inspect command first checks if the invocation image supports the custom com.docker.app.inspect command. If yes then this is called with the format as before. If not then it's not a Docker App bundle and the bundle file is parsed for the relevant information which is then printed using the same formatters as the Docker App inspect function.

- How to verify it

Manually create a CNAB, push it to hub with cnab-to-oci, and pull it with docker app. Use docker app image inspect <cnab-id> and confirm the output contains the metadata, services, and parameters.

You can also use docker app image inspect <cnab-id> --pretty to get a table view but 2 fields are removed (REPLICAS and PORTS)

- Description for the changelog

Allow docker app image inspect of CNAB bundles created without Docker App

- A picture of a cute animal (not mandatory)

cat-2019-11-19

Allow `image inspect` of CNABs not created with docker app. The command
will output basic information that is read from the bundle.json file
including:
* metadata (version, name, description, maintainers)
* services (name and image)
* parameters (including default values if present)

Signed-off-by: Nick Adcock <nick.adcock@docker.com>
Copy link
Member

@eunomie eunomie left a comment

Choose a reason for hiding this comment

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

LGTM

Checks the CNAB for the docker app inspect action before attempting to
call inspect. If the action is not defined then inspect the CNAB bundle
directly.

Refactors the `hasAction` func to just check for the key instead of
looping through the map.

Signed-off-by: Nick Adcock <nick.adcock@docker.com>
@codecov
Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #753 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #753   +/-   ##
=======================================
  Coverage   69.94%   69.94%           
=======================================
  Files          63       63           
  Lines        3540     3540           
=======================================
  Hits         2476     2476           
  Misses        744      744           
  Partials      320      320

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 355ab4f...8908b28. Read the comment docs.

@zappy-shu zappy-shu force-pushed the APP-321-inspect-cnab-bundles branch 2 times, most recently from af4ed9d to be5afd0 Compare November 20, 2019 11:47
Prints the metadata fields in PascalCase when calling `app image
inspect` to match the other fields.

Fixed `FromBundle` func comment

Signed-off-by: Nick Adcock <nick.adcock@docker.com>
Removes the App-only SERVICE fields from the `app image inspect
--pretty` output when inspecting a non-App CNAB:
* REPLICAS
* PORTS

Added unit test for image inspect of CNABs with pretty format.

Refactored parameter key sorting code to use simpler `sort.Strings()`

Signed-off-by: Nick Adcock <nick.adcock@docker.com>
@zappy-shu zappy-shu changed the title [WIP] Image inspect non-app CNABs Image inspect non-app CNABs Nov 20, 2019
Copy link
Member

@eunomie eunomie left a comment

Choose a reason for hiding this comment

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

LGTM
Tested with the hello example from cnab-to-oci repository and it looks great.
Metadata field names are now ok.

@rumpl rumpl merged commit b621499 into docker:master Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants