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

(MODULES-1637) Major refactor #103

Merged
merged 1 commit into from
Feb 19, 2015
Merged

(MODULES-1637) Major refactor #103

merged 1 commit into from
Feb 19, 2015

Conversation

juniorsysadmin
Copy link
Member

As mentioned in the Changelog and commit log, this Pull Request if commited will break a few things since major changes have been made to the API.

The code could probably be a bit better, so I have created this PR to get some feedback before I create a some acceptance tests.

@x3dfxjunkie - this PR potentially supercedes PR 102
@b4ldr - this PR potentially supercedes PR 99
@menssen - this PR potentially supercedes PR 96
@CpuID - this PR potentially supercedes PR 94
@aebm - this PR potentially supercedes PR 93
@wassimsalib - this might make your PR 89 redundant
@einyx - this PR potentially supercedes your PR 85
@jurgenweber, @brentax - this PR potentially supercedes PR 82
@jasperla - this PR potentially supercedes PR 80 - Are you perhaps able to check that it works nicely on FreeBSD?
@jlambert121 - this PR potentially supercedes PR 79 - Travis Puppet 2.7 tests have been removed, and I have attempted to use modulesync
@wenlock, @wknapik - this might make PR 70 redundant
@emonty, @rchrd2, @atrepca - this PR potentially supercedes PR 69
@mpdude - this PR potentially supercedes PR 66 - Are you perhaps able to confirm that the MacPorts default npm path is correct?

A few starting points of discussion:

  1. It might be possible to modify this code to be backward-compatible with the current version, but it seems like a lot of work. If one follows the SemVer guidelines, breaking the API for 0.x releases is perfectly okay.
  2. This code adds an explicit dependency on the treydock/gpg_key module for importing the YUM repository keys. I'm not sure if this is a something that is preferred for PuppetLabs modules in particular.
  3. For whatever reason, Node.js often gets installed on a variety of operating systems, included 'bleeding edge' ones. The usual policy of failing hard when newer operating system versions are supported does
    not seem to make sense for this module. Any strong objections?
  4. The Travis CI Puppet 2.7 tests have been removed, because I errored out out with unusual messages on rspec tests, even though a real test on a Puppet 2.7 agent seemed to be successful.
  5. These patches don't modify the npm (global) Puppet provider code, which can probably be left for a new PR. While this code forces the global config settings proxy and https-proxy to be applied first before any local npm packages are installed, it does not do something similar with the npm provider type.
    There is a need for the npm_path parameter since Windows, Darwin and possibly others default to installing npm in various places. The npm defined types have been modified to accommodate this, but the provider has not.
  6. NodeSource haven't released a binaries for Fedora 21, but I would think they are imminent.
  7. I have updated the module version number to 0.7.0 in various places, and if this gets checked in the
    tag on the master will need to be updated as well. This is rather optimistic, so I am happy to reverse these changes.

@juniorsysadmin
Copy link
Member Author

@skpy This incorporates your previous PR on parameterizing package names slightly differently, so you may wish to comment as well.

@jasperla
Copy link

jasperla commented Jan 6, 2015

I'll check if this work on OpenBSD instead of FreeBSD as I've never done any work on this module for FreeBSD.

@juniorsysadmin
Copy link
Member Author

@jasperla My mistake. I have just pushed through another commit. Can you confirm that the default npm path is correct on OpenBSD?


Debian users may want to use apt::pin to pin package installation priority on squeeze. See [puppetlabs-apt](https://github.com/puppetlabs/puppetlabs-apt) for more information.
```puppet
nodejs::npm { 'express|/opt/packages':
Copy link
Member

Choose a reason for hiding this comment

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

Describe the 'express|/opt/packages' string format.

@x3dfxjunkie
Copy link

@juniorsysadmin, that looks like it would make my PR 102 irrelevant (not that I'm complaining).

@sfc-gh-eraigosa
Copy link
Contributor

@juniorsysadmin indeed that would do it. +1 ty!

@juniorsysadmin
Copy link
Member Author

@jasperla - have fixed that in last commit
@rnelson0 - have added some documentation

@rnelson0
Copy link
Member

rnelson0 commented Jan 7, 2015

@juniorsysadmin I think the nodejs::npm docs at the top look better and it doesn't feel too verbose to me, just enough.

@juniorsysadmin
Copy link
Member Author

Rebased. Does anyone have any more feedback to add?

@juniorsysadmin
Copy link
Member Author

Rebased. Optimistic proposed version number changed to 0.8.0.

@@ -1,3 +1,26 @@
##2015-01-21 0.8.0
Copy link
Contributor

Choose a reason for hiding this comment

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

That date's a little optimistic, as a release date. ;)

@juniorsysadmin
Copy link
Member Author

Rebased and some changes made based on feedback.

@juniorsysadmin
Copy link
Member Author

NodeSource haven't released a binaries for Fedora 21, but I would think they are imminent.

NodeSource have released Fedora 21 binaries today on their repository.

@igalic
Copy link
Contributor

igalic commented Jan 27, 2015

general comments: i remain unhappy with node::npm { 'foo|/target/dir': ... }
i would've thought that in a major refactor we would've changed this to target => /target/dir, but i guess the problem here is that we'll run into title uniqueness issues.

@nibalizer
Copy link
Member

I tend to agree with @igalic that the syntax used to hack in composite namvars is startling and my initial reaction to it is negative.

That being said, composite namevars have always been a 'maybe next year' so hacking it in with pipes in the node module, hey why not. The more I look at it, the more excited about the prospect I get.

I haven't been able to review the entire patch despite several attempts. This patch is super huge which is a problem for any reviewer. I hate to be "that guy" but could this be broken up into a few logical chunks?

This seems like it is the best way forward for a real future for this module. @juniorsysadmin do you anticipate being able to take on primary ownership for this module going forward?

To respond directly to the conversation starters:

  1. semver does state that you can YOLO on the entire 0.x lifetime. I think its great to keep it in 0.x so that we can massage this new syntax a bit. I think you should have no fear of breaking compat with the old version.

  2. A lot of modules do hardcode in the gpg keys. Rabbitmq does this. I don't have a preference, if a module makes this easier then I'm ok with it.

  3. Not sure I understand this. Are you saying when an unrecognized operating system is detected it should fail, but you've wired it to not fail and keep on chugging? I suppose I think thats okay.

  4. Puppet 2.7 should diaf.

  5. Largely the node::npm defined type is replacing the provider for the package resource. I think we can let the ruby provider lag in feature set until it's discovered what the utility of the new syntax for packages is figured out.

  6. Sounds like this resolved itself.

  7. Sounds good.

$package_string = $npm_package
}
elsif $ensure == 'absent' {
$package_string = $npm_package
Copy link
Contributor

Choose a reason for hiding this comment

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

these two branches can be collapsed.

@juniorsysadmin
Copy link
Member Author

I haven't been able to review the entire patch despite several attempts. This patch is super huge which is a problem for any reviewer. I hate to be "that guy" but could this be broken up into a few logical chunks?

I could try and do this, but it's going to be really, really hard - the provider is the only code part that escaped unscathed, and that's because I don't have very strong knowledge of Puppet provider types.
It's a bit dishonest to call this a Pull Request - it's really just a fork masquerading as one. So you're better off just looking at the forked code rather than diffs.

  1. Not sure I understand this. Are you saying when an unrecognized operating system is detected it should fail, but you've wired it to not fail and keep on chugging? I suppose I think thats okay.

What my convoluted sentence was trying to say was:

  • This module is not sticking with long term releases as the only 'supported' versions
  • EOL operating system versions are 'not supported'
  • Anything newer than a long term release it will chug away with a warning
    That's the idea anyway.

This seems like it is the best way forward for a real future for this module. @juniorsysadmin do you anticipate being able to take on primary ownership for this module going forward?

I can try - my knowledge of Puppet providers is not great though. The current version looks like an absolute nightmare for anyone who needs to merge PRs, I would think this version would make things a lot easier for whoever needs to merge PRs in future.

$package_string = "${npm_package}@${npm_tag}"
}
elsif $ensure == 'latest' {
$package_string = "${npm_package}@latest"
Copy link
Contributor

Choose a reason for hiding this comment

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

if that was the case, we could, again, collapse these two branches, i.e.: if ensure matches latest, or a version string, just append it.
in that case, it would make sense to make this the default, last case. i.e.: present, absent, etc.. have already been handled, now we just give up and decide it's a version number (or latest)

@nibalizer
Copy link
Member

@hlindberg courtesy ping so you can look at the '|' namevar syntax.

@hlindberg
Copy link

@nibalizer From a language perspective, the title is any valid string and it is up to the type to do what it pleases with it. From a resource perspective it has to be unique. In practice, there are several types where a compound namevar is wanted and it would be a shame if it is done differently in different types.

My natural tendency would be to use URI syntax for this sort of thing - i.e a path within a domain. Protocol is not needed since that is really the type.

@juniorsysadmin
Copy link
Member Author

Based on feedback (especially about the namevar ugliness), the last commit:

  • Allows an arbitary value for the namevar for the nodejs:npm defined type except if one wants to be lazy and not specify a package name
  • Adds a user parameter to allow npm install to be run as a specific user

When ensure => latest is set, the installcheck will always fail and run npm install package@latest - I am not sure if there is much that can be done about this without using a Custom Type. Longer term, a better direction for this defined type is probably a wrapper which calls a Custom Type, similar to the what is done in puppetlabs-mysql etc.

@juniorsysadmin
Copy link
Member Author

Alignment issues in the RSpec files of the last commit have been fixed.

@igalic
Copy link
Contributor

igalic commented Feb 6, 2015

👍 for merge

@eljohnson92
Copy link

When are you planning on merging this? we would like support for updated node

@igalic
Copy link
Contributor

igalic commented Feb 16, 2015

@cyberious, @mhaskel: ping

@nibalizer
Copy link
Member

ya lets merge this +1

This set of patches includes multiple changes and is not backward-compatible.

In summary this code:
- Supercedes PR 99 (MODULES-1075), 97, 96, 94, 93, 85, 82, 80, 79, 51, 69, 66
  and 102
- Explicitly makes Debian Squeeze unsupported
- Makes nodejs, nodejs-dev and nodejs-debug package names parameters
- Defaults to using the NodeSource repositories where possible, but allows
  native packages to be installed when appropriate parameters are set
- Introduces a parameter repo_class, which allows one to use alternative
  repositories like EPEL for the Node.js packages.
- Adds Windows installation support via Chocolatey
- Adds FreeBSD and OpenBSD support
- Changes the format of the nodejs::npm defined type to be module|path
  rather than path:module for the name
- Attempts to support all of the npm install <package> forms, except for
  version ranges. Tags are supported with a separate parameter, and the
  version parameter has been removed (Version numbers can be passed to the
  ensure parameter instead)
- Adds a defined type nodejs::npm::global_config_entry, which allows one to
  set and delete global npm config options. The proxy parameter in nodejs:npm
  has been removed since this can now be done with global_config_entry.
- Adds a number of RSpec unit tests
- Adds a Beaker acceptance test skeleton
@juniorsysadmin
Copy link
Member Author

I have fixed two major issues in nodejs::npm - ensure => absent should now work properly, and default npm paths are now correct on Windows. (The commits have been squashed). I have also done a fair bit of testing of the npm defined type on Linux and Windows, so I'm reasonably satisfied that it works as advertised.

@daenney
Copy link
Member

daenney commented Feb 19, 2015

This code adds an explicit dependency on the treydock/gpg_key module for importing the YUM repository keys. I'm not sure if this is a something that is preferred for PuppetLabs modules in particular.

This shouldn't really be needed. All it takes is to drop one file, the key file, in the right directory: /etc/pki/rpm-gpg/RPM-GPG-KEY-$name.

@nibalizer
Copy link
Member

\o/

@igalic
Copy link
Contributor

igalic commented Feb 19, 2015

it's done!

thank you everyone for reviewing, and thank you so much @juniorsysadmin!

@mmarseglia
Copy link

Thank you @juniorsysadmin!

@juniorsysadmin juniorsysadmin deleted the major-changes branch February 20, 2015 00:19
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.