yaml workflow missing start tag - go

I'm trying to use Go client to programmatically manage workflows. I'm using yaml, this is my workflow:
name: order-process
tasks:
- id: collect-money
type: payment-service
- id: fetch-items
type: inventory-service
switch:
- case: totalPrice > 100
goto: ship-parcel-with-insurance
- default: ship-parcel
- id: ship-parcel-with-insurance
type: shipment-service-premium
end: true
- id: ship-parcel
type: shipment-service
And when I deploy this, I can't visualize it in camunda operate, the page is stuck on loading
and I have this error in console:
Error: unparsable content detected
line: 0
column: 0
nested error: missing start tag

we are sorry but Operate only supports BPMN XML deployments at the moment. The YAML support in Zeebe is only rudimentary and not intended for real-world use cases. It becomes really hard to model complex processes with yaml, which is easily possible with BPMN. We highly encourage you to switch to the Zeebe Modeler to create your workflow models.
If you want to discuss this further, we are happy to welcome you in one of our community channels.

Related

How to optionally apply environment configuration?

I want to optionally apply a VPC configuration based on whether an environment variable is set.
Something like this:
custom:
vpc:
securityGroupIds:
- ...
subnetIds:
- ...
functions:
main:
...
vpc: !If
- ${env:USE_VPC}
- ${self:custom.vpc}
- ~
I'd also like to do similar for alerts (optionally add emails to receive alerts) and other fields too.
How can this be done?
I've tried the above configuration and a variety of others but just receive various different errors
For example:
Configuration error:
at 'functions.main.vpc': must have required property 'securityGroupIds'
at 'functions.main.vpc': must have required property 'subnetIds'
at 'functions.main.vpc': unrecognized property 'Fn::If'
Currently, the best way to achieve such behavior is to use JS/TS-based configuration instead of YAML. With TS/JS, you get full power of a programming language to shape your configuration however you want, including use of such conditional checks to exclude certain parts of the configuration. It's not documented too well, but you can use this as a starting point: https://github.com/serverless/examples/tree/v3/legacy/aws-nodejs-typescript
In general, you can do whatever you want, as long as you export a valid object (or a promise that resolves to a valid object) with serverless configuration.

YAML file requires different amounts of indentation for different nodes

I'm attempting to write a YAML config script for a load testing utility called Artillery.
The YAML syntax is not making any sense to me though. Artillery appears to deserialize the YAML to a Javascript object syntax so it expects nodes in the YAML file to have a certain structure.
config:
target: https://mhhs-prod-webapp.azurewebsites.net/
phases:
- duration: 60
arrivalRate: 50
scenarios:
- flow:
- get:
url: '/'
Given the above file though it fails complaining that 'get' must be of type object. In the file above the get node has a child node url of key value type, so I'm expecting it to be of type object.
After much trial and error I've managed to get it to work using the following layout.
config:
target: https://mhhs-prod-webapp.azurewebsites.net/
phases:
- duration: 60
arrivalRate: 50
scenarios:
- flow:
- get:
url: '/'
But the bizarre thing is that this file is identical to the previous one apart from the fact that the url node is indented 4 spaces instead of the 2 spaces of indentation used throughout the rest of the file.
Is this correct? I'm having trouble finding an explanation of YAML that is understandable but so far I haven't come across anything that suggests that different amounts of indentation do completely different things.
Hohoho, I understand how you feel about YAML indentations.
It's like Python-based indentation but with a mix of JSON.
In your code:
config:
...
scenarios:
- flow:
- get:
url: '/'
"url" looks like a child of "flow" since it has an indent like so.
It can go in a couple of routes.
Route #1: (Where "url" is under "flow:")
...
scenarios:
- flow:
- get:
- url: '/'
Route #2: (Where "url" is under "get:")
...
scenarios:
- flow:
- get:
- url: '/'
Route #3: (Where "url" is under~ uhm...)
config:
...
scenarios:
...
url: '/'

Issue with creating a documentation when using re-usable enums

