Skip to content

Object parameters cannot be read from a file #3257

@lbergnehr

Description

@lbergnehr

Describe the bug

According to

porter install --param config=./config.json
,
an object parameter should, much like the file type parameter, be able to be
taken from a file directly when specified using the --param option in e.g.
porter install.

To Reproduce

Steps to reproduce the behavior:

  1. Use this porter.yaml:

    schemaType: Bundle
    schemaVersion: 1.0.1
    name: porter-repro
    version: 0.1.0
    description: "An example Porter configuration"
    registry: "localhost:5000"
    
    # Declare and optionally configure the mixins used by the bundle
    mixins:
      - exec
    
    parameters:
      - name: object_parameter
        type: object
        path: /cnab/app/object_parameter.json
    
    # Define the steps that should execute when the bundle is installed
    install:
      - exec:
          description: "Install Hello World"
          command: echo
          arguments:
            - install ${ bundle.parameters.object_parameter }
    
    # Define the steps that should execute when the bundle is upgraded
    upgrade:
      - exec:
          description: "World 2.0"
          command: ./helpers.sh
          arguments:
            - upgrade
    
    # Define the steps that should execute when the bundle is uninstalled
    uninstall:
      - exec:
          description: "Uninstall Hello World"
          command: ./helpers.sh
          arguments:
            - uninstall
  2. Put the following in object_parameter.json:

    {
      "key": "value"
    }
  3. Run porter install --param object_parameter=./object_parameter.json

  4. Observe the error:

    unable to convert parameter's object_parameter value ./object_parameter.json to the destination parameter type object: could not unmarshal value ./object_parameter.json into a json object: invalid character '.' looking for beginning of value
    

Expected behavior

The file should be read and marshalled into the object parameter
representation if the parameter given in the --param option is pointing to a
file.

Version

porter v1.2.0 (45c17c15)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions