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

[Feature Request]: Code optimization - retrieve module relative path through dedicated function #3187

Open
eriqua opened this issue May 9, 2023 · 5 comments
Labels
[cat] testing category: testing enhancement New feature or request

Comments

@eriqua
Copy link
Contributor

eriqua commented May 9, 2023

Description

Implement helper function to retrieve the module relative path given the full path, e.g., Get-FormattedModuleRelativePath

Replace lines like

$moduleRelative = $moduleRoot.Replace('\', '/').split('modules/')[1]

used e.g., by Pester test, with a call to that function

@AlexanderSehr
Copy link
Contributor

Should link to

$moduleRelative = $moduleRoot.Replace('\', '/').split('modules/')[1]
$splitHyphens = $moduleRelative.split('-')
$splitHyphens = $splitHyphens | ForEach-Object { $_.substring(0, 1).toupper() + $_.substring(1) }
$splitHyphens = $splitHyphens -join ''
$fullModuleIdentifier = 'Microsoft.{0}' -f $splitHyphens.Replace('-', '')

@eriqua
Copy link
Contributor Author

eriqua commented May 9, 2023

@AlexanderSehr so I get the function should return the module full resourceType and not only the relative path, correct? If so I guess we should go with something like Get-ModuleResourceType?

@eriqua
Copy link
Contributor Author

eriqua commented May 11, 2023

Should also include an update to custom modules to include their suffix in the readme title

Example
modules\Web\sites\config--authsettingsv2\README.md

Site AuthSettingsV2 Config [Microsoft.Web/sites/config]

@AlexanderSehr
Copy link
Contributor

AlexanderSehr commented May 13, 2023

@AlexanderSehr so I get the function should return the module full resourceType and not only the relative path, correct? If so I guess we should go with something like Get-ModuleResourceType?

Correct. So network/virtual-networks should return Microsoft.Network/virtualNetworks.

@eriqua
Copy link
Contributor Author

eriqua commented May 20, 2023

Ref updated Set-DeploymentExamplesSection in Set-ModuleReadme for cleaner code to convert from kebab-case to camelCase or PascalCase:

    # Convert moduleName from kebab-case to camelCase
    $First, $Rest = $moduleName -Split '-',2
    $moduleNameCamelCase = $First.Tolower() + (Get-Culture).TextInfo.ToTitleCase($Rest) -Replace '-'
    # Convert moduleName from kebab-case to PascalCase
    $moduleNamePascalCase = (Get-Culture).TextInfo.ToTitleCase($moduleName) -Replace '-'

@AlexanderSehr AlexanderSehr added this to the Azure Verfified Modules (AVM) - CI Issues milestone May 19, 2024
@AlexanderSehr AlexanderSehr removed this from the Azure Verfified Modules (AVM) - CI Issues milestone Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[cat] testing category: testing enhancement New feature or request
Projects
Status: To do
Development

No branches or pull requests

2 participants