Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonVariable: New type of object variable where each value user selects has many properties (POC) #995

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

torkelo
Copy link
Member

@torkelo torkelo commented Dec 6, 2024

The variable system has for a long time supported object property notation (Ex ${__org.name})

Sadly we have not provided end users with the ability to define object variables.

This PR explores a new type of variable (tentative name JsonVariable but it's a poor name).

Examples

new JsonVariable({
  name: 'env',
  value: 'test',
  provider: JsonVariableOptionProviders.fromString({
    json: `[
      { "id": 1, "name": "dev", "cluster": "us-dev-1", "status": "updating" }, 
      { "id": 2, "name": "prod", "cluster": "us-prod-2", "status": "ok" }
    ]`,
  }),
}),
new JsonVariable({
  name: 'testRun',
  label: 'Test run',
  provider: JsonVariableOptionProviders.fromObjectArray({
    options: [
      { runId: 'CAM-01', timeTaken: '10s', startTime: 1733492238318, endTime: 1733492338318 },
      { runId: 'SSL-02', timeTaken: '2s', startTime: 1733472238318, endTime: 1733482338318 }},
    ],
    valueProp: 'runId',
  }),
}),

Demo

json_variable.mp4

Copy link
Member

@dprokop dprokop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea a lot. Not sure yet if this variable would make sense to be added to core, but starting with apps I think this is great.

new JsonVariable({
name: 'env',
value: 'test',
provider: JsonVariableOptionProviders.fromString({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea with Observables provider, technically those can be easily retrieved from an async source, sounds very powerful.

{ runId: 'SSL-02', timeTaken: '2s', startTime: 1733472238318, endTime: 1733482338318 },
{ runId: 'MRA-02', timeTaken: '13s', startTime: 1733462238318, endTime: 1733472338318 },
],
valueProp: 'runId',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this will be the property used for default interpolation, when no path provided in the variable syntax? i.e. if i just used ${testRun} the that would by default be equivalent to ${testRun.runId}?

@dprokop dprokop requested review from a team, oscarkilhed and ivanortegaalba and removed request for a team December 9, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants