Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Add transformations to corresponding panels #13

Conversation

manfontan
Copy link

Description

Add transformations to the panels supporting them. Based on transformations

Since transformations are not supported by all panels I have added them for each of those actually supporting them rather than using __panel.

Test

Not sure how to test this. My assumption is that I should generate the spec.json from the spec.yml then assert the .libsonnet changes have been generated as expected. Any help with this will be very appreciated.

Manuel Fontan added 3 commits April 13, 2021 21:03
Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
@manfontan
Copy link
Author

Ok this seems to be actually broken. I will figured it out 😓

$ swagger-cli bundle -o _gen/7.0/spec.json specs/7.0/spec.yml 
Created _gen/7.0/spec.json from specs/7.0/spec.yml
$ go run . 7.0 jsonnet                                       
2021/04/14 00:10:57 json: cannot unmarshal string into Go struct field Schema.Components.Schemas.Properties.AllOf.Properties.Items.Properties of type main.Schema
exit status 1

Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
@manfontan
Copy link
Author

Ok looking better now

I can see the addTransformation method in the .libsonnet output for the different panels.

    addTransformation(
      transformation
    ):: self {}
      + { transformations+: [
        transformation
      ] },

Manuel Fontan added 3 commits April 14, 2021 10:12
Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
@manfontan
Copy link
Author

I tried creating a _transformation.yml and $ref it to avoid duplicated code in the panels but the result libsonnet was not what I expected. I probably need to review the generator code to fully understand how things are generated.

With the id and options properties it looks something like this:

    addTransformation(
      id=null,
      options=null,
    ):: self {}
      + { transformations+: [
        {
          [if id != null then 'id']: id,
          [if options != null then 'options']: options,
        },
      ] },

Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
@manfontan
Copy link
Author

Ok so my problem was that I was not fully dereferencing the spec.json.

$ swagger-cli bundle -r -o _gen/7.0/spec.json specs/7.0/spec.yml
$ go run . 7.0 jsonnet

With the above commands I got it working as expected.

In the latest commit I have added a _transformation.yml and reference it from the panels.

Signed-off-by: Manuel Fontan <mfontangarcia@slack-corp.com>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Manuel Fontan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@manfontan manfontan closed this Sep 6, 2022
@manfontan manfontan deleted the mfontangarcia-add-trasnformations-to-panels branch September 6, 2022 20:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants