cnabio / duffle

CNAB installer
https://duffle.sh
MIT License
375 stars 54 forks source link

certain image names in duffle.json produce spurious images in bundle #817

Closed glyn closed 5 years ago

glyn commented 5 years ago

The following duffle.json:

{
    "name": "imagebug",
    "version": "1",
    "schemaVersion": "v1.0.0-WD",
    "invocationImages": {
        "cnab": {
            "name": "cnab",
            "builder": "docker",
            "configuration": {
                "registry": "imagebug"
            }
        }
    },
    "images": {
        "x.y": {
            "image": "docker.io/cloudfoundry/cnb@sha256:93e2707b756ed9544ecccab6884424e4990e2b3ec08f0435b8249499b51b2354",
            "digest": "sha256:93e2707b756ed9544ecccab6884424e4990e2b3ec08f0435b8249499b51b2354"
        }
    }
}

when input to duffle build, produces an invalid images section of bundle.json:

{
  "description": "",
  "images": {
    "x": {
      "description": "",
      "image": "",
      "imageType": ""
    }
  },
  "invocationImages": [
    {
      "image": "imagebug/imagebug-cnab:32ff5be1120468ffcb5c37226c5348276b9de209",
      "imageType": "docker"
    }
  ],
  "name": "imagebug",
  "schemaVersion": "v1.0.0-WD",
  "version": "1.0.0"
}

This seems superficially like https://github.com/deislabs/duffle/issues/658, which was apparently fixed.

Possible clue

Change x.y to x in duffle.json and the correct bundle is produced:

{
  "description": "",
  "images": {
    "x": {
      "description": "",
      "image": "docker.io/cloudfoundry/cnb@sha256:93e2707b756ed9544ecccab6884424e4990e2b3ec08f0435b8249499b51b2354",
      "imageType": ""
    }
  },
  "invocationImages": [
    {
      "image": "imagebug/imagebug-cnab:32ff5be1120468ffcb5c37226c5348276b9de209",
      "imageType": "docker"
    }
  ],
  "name": "imagebug",
  "schemaVersion": "v1.0.0-WD",
  "version": "1.0.0"
}

Steps to reproduce (at least on macOS)

glyn commented 5 years ago

This appears to be a side-effect, or probably a feature, of https://github.com/spf13/viper (and the underlying https://github.com/mitchellh/mapstructure).

glyn commented 5 years ago

Note that https://github.com/deislabs/duffle/issues/752 changed duffle so that it is intended to take only duffle.json as input (no TOML or YAML thank you), so we are free to switch from viper to standard JSON parsing.

carolynvs commented 5 years ago

I vote for removing viper now that we don't need multiple file formats anymore in duffle. We can just go back to using encoding/json.