-
Notifications
You must be signed in to change notification settings - Fork 761
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
Port TTK rule: artifacts-parameter.test.ps1 #7222
Comments
@bmoore-msft Would like to verify and understand how _artifactsLocation* parameters function in the bicep world. Will this continue to be a valid and compelling scenario? Thanks. |
Same as in the JSON world - for marshalling any non-template artifacts... Scripts, binaries, zip, dsc config, sql bacpac, etc... |
Can I ask why this exists??? There's no reason for the "artifacts" parameters to be formatted according to this TTK rule. It certainly makes them pretty, but in the bicep world, we're moving away from params that start with an _. In fact, these parameters could be called 'Fred' and 'Sally' for all that bicep/arm cares. If you go down this path, you'll have linter rules mandating that param names match the fields they are setting (vmSKU vs vmSize, Name vs DiskName) which is a rabbit hole you don't want to go down. |
cc @bmoore-msft @ChristopherGLewis Do you use those parameters without the underscore? Is it useful to be able to keep the rest of the rule but turn off that part? |
The rule follows a pattern that's been in ARM deployments since the beginning - not everyone follows the pattern and the rule can be turned off..
Aside from |
Yes, but is it a good pattern? Just because it was always this way doesn't mean it's right. I really dislike that in a VM deployment with many parameters, these two are "suggested" to start with an underscore. |
I don't know if it's good or bad, but it hasn't been a problem to date and changing/breaking at this point could be bad. Though I'm not sure I understand the concern.... If you don't use parameters with the distinct naming pattern, then the rule doesn't apply. If you do use parameters with that distinct naming pattern, then you've opted into the rule. If you use that pattern for naming parameters and use those parameters for some other purpose the rule can be disabled. What's the behavior you're expecting? |
I'm expecting BICEP not to care what I name parameters, other than those outside Bicep's best practices. Bicep recommends camel-case, and these Arti's don't match Bicep best practices. Now there's a linter rule saying that these (and only these) should start with "" - EVEN THOUGH naming them anything else doesn't break ARM/BICEP nor the deployment. This just seems arbitrary, and not within the norm for ARM/Bicep. I hate "Always do X, EXCEPT for" when the "except for" has no reason other than inertia. |
I think this is why we have the ability to turn off rules... i.e. if you don't agree with a defined best practice... |
@ChristopherGLewis Do you actually use artifactsParameters as a parameter name? And if so, are the other parts of the rule helpful? I.e., is there any disadvantage for you turning off the rule completely? Or does it just bother you? There is also the question of if the rule is on or off by default, but unless this detrimentally affects a lot of people, I'd prefer it be on by default. Thanks. |
Which I have. but that's for my instance of vscode via my bicepconfig.json. How do I get this to apply to the module so it doesn't apply if someone else uses the template? is there a #pragma line equivalent in bicep or is the only way to turn off the linter line is via the bicepconfig.json file - which applies to everything rather than the one file I want it to. |
I use Your statement:
is confusing for me. If Bicep/ARM/Azure all support any parameter name for these, what tools are you indicating? And shouldn't ARM/Azure be the determining factor of what's allowed? There's no disadvantage to turning off the rule completely, there's just no scoping nuance to the bicepconfig.json file. And bicepconfig.json is separate from the ARM/Bicep - there's no way to ignore the rule for just this bicep template. I guess my biggest issue is that this rule got turned on with the latest version of Bicep. I'm concerned that if we have linter rule defaults that change over time there will be pipelines/build processes that break when new versions of bicep go out. I know we're still in the "breaking changes are acceptable" phase, but this is a bad precedence to set. |
At least three places I know of where these parameters have expected names:
This doesn't limit what's allowed, it's a warning for a particular best practice usage as Brian noted, the aptness of which can certainly be discussed.
To answer your questions on this: You can have multiple levels of bicepconfig.json files to scope a rule's settings to a particular directory (i.e. have a bicepconfig.json in the folder with that bicep file, and just mention the one rule to turn off). You can also turn it off for a particular line with: Also, the expectation is that the bicepconfig.json file is checked in, it's not intended to be per-user.
We're starting to think about this, but it didn't make a lot of sense until there were a reasonable number of rules. Here's a first proposal that deals with defaults of rules (up until now we've mostly turned them all on by default to get better usage feedback): #8013. Haven't decided yet on a versioning scheme to keep existing pipelines from breaking, although as long as you don't upgrade bicep the rules won't currently change on you. Feel free to create an issue to discuss. POSSIBLE SOLUTIONS:
My current inclination is 2 or 4 |
I think the main issue here is an issue with how far to go on "reserving" a param name. As Brian mentioned, there is some tooling and paradigms connected to how There are some names of params in Bicep we've already "reserved" as special such as
we've put tooling around the fact that the param is named location and you've given a specific value for it. In this case, we are adding tooling around @StephenWeatherford and @bmoore-msft, I would like to ensure this rule is not too rigid. So if someone even creates Let's stick to the heart of the ttk rule and ONLY invoke those type/default value rules if the user uses This should provide a healthy compromise to @ChristopherGLewis feedback. I do apologize if you happen to be using |
@ucheNkadiCode @ChristopherGLewis if you haven't, you might want to read my responses above about limiting the scope of a linter rule. I'd also be interested in how we could make those features better known (something in the docs maybe?). If you're using the vscode editor the lightbulb next to the error offers the disable-next-line solution as well as editing the bicepconfig.json (although doesn't mention anything about multiple levels of config). Please continue to provide feedback, we are very interested in providing features that work well for everyone, so we need to also know when things aren't working out. |
Thanks for the responses to this - I believe that this destined outcome operates much better in my opinion. I didn't know about this line:
I like to be up to speed on all things bicep, but I missed that one, which is exactly the solution I needed. I will note that my lightbulb does not always show vs which might be a little confusing since the position of the lightbulb doesn't change. Note also that when you mouse over the error the main error window shows "No quick fixes available": |
Wow @ChristopherGLewis! That is a very interesting Bug! I'll make sure to add it to our backlog. Thank you for pointing that out. I wonder if this extends to many more disable-next-line suggestions In terms of the error with the quick fix, I think we simply didn't implement logic to take care of that use case. However #8016 should take care of this issue since we will no longer worry about "ArtifactsLocation" or "artifactslocation" whatsoever. Only if there is an underscore that precedes it. I still mentioned this issue in #8023 |
TTK sources: https://github.com/Azure/arm-ttk/blob/master/arm-ttk/testcases/deploymentTemplate/artifacts-parameter.test.ps1
TTK unit tests: https://github.com/Azure/arm-ttk/tree/master/unit-tests/artifacts-parameter
Old docs: https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-test-cases#artifacts-parameter-defined-correctly
The text was updated successfully, but these errors were encountered: