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

Update vendoring to dep from gdm #3564

Closed
wants to merge 1 commit into from
Closed

Update vendoring to dep from gdm #3564

wants to merge 1 commit into from

Conversation

goller
Copy link
Contributor

@goller goller commented Dec 11, 2017

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Connect #3394

This PR changes Telegraf's vendoring from gdm to dep Dep is getting closer and closer to be ready to go (see https://github.com/golang/dep#current-status)

To generate the dep files (Gopkg.lock and .toml) I used deps automatic conversion from the godep vendoring solution.

Gdm's Godep file is similar to godeps. Here is a python program I wrote to convert gdm's Godep to godep's format:

#!/usr/bin/env python
import json

with open('Godeps') as godeps:
    conversion = {
        "ImportPath": "github.com/tools/godep",
	"GoVersion": "go1.9",
	"GodepVersion": "v74",
	"Deps": []
    }
    deps = godeps.readlines()
    for dep in deps:
        package, sha = dep.split()
        conversion["Deps"].append({
            "ImportPath": package,
            "Rev": sha
        })

    print(json.dumps(conversion, indent=4))

... and the shell script ...

python convert.py > howdy
rm Godeps           # the godeps vendoring uses a Godeps directory
mkdir Godeps
mv howdy Godeps/Godeps.json
dep init -v         # initializes the vendoring directory using Godeps/Godeps.json
dep ensure          # ensures all files are in the vendor directory
dep status          # status of the vendoring... pretty interesting.

There are other details that this PR should have

@crazy-canux
Copy link
Contributor

Looks good.
Gdm will never make succeed.
When can I use dep?

@smyrman
Copy link

smyrman commented Mar 15, 2018

Understand why the Gopkg.toml has far far far fewer entries than the lock.

This is normal. The Gopkg.toml gives constrains to dep ensure / dep ensure -update, and nothing more. It doesn't need to contain a single entry if there is nothing that needs special treatment, e.g. a module (repo) with breaking changes not to be updated to the latest release or a module to be retrieved directly from master (or hotfix branch) etc.

@goller
Copy link
Contributor Author

goller commented Mar 15, 2018

@smyrman Do you have some links you could share about that? I'd love to read up to make sure I understand.

@smyrman
Copy link

smyrman commented Mar 16, 2018

The statement above is based on us having used the tool for various projects for the last several months. Our Gopkg.toml files are always very short, and always hand-edited to contain the most basic constraints only. You can put more constraints if you wish, but it's not needed to generate a valid lockfile which is automatically kept up to date based on code changes. This separates it massively from other tools such as e.g. glide, and makes it a lot more convenient to use.

Please refer to the official documentation: https://golang.github.io/dep/docs/Gopkg.toml.html

glinton added a commit that referenced this pull request Jun 18, 2018
@glinton glinton mentioned this pull request Jun 18, 2018
3 tasks
glinton added a commit that referenced this pull request Jun 18, 2018
@glinton glinton deleted the feature/dep branch June 19, 2018 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants