tliron / puccini

Cloud topology management and deployment tools based on TOSCA
https://puccini.cloud
Apache License 2.0
88 stars 20 forks source link

Issue in data type of row #109

Open ashish-gupta-2 opened 1 year ago

ashish-gupta-2 commented 1 year ago

sample.yaml

tosca_definitions_version: tosca_simple_yaml_1_3

metadata:
  template_name: Inputs and Outputs Example
  template_author: Puccini
topology_template:

  inputs:
    cores:
      type: integer
      default: 4
      constraints:
      - less_than: 8

  node_templates:
    server:
      type: tosca:Compute
      capabilities:
        host:
          properties:
            num_cpus: { get_input: cores }
      attributes:
        public_address: "10.11.111.121"
  outputs:
    url:
      type: string
      value: { concat: [ 'http://', { get_attribute: [ server, public_address ] }, ':8080' ] }

function-call.go

  if data, ok := map_["row"]; ok {
              if functionCall.Row, ok = asInt(data); !ok {
                  return nil, fmt.Errorf("malformed function call, \"row\" not an integer: %T", data)
              }
          }

    if data, ok := map_["column"]; ok {
        if functionCall.Column, ok = asInt(data); !ok {
            return nil, fmt.Errorf("malformed function call, \"column\" not an integer: %T", data)
        }
    }

we are using below js script for coerce in our js file

const traversal = require('tosca.lib.traversal');
traversal.coerce();

It is taking row number as float64 rather than integer due to which below issue is coming :

GoError: malformed function call, "row" not an integer: float64 at internal:tosca.lib.traversal:158:9(58)

the same thing is working fine while using CLI command :

puccini-tosca compile -c <filename>
tliron commented 1 year ago

Thanks for this! Are you using a build from git main or is this the latest downloaded version?

ashish-gupta-2 commented 1 year ago

@tliron We are using the latest downloaded version v0.20.1

tliron commented 1 year ago

Could you please test with the latest git build? It should be very easy, see this guide.

ashish-gupta-2 commented 1 year ago

Will try that , are you planning to release latest git code main branch . Last release(v0.20.1) happened on 28-Feb-2022

tliron commented 1 year ago

There is a major fix I've been working for a while regarding constraints. As soon as it's fixed and tested I will release.

It could be that the bug you've discovered still exists, I just want to make sure, it sounds like something I already fixed.

tliron commented 1 year ago

The recent commits made a major refactoring to how values and function calls are parsed, normalized, and coerced. Could you please check now with the recent commit and let me know if you have issues? Otherwise, is there a way you can share your test case with me to help debug it?