nanovms / ops

ops - build and run nanos unikernels
https://ops.city
MIT License
1.27k stars 132 forks source link

Error: failed converting configuration file: json: cannot unmarshal number into Go struct field RunConfig.RunConfig.Ports of type string #1592

Closed radiosilence closed 6 months ago

radiosilence commented 6 months ago

I'm following the AWS documentation, and it seems to dislike the ports being a array of numbers in the RunConfig, as per docs.

Works if you use an array of strings.

It also breaks if you use SecurityGroup.

Error: failed converting configuration file: json: unknown field "SecurityGroup"

This is the command I am running:

ops image create -t aws -c config.json --package radiosilence/nano-web:latest Here's my config file, which breaks but is correct according to docs:

{
  "Dirs": ["public"],
  "Env": {
    "SPA_MODE": "1"
  },
  "CloudConfig": {
    "Platform": "aws",
    "Zone": "eu-west-2",
    "BucketName": "nano-test-bucket"
  },
  "RunConfig": {
    "Ports": [80], // here
    "SecurityGroup": ["web"] //here
  }
}

I've tried on latest release 0.1.40 and also a build from master.

eyberg commented 6 months ago

thanks for letting us know, yes ports are passed in as a string here, https://github.com/nanovms/ops-documentation/commit/0edc1bf47d70a74c4e8b6f04c2afa16c09c7c0b6

I didn't immediately see your reference to where setting 'SecurityGroup' to an array was in the docs?

also, SecurityGroup is set in the CloudConfig

radiosilence commented 6 months ago

Ah, I see! Yeah meant to put it as a string not []string in my example.

Might need a correction in the docs too then:

"You can select a different VPC or use a existing security group using the configuration file. The keys to set are RunConfig.VPC and RunConfig.SecurityGroup."

And the example below uses RunConfig. Not sure what PrivateStaticIP should be in but in the docs it says RunConfig :)

eyberg commented 6 months ago

I see, updated https://github.com/nanovms/ops-documentation/commit/8a28d1e69d5e3d92f9e3a66d9e3e7ec3223a5646

yeh, in general if something is explicitly for a particular cloud (such as vpc/sg/etc. we'll throw it into CloudConfig); the ip, in the past has been shared for both local and cloud deployments but we have some initial code to change that as the onprem target and compose support a lot more control wrt that