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

fix(convert-formulas.sh): add -_ to allowed chars in formula name #207

Merged
merged 2 commits into from
Oct 31, 2020

Conversation

dafyddj
Copy link
Contributor

@dafyddj dafyddj commented Sep 29, 2020

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

Describe the changes you're proposing

Allow '-' and '_' in formula names. Formulas already exist with '-' in the name (prior to -formula),
so it seems reasonable to allow creation of new ones.

Pillar / config required to test the proposed changes

Debug log showing how the proposed changes work

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

@dafyddj dafyddj requested a review from a team as a code owner September 29, 2020 19:48
@pull-assistant
Copy link

Score: 1.00

Best reviewed: commit by commit


Optimal code review plan

     fix(convert-formulas.sh): add -_ to allowed chars in formula name

Powered by Pull Assistant. Last update b334c82 ... b334c82. Read the comment docs.

Copy link
Contributor

@vutny vutny left a comment

Choose a reason for hiding this comment

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

Looks good

@baby-gnu
Copy link
Contributor

I'm wondering if the tooling accept to have a - in the name of the formula. I think @myii told me something about this.

@noelmcloughlin
Copy link
Member

noelmcloughlin commented Sep 30, 2020

I would be against allowing underscore in formula names because it invalidates current assumptions around semantic naming. Some core maintainers (i.e. me) expect a standard semantic name of <component>-formula using 'dash' as the historic community convention for formula name. In https://github.com/saltstack-formulas/salter I assume '-' and can add '_' but increased flexibility in the naming convention introduces complexity in other places.

@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 30, 2020

I'm wondering if the tooling accept to have a - in the name of the formula. I think @myii told me something about this.

There are at least 13 formulas that have - in their names, so I don't believe there is a tooling issue (although I welcome correction on that), and this change just brings the convert-formula.sh into line with current practice.

I add _ for flexibility, but perhaps it is not necessary.

@myii
Copy link
Member

myii commented Sep 30, 2020

@myii
Copy link
Member

myii commented Sep 30, 2020

I'm wondering if the tooling accept to have a - in the name of the formula. I think @myii told me something about this.

This is a link to that conversation. We can manage (and pretty much have to, due to the sheer volume of formulas already doing this).

https://freenode.logbot.info/saltstack-formulas/20200325#c3478581-c3478644

- - -
20:54 nebuchadnezzar a question, is there a reason to limit the new name used by ./bin/convert-formula.sh ?
20:54 myii What limit is that? Let me look at it again...
20:54 nebuchadnezzar I would like to create a new formula for go-wisper/go-carbon/go-carbonapi and this limitation is too restrictiv for me
20:55 nebuchadnezzar erf, it's not go-carbonapi it's just carbonapi ;-)
20:55 myii But where will it be located in GitHub (or other hosting service)?
20:56 myii https://;project;/https://;repo; right?
20:56 myii CC: @​dafydd -- you may be interested to come back to this little discussion.
20:57 nebuchadnezzar I hope it will be at saltstack-formula/go-wisper-formula
20:59 nebuchadnezzar There are 51 formulas with a dash in their name
20:59 myii OK, maybe the regex is a little restrictive.
20:59 myii But it does make difficulties, though.
21:00 myii Take the syslog-ng-formula for example. I remember there being some horrible things we had to do to get it working in the CI, including changing those dashes to underscores.
21:01 nebuchadnezzar ho, I was not aware of that
21:01 myii https://github.com/myii/ssf-formula/blob/c259684c43e49730445ca7c3327b462447418b25/ssf/formulas.yaml#L4281-L4307
21:01 myii You can see the underscores shown in some of the places there.
21:02 myii Maybe it could have been avoided with better design, I'm not sure. I didn't convert that formula.
21:07 nebuchadnezzar thanks, I'll start locally and I'll change to a better name after, thanks
21:08 myii You're welcome. If you figure out how to get it working with the dash instead of using an underscore, let me know. That will come in useful when converting some of the other formulas.

@myii
Copy link
Member

myii commented Sep 30, 2020

@dafyddj I just need to get around testing both additions locally and then we get this merged if all is OK.

Actually, we really should update the test to have a formula name that contains both - and _, i.e. modify this section:

# Test the conversion of `template-formula` into another formula
# ready for development
- env: 'Conversion'
name: 'Test: bin/convert-formula.sh'
script:
- git clone . tmp/converted-formula
- cd tmp/converted-formula
- DEBUG=true bin/convert-formula.sh converted
- '[ $(git rev-list HEAD --count) -eq 2 ]'
# Quick visual check that correct files have been updated
- git show --pretty="" --name-status
- bin/kitchen verify default-debian-10-tiamat-py3

How about changing from converted-formula to something like test-the_use-this-template_button-formula?

@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 30, 2020

