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

Adding svn provider support for versioning of individual files #274

Merged
merged 1 commit into from Sep 30, 2016

Conversation

squarebracket
Copy link

I extended the SVN provider to include some particular functionality I needed, but I'm not sure if it fits with the "goal" of the module. If it does, I'll add tests and make it more robust; otherwise I'll fork it off into my own module.

Two features have been added to the provider.

  1. Export support
    Added :export parameter/feature to type/provider -- accepts :true or :false
    Provider runs svn export instead of svn checkout if :export is true, which creates an non-versioned copy of the working tree in path. Of course, since it is non-versioned, there is no way of tracking revision through svn, so each subsequent puppet run requires :force to be true.
  2. Cherry-picking individual files from the repo
    Added :files parameter/feature to type/provider -- accepts array (Should probably be renamed to :paths)
    Implements functionality of subversion sparse directories. Only useful when using a non-full depth. It calls svn update on the paths that are passed through to it.
    In other words, if you want to check out only certain parts of the repo to the local working tree, you could, for example, do:
vcsrepo { '/some/local/directory':
  ensure => present,
  provider => svn,
  depth => 'immediates',
  source => 'http://svn.example.com/',
  files => ['/some/path', '/some/file.txt', '/some/otherfile.txt']
}

@hunner
Copy link

hunner commented Nov 11, 2015

Of note, svn export is similar to git archive --remote=git://... <branch> | tar xf - which outputs just the work tree with no repo attached. (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html)

It's nice to have portable options between providers with similar functionality. I think the name export is appropriate for this feature, as the word archive could be used for creating an actual tarball of the contents (say, svn export into tar in the svn provider).

@hunner
Copy link

hunner commented Nov 11, 2015

I don't really understand what files does from your description. It only updates SOME files from the repo, instead of all of them? Why is this useful?

@sodabrew
Copy link

How will the provider know when it needs to update the output without talking to the network every time? I think you'll end up rewriting the targets on every puppet execution.

@squarebracket
Copy link
Author

I can definitely add in the export functionality to the git provider as well.

Regarding files, I'll let you know how I'm using it since that will probably provide a clearer picture of its use case. I use it to pull just the jmeter test plan files from our tests repository. I don't pull down the entire repo because it also includes documentation, example properties files, and example data files, and I don't want to clutter the working directory where I launch jmeter tests.

In a more general sense, I see it as a (poorly-named) implementation of subversion's sparse directories functionality.

@squarebracket
Copy link
Author

@sodabrew if you're talking about the export functionality, that is correct.

@squarebracket
Copy link
Author

Updated first comment to make the files point clearer in its use.

@jonnytdevops
Copy link

@hunner Do you think this is something we'd like inside a puppet module? As @sodabrew says, the module would have to communicate over the network on each run. Maybe that's ok, as it would only do this when using this new 'files' property, but it may not be a "moduley" things...

end

newparam :files, :required_features => [:files] do
desc "The files to pull from the SVN server"
Copy link

Choose a reason for hiding this comment

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

This mentions SVN explicitly, but it may be usable from other providers.

@hunner
Copy link

hunner commented Mar 24, 2016

After community review in the weekly PR triage, we are 👍 for functionality, 👍 for bandwidth concerns, and 👍 for the property names files and export

@HelenCampbell
Copy link

Hey @squarebracket , thank you for your contribution! We would be keen to get this merged, however there are a few things we need to do so. Would you be willing to add documentation to the README and some tests for your added functionality?

@squarebracket
Copy link
Author

Hi! Yes, I saw the comments from a few days ago. I've been a bit busy working on the puppet-graphite module so I haven't had a chance to get around to this. I'll push some tests/docs in the next couple weeks and bump the thread when I'm done.

@squarebracket squarebracket changed the title Adding svn provider support for export and versioning of individual files (WIP) Adding svn provider support for versioning of individual files (WIP) Aug 29, 2016
@squarebracket
Copy link
Author

Ok, I reworked things quite a bit since the last update.

Functionality changes

I renamed the files parameter to be includes, since I think that makes way more sense. It is now a property that can be properly tracked and changed. Providing paths to includes auto-activates sparse mode (i.e. it checks out the root repo with --depth empty), and if a depth is given, it will check out the includes paths at that depth. See the docs for a better explanation.

I've decided to drop support for export since it cluttered up the code too much with if/else and a boat load of warnings. However, after looking at the magic inside the type's ensure, I'm thinking that, if export is implemented, it should be implemented as an ensure type. I think it would be much clearer that way that you're getting an unversioned copy. I'd like to hear your feedback, but regardless, it won't be part of this PR.

Tests

Added unit tests for all the includes stuff, as well as some acceptance tests, cuz why not.

Docs

Updated documentation with a verbose explanation of how sparse stuff works.

Outstanding issues

I purposely checked in an acceptance test that is failing. It is that switching sources does not work. The type/provider will not know that the source has changed, since source is a param and not a property. I'd like to know what should be done about this. Should I change source to a property, and implement the logic in all of the providers? I see you're doing some fancy stuff with multiple remotes in the git provider, but I didn't look over it too much.

Also, there's somewhat of a name clash between excludes, which is more like "local ignore paths" and includes, which is paths to check out from the repo. I want to know if you have any reservations about this.

@squarebracket
Copy link
Author

Woops, accidentally checked in my libvirt puppet vagrant box, just undid that.

@squarebracket
Copy link
Author

The only test that's failing is the one I noted before -- the acceptance test for switching sources. This is intentional because it's something that needs to be fixed. If you'd like me to file a bug in JIRA to have the discussion there, let me know.

@squarebracket
Copy link
Author

Did this come up at your meeting yesterday by any chance?

@hunner
Copy link

hunner commented Sep 15, 2016

The ability to change the source as a property should probably be submitted in a separate PR that this depends on. For the git provider, the update_remotes method is essentially the source=(value) property setter, and the exists? method would be updated to use the getter (called source) instead of working_copy_exists?

- Added `includes` parameter to type/provider
  Calls `svn update --depth empty` on root path, and then `svn update`
  on paths provided to `includes`

Also added acceptance tests for SVN provider, cuz why not.
@squarebracket squarebracket changed the title Adding svn provider support for versioning of individual files (WIP) Adding svn provider support for versioning of individual files Sep 29, 2016
@eputnam eputnam merged commit 6e16029 into puppetlabs:master Sep 30, 2016
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.

None yet

7 participants