The issue with creating documentation when using re-usable enums
My yaml file looks like this
openapi: 3.0.2 components: schemas:
Countries:
type: string
enum:
- Unknown
- Afghanistan
- Albania
- Algeria
- American Samoa
- "\u00c5landIslands"
- NotOtherwiseSpecified
, when I compile it creates the java classes correctly, however, is not creating the documentation, just gives me:
Countries-
and nothing more is displayed for that particular scheme. For the other schemes enum options are displayed, etc.
Can you help me with this problem? Is this an issue of swagger or I am mistaken somewhere. The example in the swagger website and my code are following the same rules: https://swagger.io/docs/specification/data-models/enums/.
I also posted similar question here: https://community.smartbear.com/t5/SwaggerHub/Issue-with-creating-a-documentation-when-using-re-usable-enums/m-p/191938
P.S. I thought the problem is coming because of the special character, but it is not. I tried without that specific enum entry and also I have another similar way reusable enum that behaves the same way.
This is working fine for me. I am attaching an example for reference of how I am doing it.
Parameters in route.yaml
parameters:
- name: Country
in: query
required: true
schema:
$ref: "#/components/schemas/test"
Declaration in parameters.yaml
components:
schemas:
test:
type: string
enum:
- Unknown
- Afghanistan
- Albania
- Algeria
- "\u00c5landIslands"
Attaching the image from Swagger UI
Please add some more details for reference as above mentioned are working fine for me.

Can´t use sequences/lists in YAML with Spring Cloud Config

I´m having problems using an (apparently) valid YML file with Spring Cloud Config as soon as I try to use anything like list or sequences.
Some dummy YML samples. This one works when I hit the endpoint exposed by the server:
info:
description: "This is the collector for CEM"
git-commit: "bla bla MD5"
version: "0.2.0-SNAPSHOT"
This one does not work:
info:
description: "This is the collector for CEM"
git-commit: "bla bla MD5"
version: "0.2.0-SNAPSHOT"
items: [ "a", "b", "c"]
Tried this as well:
info:
description: "This is the collector for CEM"
git-commit: "bla bla MD5"
version: "0.2.0-SNAPSHOT"
items:
- "a"
- "b"
- "c"
The error I get with the second and third examples is this one:
This page contains the following errors:
error on line 1 at column 462: StartTag: invalid element name
Below is a rendering of the page up to the first error.
What would be the correct way of using lists/sequences? I am mostly interested in lists of complex objects and, unfortunately, the samples provided are almost always one-liners.
Cheers!
Update: I fixed a badly written example (the third one). I still does not work.
Update 2: This is actually an issue with the HTML renderer and not with the functionality of the config server itself, as it passes the config to the client without issue. However the HTML is a nice-to-have as it gives you visual information on what is being loaded.
Update 3: I´m using Spring Cloud Brixton.SR7
You could try with:
items:
- a
- b
- c
The issue seems to be removed pulling the latest version of Spring Cloud Config. However, now JSON is displayed instead of XML.

How to change one value in an associative array referenced by Node

So I apologize in advance if I use yaml terminology wrong I am pretty new to it.
So I have this item in a list that is an associative array and I would like to use a node to repeat it multiple times in the file but I need to change one value in a sub array in it and I don't know how to do it without overwriting the entire array.
So here is the item in the list
- &def_service
type: service
name: Remote Service
config:
machine: ''
version: '1.0.0'
apikey: VALUE_I_WANT_TO_CHANGE
and I what I've tried to do is
- <<: *def_service
config:
apikey: NEW_VALUE
but that just overwrites the entire array so config is just
{config:{apikey:NEW_VALUE}}
I would be very grateful for an answer here I am pretty stuck.
Ok so an answer that occurred to me maybe not the best answer is just to introduce another variable for the config array like this.
- &def_service
type: service
name: Remote Service
config: &service_config
machine: ''
version: '1.0.0'
apikey: VALUE_I_WANT_TO_CHANGE
so to reference it I did this
- <<: *def_service
config:
<<: *service_config
apikey: NEW_VALUE
YAML is not a programming language. It is designed for data representation, not for data transformation.
The merge key you use (<<) is not part of the YAML specification. It is part of the YAML type repository, which is outdated (since it is defined for YAML 1.1). Therefore, your question is highly dependendent on the YAML processor you use. One processor might implement it while another does not.
Since you have a specific problem, it would probably be better to write YAML tailored to your problem, and then handle it in your code (assuming that you are in charge of the code). Something like this:
- !config_base
&def_service
type: service
name: Remote Service
config: &service_config
machine: ''
version: '1.0.0'
apikey: VALUE_I_WANT_TO_CHANGE
- !config_child
base: *def_service
substitutions:
config:
apikey: NEW_VALUE
You can then write code that does the substitution inside your deserialized YAML structure.

Resources