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

Secrets Code Gen #6385

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open

Secrets Code Gen #6385

wants to merge 76 commits into from

Conversation

gearama
Copy link
Member

@gearama gearama commented Jan 30, 2025

Generate KV Secrets from tsp with the latest codegen and typespec
From a Secrets POV all is well we have a thing going on, code is generates, compiling and testing
on the innfra side work that needs to happen to streamlline it further

move client tsp and tsconfig info into the specs repo thus the configs come as part of the downloading of TSPs thus no more file copy. It is still very useful as part of local development and rapid turn around for fixes for example for names.
publish codegen to NPM so then we don't need all the magic git operations to get the generator, it would be obtained and invoke by the tsp-client command

Right now we are at parity with the previous API surface , there are changes to the models but the methods should be fine

Pull Request Checklist

Please leverage this checklist as a reminder to address commonly occurring feedback when submitting a pull request to make sure your PR can be reviewed quickly:

See the detailed list in the contributing guide.

  • C++ Guidelines
  • Doxygen docs
  • Unit tests
  • No unwanted commits/changes
  • Descriptive title/description
    • PR is single purpose
    • Related issue listed
  • Comments in source
  • No typos
  • Update changelog
  • Not work-in-progress
  • External references or docs updated
  • Self review of PR done
  • Any breaking changes?

@gearama
Copy link
Member Author

gearama commented Jan 30, 2025

/azp run cpp - keyvault

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@gearama
Copy link
Member Author

gearama commented Jan 30, 2025

/azp run cpp - keyvault

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 30, 2025

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-security-keyvault-secrets-cpp

@gearama gearama changed the title Kv tsp secrets3 Secrets Code Gen Mar 4, 2025
Copy link
Member

@LarryOsterman LarryOsterman left a comment

Choose a reason for hiding this comment

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

My biggest comment is that there are a substantial number of breaking changes in this PR, and there are a surprising number of tests that don't appear to be carried forward into the new codebase.

What is the plan for managing these breaking changes?

Copy link
Member

@antkmsft antkmsft left a comment

Choose a reason for hiding this comment

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

George, do we really want to move the header files from, say, <azure/keyvault/secrets.hpp> to <azure/security/keyvault/secrets.hpp>?
This won't align with the rest of the current keyvault libraries, and some of them are in GA state, so we probably won't do the same move for them? And then there will forever be #include <azure/keyvault and #include <azure/security/keyvault which is not great, so is it really worth it? I'd say, keep the include file location the same. If codegen needs some option to support this, let's implement that option in codegen.

@gearama
Copy link
Member Author

gearama commented Mar 5, 2025

i guess we could discuss it with Larry and Rick , to be hones i think we made a mistake originally by not including that path , which is in the namespace and the package name , so the headers should have been in azure/security/keyvault/ .... Let me talk with Larry and Rick and circle back when i have a clearer idea.

@antkmsft
Copy link
Member

antkmsft commented Mar 5, 2025

@gearama, I agree, possibly that was a mistake, but now, I think, we should keep it, because the alternative is not giving us much while making some problems.

Comment on lines -4 to -7
/**
* @file
* @brief DLL export macro.
*/
Copy link
Member

Choose a reason for hiding this comment

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

we should update codegen to include these comments (+comments in the all-inclusive header and dll_import_export as well)

Copy link
Member

Choose a reason for hiding this comment

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

Do these comments even show up in our published documentation?

Copy link
Member

Choose a reason for hiding this comment

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

Same comment applies to rtti.hpp - IMHO we should not be including these files in published documentation, so it only affects the comments. And in that case, I'd just throw in a link to a .md file which explains it in detail so we don't need to duplicate all this text.

Comment on lines -11 to -20
#include "azure/keyvault/secrets/dll_import_export.hpp"
#include "azure/keyvault/secrets/keyvault_backup_secret.hpp"
#include "azure/keyvault/secrets/keyvault_deleted_secret.hpp"
#include "azure/keyvault/secrets/keyvault_operations.hpp"
#include "azure/keyvault/secrets/keyvault_options.hpp"
#include "azure/keyvault/secrets/keyvault_secret.hpp"
#include "azure/keyvault/secrets/keyvault_secret_paged_response.hpp"
#include "azure/keyvault/secrets/keyvault_secret_properties.hpp"
#include "azure/keyvault/secrets/rtti.hpp"
#include "azure/keyvault/secrets/secret_client.hpp"
Copy link
Member

Choose a reason for hiding this comment

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

