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

CODENVY-502 allow to create factories by providing custom parameters #1247

Merged
merged 1 commit into from
May 23, 2016

Conversation

benoitf
Copy link
Contributor

@benoitf benoitf commented May 13, 2016

Change-Id: I0c9554ac6d767e110f9bc39c30e2fb2712ad413f
Signed-off-by: Florent BENOIT fbenoit@codenvy.com

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk @vparfonov

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

FYI, in the JIRA issue there is a video

@skabashnyuk
Copy link
Contributor

-1 For the Factory Service.
I don't like idea to add to generic Factory service github specific.
May be it's part of Github Service or GithubFactoryService.

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk it can't be in github service as github is only deployed on workspace agent

@skabashnyuk
Copy link
Contributor

ok GithubFactoryService.
Also FactoryServiceClient should not contains Github sprcific

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

GithubFactoryService with /factory/github mapping is ok ?

@mshaposhnik
Copy link
Contributor

mshaposhnik commented May 13, 2016

Dont forget that github is a plugin. Some custom builds theoretically may not support it.

UPD: we just allowed to create factories with any source type (and gihub too). See #1248

@skabashnyuk
Copy link
Contributor

Not sure yet. BTW why you need that rest method? Why don't you create factory on client ?

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk because logic is server side

@skabashnyuk
Copy link
Contributor

Can you describe a bit more desired parameters and desired behaviour of your rest method? What configuration of factory will be?

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@mshaposhnik it's related to pure git, not github. You don't need github plugin in the agent.

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk parameter is listed in PR. It's to create a factory based on a github url

@garagatyi
Copy link

-1 to include github specific features in common API

}

// use regexp to find repository details (repository name, project name and branch and subfolder)
final Pattern GITHUB_PATTERN = Pattern.compile("^(?:http)(?:s)?(?:\\:\\/\\/)github.com/(.*?)/(.*?)(?:/tree/(.*?)(?:/(.*?))?)?$");

Choose a reason for hiding this comment

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

Compilation of pattern can be improved by making it static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW it will be moved to another class

@skabashnyuk
Copy link
Contributor

BTW it should be POST

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk I don't see why it should be more POST

@skabashnyuk
Copy link
Contributor

I thought it create new factory, NO?

@garagatyi
Copy link

I don't think that we should allow such API for factory. This task should be done by client, not API. It can be done by Java client or Js, but it definitely should not be in the API

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

@skabashnyuk it is indempotent

@skabashnyuk
Copy link
Contributor

-1 for this service.
The whole use case what you are trying to solve can help to understand the way better way of implementation.

@benoitf
Copy link
Contributor Author

benoitf commented May 13, 2016

I have reworked to allow "pluggable" factory resolver. It's now based on plugins
to sum-up : no github introduced directly but allow to plug github, etc through extension mechanisms

@codenvy-ci
Copy link

@skabashnyuk
Copy link
Contributor

I don't get it. The whole picture how it will work is unclear for me.

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

@skabashnyuk
the whole picture is quite easy and described in the specification document
the idea is to have factory model based without creating/storing them. Like the previous "non-encoded factories".
Factories data will be stored inside the repository, not in codenvy database.

@skabashnyuk
Copy link
Contributor

the whole picture is quite easy and described in the specification document

Sorry. Not for me.
It's looks like your vision of technical solution for some sort of user-story.
But initial use case is not described. The missing part is the problem what we are trying to solve.
BTW it may looks like we may need to resurect "non-encoded " factory.

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

I can explain everything you want.
The referenced specification document is written by Tyler
Usecase is the title of this pull request: create factories "on demand" based on a github repository for example if I have a link to a github repository.
This PR enable extensibility which is not available for now by allowing to plug external resolvers and then enhance factories through plugins. So we could extend this for other stuff.

@skabashnyuk
Copy link
Contributor

I think solution should be more general like non-encoded factory.

@TylerJewell
Copy link

We do not have non encoded factory. We have this resolver. The comments should focus on the code readiness. What is left to be improved?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

it's a general solution. And it allows to plug server side logic which is required

@skabashnyuk
Copy link
Contributor

And this functionality has no github specific?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

it has specific part for github that will be provided by a plugin.
(like extracting branch, subfolder, etc from a github url)

?url=https://github.com/ --> handle by github plugin (if enabled else it will provide error like today)
?url=http://foo.com --> error as no plugin is handling (but may work if someone write a plugin for this)

@skabashnyuk
Copy link
Contributor