I would be against allowing underscore in formula names because it invalidates current assumptions around semantic naming. Some core maintainers (i.e. me) expect a standard semantic name of <component>-formula using 'dash' as the historic community convention for formula name. In https://github.com/saltstack-formulas/salter I assume '-' and can add '_' but increased flexibility in the naming convention introduces complexity in other places.

Are you referring here specifically to the -formula part of the name because I do not expect anyone to use _formula.
Otherwise, I looked at salter (which I wasn't previously aware of) and can't immediately see where the underscore would cause a problem.

@dafyddj
Copy link
Contributor Author

dafyddj commented Sep 30, 2020

How about changing from converted-formula to something like test-the_use-this-template_button-formula?

Good idea.

@dafyddj dafyddj marked this pull request as draft September 30, 2020 14:04
@baby-gnu
Copy link
Contributor

baby-gnu commented Oct 5, 2020

I would like to propose some formulas we used at work and one of them would be pam-mount-formula.

@dafyddj dafyddj force-pushed the fix/convert-dash-underscore branch 3 times, most recently from 2abcc49 to be56eaa Compare October 6, 2020 17:21
Comment on lines +55 to +59
tag_out=$(git tag --list | xargs git tag --delete)
if [ "${DEBUG:-false}" = "true" ]; then
echo "$tag_out"
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks a lot 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

but someone may argue that it's not the purpose of this PR ;-)

@dafyddj dafyddj force-pushed the fix/convert-dash-underscore branch from be56eaa to facced5 Compare October 28, 2020 23:26
@myii
Copy link
Member

myii commented Oct 30, 2020

@dafyddj I've taken this PR and rebased on the latest version of this formula. I've then run it with:

$ bin/convert-formula.sh test_the_use-this-template-button

I've grabbed the diff between the resultant first and second commits into a gist for commenting purposes (not necessarily action items, primarily discussion). Working from top-to-bottom (not prioritised):

  1. [L49-L1330] General comment, not to be tackled by this PR: A couple of files deleted with 1,250+ lines removed -- could/should this be done in the first commit rather than the second, to avoid clutter in the git history? Further sections include:
    • [L1416-L3287] -- another 1,850+ lines removed.
    • [L3465-L3695] -- another 200+ lines removed.
    • So a total of 3,300+ lines removed, which could be avoided entirely from the git history of the converted repo?
  2. [L3295-L3297] Wish-list, not for this PR, nor critical in any way: How about the script being clever enough to modify the heading symbols to match the change in line length throughout the whole of README.rst?
  3. [L4332-L4334] Change requested for this PR, as discussed in Slack: Please use # yamllint disable-line rule:line-length instead of the current method; the diff here shows that fix already applied.
  4. [L4391-L4392] Confirming behaviour throughout the Jinja in the file conversions (only the first example linked from the gist): So both of these apply?
    • Each hyphen - converted to a single underscore _ -- this is necessary for Jinja variables, IIRC from our conversations.
    • Each underscore - converted to a double underscore __ -- this one initially feels a little wonky but probably makes sense overall.

All-in-all, a fantastic bit of work, kudos!

@dafyddj dafyddj force-pushed the fix/convert-dash-underscore branch from facced5 to 7c33601 Compare October 31, 2020 18:38
@dafyddj
Copy link
Contributor Author

dafyddj commented Oct 31, 2020

3. [L4332-L4334] Change requested for this PR, as discussed in Slack: Please use # yamllint disable-line rule:line-length instead of the current method; the diff here shows that fix already applied.

Done I'll address the other points another time/elsewhere.

@dafyddj
Copy link
Contributor Author

dafyddj commented Oct 31, 2020

[L4391-L4392] Confirming behaviour throughout the Jinja in the file conversions (only the first example linked from the gist): So both of these apply?

  • Each hyphen - converted to a single underscore _ -- this is necessary for Jinja variables, IIRC from our conversations.
  • Each underscore - converted to a double underscore __ -- this one initially feels a little wonky but probably makes sense overall.

The only manipulation done is to convert a hyphen to a double underscore:
NEW_NAME_PYSAFE=$(echo "$NEW_NAME" | sed 's/-/__/g')
I chose a double underscore (rather than a single) just to retain some information that a change was made.

@dafyddj dafyddj marked this pull request as ready for review October 31, 2020 18:50
@dafyddj dafyddj requested a review from a team as a code owner October 31, 2020 18:50
@myii myii merged commit 4be96d3 into saltstack-formulas:master Oct 31, 2020
@myii
Copy link
Member

myii commented Oct 31, 2020

Thanks for all of the reviews, guys.

Merged, @dafyddj.

@saltstack-formulas-travis

🎉 This PR is included in version 4.3.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

myii added a commit to myii/ssf-formula that referenced this pull request Dec 17, 2020
@dafyddj dafyddj deleted the fix/convert-dash-underscore branch November 29, 2024 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants