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

Possibility to fetch deploy a service from git #190

Merged
merged 8 commits into from
Jun 6, 2018

Conversation

antho1404
Copy link
Member

@antho1404 antho1404 commented Jun 5, 2018

Now it is possible to automatically fetch the sources from any git repository from the cli.

The following commands are now working and behave like expected (fetch the repository and then build and deploy or test the service)

  • mesg-core service test https://github.com/mesg-foundation/service-ethereum.git
  • mesg-core service deploy https://github.com/mesg-foundation/service-ethereum.git

For now it's not testable because example are already updated according to the pull request #183, we need to merge this one first and test again that everything works fine

fix #157

@antho1404 antho1404 self-assigned this Jun 5, 2018
@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #190 into dev will decrease coverage by 10.34%.
The diff coverage is 57.4%.

Impacted file tree graph

@@            Coverage Diff             @@
##             dev     #190       +/-   ##
==========================================
- Coverage   74.3%   63.96%   -10.35%     
==========================================
  Files         58       69       +11     
  Lines       1187     1515      +328     
==========================================
+ Hits         882      969       +87     
- Misses       234      473      +239     
- Partials      71       73        +2
Impacted Files Coverage Δ
cmd/service/deploy.go 0% <0%> (ø)
cmd/service/test.go 9.75% <57.14%> (ø)
cmd/service/utils.go 69.01% <58.97%> (ø)
api/core/execute.go 84.61% <0%> (-2.06%) ⬇️
conversion/currency.go 100% <0%> (ø) ⬆️
cmd/service/detail.go 0% <0%> (ø)
cmd/service/validate.go 0% <0%> (ø)
cmd/service/start.go 0% <0%> (ø)
cmd/service/list.go 0% <0%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85b5301...3ec4eaa. Read the comment docs.

@@ -31,8 +35,32 @@ func handleError(err error) {
}
}

func gitClone(url string) (path string, err error) {
tmpFile := "/tmp/mesg-templates"
Copy link
Member

@NicolasMahe NicolasMahe Jun 5, 2018

Choose a reason for hiding this comment

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

This is very ugly to put the path in a root folder like this.
It's not even deleted at the end.

If you look at https://golang.org/pkg/io/ioutil/#TempDir, it says If dir is the empty string, TempDir uses the default directory for temporary files
Eg:

dir, err := ioutil.TempDir("", "example")
if err != nil {
	log.Fatal(err)
}
defer os.RemoveAll(dir) // clean up

Copy link
Member

@NicolasMahe NicolasMahe left a comment

Choose a reason for hiding this comment

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

This PR seems to not be finished..
@antho1404 are you sure you push all your local commits?

if err != nil {
return
}
path, err = ioutil.TempDir(tmpFile, string(time.Now().UnixNano()))
Copy link
Member

@NicolasMahe NicolasMahe Jun 5, 2018

Choose a reason for hiding this comment

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

On my computer path is like: /tmp/mesg-templates/�094045028
There is a encoding error. You should use

strconv.FormatInt(time.Now().UnixNano(), 10))

instead of

string(....)

Copy link
Member Author

Choose a reason for hiding this comment

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

even the TempDir accepts empty string for defaults and manages everything so I used that and it takes the defaults from that function better than trying to create a specific folder that might have some conflicts

importedService, err := service.ImportFromPath(path)
var err error
if _, err = url.ParseRequestURI(path); err == nil {
path, err = gitClone(path)
Copy link
Member

Choose a reason for hiding this comment

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

The new path is not forward to the function buildDockerImage thus it cannot build it..

@NicolasMahe NicolasMahe merged commit f0471c0 into dev Jun 6, 2018
@NicolasMahe NicolasMahe deleted the 157-publish-from-git branch June 6, 2018 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish a service from a repo
2 participants