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

Migrate scopes to required_scopes #5389

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zzooeeyy
Copy link
Contributor

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

How to test your changes?

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

zzooeeyy commented Feb 12, 2025

@zzooeeyy zzooeeyy force-pushed the zl/migrate_scopes_to_required_scopes branch from 54472ee to 0b02232 Compare February 12, 2025 23:52
@zzooeeyy zzooeeyy mentioned this pull request Feb 12, 2025
5 tasks
@zzooeeyy zzooeeyy force-pushed the zl/migrate_scopes_to_required_scopes branch from 0b02232 to 3f89a13 Compare February 13, 2025 22:54
Copy link
Contributor

@MitchDickinson MitchDickinson left a comment

Choose a reason for hiding this comment

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

This is a step in the right direction for sure - nice work!
I have a suggestion to improve the interface and also a couple questions on why certain code is still required, but this is coming along nicely!

@@ -108,6 +108,8 @@ export async function linkedAppContext({
await addUidToTomlsIfNecessary(localApp.allExtensions, developerPlatformClient)
}

await localApp.migratePendingSchemaChanges()
Copy link
Contributor

Choose a reason for hiding this comment

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

At this level of abstraction there is nothing specific about "schema changes" to be known. What you've built here is a more generic "Extensions can run arbitrary code during link" mechanism.

Some thoughts:

  1. Since the abstract solution here isn't specific to migrations, we could have a more general name (not sure what it would be).
  2. Alternatively, I think there is value in constraining usages of this function to actual transformations. In other words: is there a way to design this interface such that implementations are constrained in the things they can do?

Additionally, this solution relies on mutation of the underlying configuration object, and passing in mutable properties can be a source of bugs, so it might be worth looking at a solution that doesn't involve mutating the extension.config object.

I think #2 might be worth pursuing. Today your interface is is (extension: ExtensionInstance) => Promise<void>, which is generic. I would suggest trying an alternative where the interface is something like (config: TConfiguration) => TConfiguration (provide a function that maps a configuration to a new configuration). This would constrain the possible implementations to mutating a config, which is more in line with what you want here.

await Promise.all([this.realExtensions.map((ext) => ext.migratePendingSchemaChanges())])
}

async migrateScopesToRequiredScopes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed here still? I see you are doing the mutation in the app_config_app_access file, so this seems redundant? I'm probably missing something.

@@ -378,13 +378,29 @@ async function overwriteLocalConfigFileWithRemoteAppConfiguration(options: {
remoteAppConfiguration = buildAppConfigurationFromRemoteAppProperties(remoteApp, locallyProvidedScopes)
}

// Create a clean version of the local config without scopes/require_scopes
Copy link
Contributor

Choose a reason for hiding this comment

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

link is also a "platform" class so in general it shouldn't have reference to concrete extension implementations like access scopes. Given you have the general interface for mutating the TOML, why is this code also necessary?

@@ -43,3 +43,24 @@ export async function patchAppConfigurationFile({path, patch, schema}: PatchToml
export function replaceArrayStrategy(_: unknown[], newArray: unknown[]): unknown[] {
return newArray
}

export async function replaceScopesWithRequiredScopesInToml(path: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same Q here - why is this required? I wouldn't expect this file to include module-specific code.

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