Should we update codegen with the features to match the existing header files? It can be done... Diffing will certainly be easier, especially for doxygen comments.
Alternative: keep these headers, but include the new ones from them.

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't think we should do that , we include the headers we generate, i'm not sure , we provide the root header file, if poeple decide to include things manually that's on them, we changed header file names before , so i'm not sure there's a point to trying to match underlying things as before.

@@ -22,15 +21,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
/**
* @brief Represents a long running operation to restore a deleted secret.
*/
class RecoverDeletedSecretOperation final : public Azure::Core::Operation<SecretProperties> {
class RecoverDeletedSecretOperation final : public Azure::Core::Operation<KeyVaultSecret> {
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename KeyVaultSecret to SecretProperties?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is a secret properties already , plus things changes and props that were in the properties meodel moved into the secret and vice versa.

@@ -21,13 +21,12 @@ using namespace std::chrono_literals;

int main()
{
// @begin_snippet: SecretSample1CreateCredential
Copy link
Member

Choose a reason for hiding this comment

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

Why did we remove the snippet coments?

Copy link
Member Author

@gearama gearama Mar 7, 2025

Choose a reason for hiding this comment

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

build issues, for some reason or another, it was saying it couldn't find them, and i couldn't figure out why that is . That script is a black hole that does not explain why something fails

Comment on lines -77 to -78
std::make_unique<_internal::KeyVaultChallengeBasedAuthenticationPolicy>(
credential, tokenContext));
Copy link
Member

Choose a reason for hiding this comment

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

We should keep using this policy, not need to drop it just because codegen doesn't emit it.
We could add a code injection context for policies initialization (codegen: replace SecretClient policies initialization), or channel that through config (replaceAuthPolicy = {include: 'azure/keyvault/shared/keyvault_challenge_based_auth.hpp', statement = 'std::make_unique<_internal::KeyVaultChallengeBasedAuthenticationPolicy>(credential, tokenContext)'}), although code injection is probably a better solution, because it would allow for constructor overloads with different auth policy depending on parameters.

You can even do it today, with // codegen: insert after includes + // codegen: replace KeyClient::KeyClient, and maybe it is how it should be done, without implementing the codegen: replace SecretClient policies initialization - that is what that feature was done for, keeping this scenario in mind.

Copy link
Member Author

Choose a reason for hiding this comment

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

fi we want to add codegen support to do that maybe we should, but i'm not sure that is a secure way to auth, what we have now works. some architect or lead should give their opinion. My initial reaction is that we don't need it and it's not secure so we shouldn't have it.

Copy link
Member

Choose a reason for hiding this comment

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

Challenge-Based auth is not secure? You must be confusing it with something else.
What we have now works, but it won't work in gov clouds, for example. CHallenge-Based auth is like BearerTokenAuth v 1.1 - it is backwards compatible. We should not be dropping it. I think you should inject it by using //codegen: replace SecretClient::SecretClient in the .cpp file.

Comment on lines -125 to +112
* @brief Set a secret in a specified key vault.
*
* @param name The name of the secret.
* @param secret The secret definition.
*
* @brief The SET operation adds a secret to the Azure Key Vault. If the named secret already
* exists, Azure Key Vault creates a new version of that secret. This operation requires the
* secrets/set permission.
* @param secretName The name of the secret. The value you provide may be copied globally for
* the purpose of running the service. The value provided should not include personally
* identifiable or sensitive information.
* @param secret The secret to set.
Copy link
Member

Choose a reason for hiding this comment

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

Are doxygen docs good?
The ones I've seen do look good, and not only good but in most cases better, but can we do something to review all of them in a diff, any ideas?
If we want to correct some of them, we can also add // codegen: replace SecretClient::SetSecret comment injection context.

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't understand the question

Copy link
Member

Choose a reason for hiding this comment

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

Can we have a meeting like the ApiView one, but for the generated documentation?

@antkmsft antkmsft self-requested a review March 7, 2025 02:12
Copy link
Member

@antkmsft antkmsft left a comment

Choose a reason for hiding this comment

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

I'm no longer "requesting changes" in this PR, but I don't know how will we proceed, like what level of review is expected, and how you want to approach it - do we check in first, and then hold some review for the docs and the ApiView, or do we fix all/most of the things before you merge this PR?

Most of the feedback I've left is not directly to you, but to be discussed within our team to make a decision, like we did this morning about the headers path and the Models namespace.

I guess I could set this to "Approved", and I see the reasons to not set this to Approved, depending on how we are going to interpret it for such big and fundamental PR.

@antkmsft antkmsft dismissed their stale review March 7, 2025 02:18

not requesting anything specifically, not approving yet either

@LarryOsterman
Copy link
Member

Generally I'm OK with the changes. But I'd love to see an APIView of the current changes - the one in apiview currently is from January and it's way out-of-date :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants