Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Godep importer #742

Merged
merged 4 commits into from
Jun 12, 2017
Merged

Godep importer #742

merged 4 commits into from
Jun 12, 2017

Conversation

darkowlzz
Copy link
Collaborator

What does this do / why do we need it?

Adds godep config importer support to init.

What should your reviewer look out for in this PR?

Importer logic and test cases.

Which issue(s) does this PR fix?

fixes #577

@darkowlzz darkowlzz mentioned this pull request Jun 10, 2017
@carolynvs carolynvs self-requested a review June 11, 2017 13:14
Copy link
Collaborator

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Just a few small suggestions, otherwise it looks good!

if err != nil {
return nil, nil, err
}
manifest.Constraints[pc.Ident.ProjectRoot] = gps.ProjectProperties{Source: pc.Ident.Source, Constraint: pc.Constraint}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does godep allow specifying an alternative source? I didn't see anything handling that in buildProjectConstraint. If not, we can skip setting the Source field on this line since it will always be "".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't find any way to set alternative source in godep. There's an open issue for the same tools/godep#366 .

}

// Rev must not be empty
if pkg.Rev == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add a unit test to verify error handling when rev is empty too.

}

type godepJSON struct {
Name string `json:"ImportPath"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about removing this field since it's not used for any of the conversion logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, doesn't seem to be useful until we decide to make it mandatory for a valid config file.
Removing :)

Detected godep configuration files...
Converting from Godeps.json ...
Using ^0.8.1 as initial constraint for imported dep github.com/sdboyer/deptest
Trying ^0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is just an FYI. In #715 I am working on fixing the version set in the lock, and once that goes in the godep importer should get that fix automatically. I'll make sure to verify that this test case is updated, as we shouldn't be locking to a version with an operator, i.e. it should be Trying v0.8.1 instead of Trying ^0.8.1 in the feedback. That was my mistake but should be fixed soon!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@carolynvs #715 didn't change this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@darkowlzz You just saved my 🥓 ! I missed a spot in godep's importer. Fixing...

@darkowlzz
Copy link
Collaborator Author

darkowlzz commented Jun 12, 2017

Removed Name field from godepImporter and added test for missing Rev.

Also, added a few checks to:

  • Skip duplicate package imports
  • Skip sub-package imports by deducing project root from the import path

}

// Obtain ProjectRoot. Required for avoiding sub-package imports.
ip, err := g.sm.DeduceProjectRoot(pkg.ImportPath)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What prompted you to check for sub-package imports? I don't remember hitting this with the glide importer and am wondering if this is a general concern for all importers or is godep specific?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay after scrolling down to the test, it makes sense. Glide lists unique packages and then lists the subpackages used separately which explains why I didn't have to check for this. 😁 Carry on!

Copy link
Collaborator

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

This looks great! Can you look into the one staticcheck failure?

- Adds skipping duplicate and sub-package imports using projectExistsInLock().
- Adds tests for missing Rev in godep import package list.
- Removes `Name` field from godepImporter.
@darkowlzz
Copy link
Collaborator Author

Seems to be ready 😊

@carolynvs carolynvs merged commit d2ead1d into golang:master Jun 12, 2017
@carolynvs
Copy link
Collaborator

🎉💃🏻🚀

@sdboyer
Copy link
Member

sdboyer commented Jun 12, 2017

woohoo!! 🎉 🚀 🎊

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support importing godep config during dep init
4 participants