I would like to understand the scope of this two PR

codenvy/codenvy#195
#1247

Acceptance of
http://beta.codenvy.com/f/?url=sourcodeurl
Without of Github specific?

A couple of thougts.
Puting codenvy.factory.json in repository and using it may intruduce some complexity.
Like we need to have it before workspace creating and can't use cloning, for instance
some vcs providers may not introduce web interface. Other question authentication on
vcs hosting. Are we going to provide this fucntionality for public projects?

What if we provide 3 types of factory?
Current. Most advanced

  1. http://beta.codenvy.com/f/?id=i-123123

Realy realy simple. Jut to play with because with project type blank it's almoust useles.
2. http://beta.codenvy.com/f/?source=sourcodeurl

Allow to users specify external factory json with source authoreplacemet. Almoust identical to 1.
3. http://beta.codenvy.com/f/?factory.json=linktojson

In 2-3 cases during acceptance we will crate persistant factory and continue acceptance as usual.
I think we can't miss this step. AFAIK some part of ide may reuse factory id during workspace liftime

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

The goal is that we don't need persistent factory IN codenvy for 2 and 3. (if 100 users click on a url factory link it would create 100 dummy factories for nothing as persistent state is on the repository)
IDE is receiving factory data without id (this is already done today in my PR)

@skabashnyuk
Copy link
Contributor

ok. So 2-3 are just sending to dashboard and dashboard do the business. Correct?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

no business is done server side

@skabashnyuk
Copy link
Contributor

Not clear for me why.
AFAIK we are accepting factory in dashboard - no?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

FactoryServlet checks if factory is valid before redirecting to dashboard so factory is checked first server side.
then FactoryServlet redirect user to dashboard which create/start workspace which then delegates to IDE the projects acceptance and IDE acceptance
(dashboard and IDE don't do any logic about factory parameters, they just execute the data from the factory object returned from the server that they share)

@skabashnyuk
Copy link
Contributor

So we just missing the part on dashboard how to get from 2-3 format to real Factory object ?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

it asks server side

@skabashnyuk
Copy link
Contributor

from concept point of view
So we just missing the part on dashboard how to get from 2-3 format to real Factory object ?
Correct?

@benoitf
Copy link
Contributor Author

benoitf commented May 16, 2016

there is no missing part as it's implemented in my PR

@skabashnyuk
Copy link
Contributor

skabashnyuk commented May 16, 2016

Not yet. I'm not get the whole picture. And you propose only github specific service.
Let's talk about why we need such kind of service and its obligation and parameters.

@gazarenkov
Copy link
Contributor

As I stated in email thread I need the big picture for factories, so we need a specs after that we discuss and consider this PR.

@benoitf benoitf changed the title CODENVY-502 allow to create factories by providing github URL CODENVY-502 allow to create factories by providing custom parameters May 19, 2016
@benoitf
Copy link
Contributor Author

benoitf commented May 19, 2016

Pull request rewritten
please review

in addition, diagram to understand details
image

@codenvy-ci
Copy link

Build # 628 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/628/ to view the results.

* @param callback
* callback which return valid JSON object of factory or exception if occurred
*/
void getFactory(@NotNull Map<String, String> factoryParameters, boolean validate, @NotNull AsyncRequestCallback<Factory> callback);

Choose a reason for hiding this comment

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

Have you considered usage of promises here? AFAIK it is default codestyle for IDE now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the same pattern than FactoryServiceClient.

Copy link
Contributor

Choose a reason for hiding this comment

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

For new code we prefer to use promises.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe you prefer but this rule is not written anywhere
so, it can't be mandatory

Choose a reason for hiding this comment

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

Copy link
Member

@azatsarynnyy azatsarynnyy May 20, 2016

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@benoitf benoitf May 20, 2016

Choose a reason for hiding this comment

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

ok thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also upgrade the other getFactory method to promise

@codenvy-ci
Copy link

Build # 660 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/660/ to view the results.

@benoitf
Copy link
Contributor Author

benoitf commented May 22, 2016

so we're good now ?

@garagatyi
Copy link

LGTM

@skabashnyuk
Copy link
Contributor

ок

… mechanism based on url parameters

Change-Id: I0c9554ac6d767e110f9bc39c30e2fb2712ad413f
Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
@benoitf benoitf merged commit f3bc97b into master May 23, 2016
@benoitf benoitf deleted the CODENVY-502 branch May 23, 2016 07:27
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.

None yet

8 participants