Skip to content

feat(azure): Move to new sdk#5350

Merged
yevgenypats merged 59 commits intomainfrom
feat/meta_gen_azure
Dec 11, 2022
Merged

feat(azure): Move to new sdk#5350
yevgenypats merged 59 commits intomainfrom
feat/meta_gen_azure

Conversation

@yevgenypats
Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats commented Dec 4, 2022

This PR comes instead of this #5286 as old pr got messed up.

This generates the autogeneration code and tries to generate the whole huge Azure SDK completely.

BEGIN_COMMIT_OVERRIDE
feat(azure): Move to new sdk

BREAKING CHANGE: Move to new SDK. Many new resources were added, please see https://www.cloudquery.io/docs/plugins/sources/azure/tables for the new list. The main difference in columns is that we don't unwrap Azure properties into separate columns. Instead properties are stored as a JSON column
END_COMMIT_OVERRIDE

@cq-bot cq-bot added the azure label Dec 4, 2022
@vercel
Copy link
Copy Markdown

vercel bot commented Dec 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
cloudquery-web ⬜️ Ignored (Inspect) Dec 6, 2022 at 0:24AM (UTC)

@yevgenypats yevgenypats marked this pull request as ready for review December 6, 2022 10:54
@yevgenypats
Copy link
Copy Markdown
Contributor Author

yevgenypats commented Dec 11, 2022

Closes #5425
Closes #5293

Copy link
Copy Markdown
Member

@erezrokah erezrokah left a comment

Choose a reason for hiding this comment

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

Thanks for the follow up @yevgenypats the new code gen changes look great 🚀
I think the switch to the new SDK removed a lot of relations we had as we multiplex on resource group instead of getting it from the parent, for example:

response, err := svc.ListConnections(ctx, resourceDetails.ResourceGroup, *gateway.Name)

vs

WHICH IS GREAT 🎸

Added a few non blocking comments on the code.
Also a few comments similar to the ones I left on @candiduslynx PR:

  1. subscription_id is missing from all the tables. Do we want to re-add it?
  2. Relations are missing a link to the parent, for example azure_cdn_endpoints had profile_id column.
  3. In the current plugin there's a convention to use lowercase table methods, e.g. endpoints instead of Endpoints for relation tables to prevent them being called from outside the package accidentally (we had a few bugs related to this in v0). Do we want to keep that convention? Since everything is auto generated I wouldn't worry to much if it's difficult to add.

Asking again - can we remove codegen1/recipes/ from source code? It's an intermediate directory if I'm not mistaken and is not required for make gen to work or the code to compile correct?

Finally I think we still to do a pass on the relations that are missing, for example

Approving since I think it will be easier to address the issues in additional PRs

ResourceName string
}
// this is used to hook ParseResourceGroup and to have easier codegen
var debug = false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this is used in the tests. Maybe add an option API to ParseResourceGroup to return a mock response? Or even rename this from debug to returnMockResourceGroup

for _, t := range tables {
// skip tables witout URL (or at least that we didn't find one)
// not NewListPager struct and more than 3 params
if t.URL == "" || !t.HasListPager || !isArrayExist(supportedNewListPagerParams, t.NewListPagerParams) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure, but is one of the conditions here consists as a warning? Maybe no URL. You can ignore if this comment is not relevant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've just pushed/simplified the code here to support multiple types of pager in codegen0

yevgenypats and others added 11 commits December 11, 2022 14:46
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
@yevgenypats
Copy link
Copy Markdown
Contributor Author

Thanks for the follow up @yevgenypats the new code gen changes look great 🚀 I think the switch to the new SDK removed a lot of relations we had as we multiplex on resource group instead of getting it from the parent, for example:

response, err := svc.ListConnections(ctx, resourceDetails.ResourceGroup, *gateway.Name)

vs

WHICH IS GREAT 🎸

Added a few non blocking comments on the code. Also a few comments similar to the ones I left on @candiduslynx PR:

  1. subscription_id is missing from all the tables. Do we want to re-add it?
  2. Relations are missing a link to the parent, for example azure_cdn_endpoints had profile_id column.
  3. In the current plugin there's a convention to use lowercase table methods, e.g. endpoints instead of Endpoints for relation tables to prevent them being called from outside the package accidentally (we had a few bugs related to this in v0). Do we want to keep that convention? Since everything is auto generated I wouldn't worry to much if it's difficult to add.

Asking again - can we remove codegen1/recipes/ from source code? It's an intermediate directory if I'm not mistaken and is not required for make gen to work or the code to compile correct?

Finally I think we still to do a pass on the relations that are missing, for example

Approving since I think it will be easier to address the issues in additional PRs

Thanks. 1 and 3 addressed. 2 will be addressed in follow-up PRs.

@erezrokah
Copy link
Copy Markdown
Member

We should have merged this as a breaking change, but I think we can tweak the changelog later on

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.

5 participants