Create a Factory in the Dashboard
Action |
In the user dashboard: |
Sample Factory |
Creating a Factory in the dashboard gives you the most freedom and control. The simplest way is to create a Factory based on an existing workspace, but you can also create Factories based on a template we provide or by pasting in a factory.json file and then generating a Factory URL using our CLI or API. Learn more the JSON structure and options in our Factory JSON reference.
A Factory created from the dashboard will be persisted into Che database and kept when upgrading to a newer version.
Create a Factory in the IDE
Action |
In the IDE: |
Sample Factory |
Creating a Factory from inside the IDE in a running workspace will generate a Factory to replicate that workspace including both runtime and project settings.
A Factory created from the dashboard will be persisted onto Che and kept when upgrading to a newer version.
Create a Factory based on a Repo
Action |
Specify the repo URL. In this case the configuration must be stored inside the repository. |
Sample Factories |
http://che.openshift.io/f?url=https://github.com/eclipse/che |
URL Factories work with GitHub and GitLab repositories. By using URL Factories, the project referenced by the URL is automatically imported.
The Factory URL can include a branch or a subfolder. Here is an example of optional parameters:
-
?url=https://github.com/eclipse/cheche will be imported with master branch -
?url=https://github.com/eclipse/che/tree/5.0.0che is imported by using 5.0.0 branch -
?url=https://github.com/eclipse/che/tree/5.0.0/dashboardsubfolder dashboard is imported by using 5.0.0 branch
Customizing URL Factories
There are 2 ways of customizing the runtime and configuration.
Customizing only the runtime
Dockerfile works on Docker infra only!
Providing a .factory.dockerfile inside the repository will signal to the Che URL Factory to use this Dockerfile for the workspace agent runtime. By default imported projects are set to a blank project type, however project type can be set in the .factory.json or workspace definition that the Factory inherits from.
Customizing the project and runtime
Providing a .factory.json file inside the repository will signal to Che URL Factory to configure the project and runtime according to this configuration file. When a .factory.json file is stored inside the repository, any Dockerfile content is ignored as the workspace runtime configuration is defined inside the JSON file.
Factory policies
Policies are a way to send instructions to the automation engine about the number of workspaces to create and their meta data such as lifespan and resource allocation.
Limitations
- Referer
-
Checks the hostname of the acceptor and only allows the Factory to execute if there is a match.
- Since & Until
-
Defines the time window in which the Factory can be activated. For example, instructors who want to create an exercise that can only be accessed for two hours could set these properties.
Multiplicity
Defines how many workspaces should be created from the factory.
- Multiple Workspaces: perClick
-
Every click of the Factory URL will generate a different workspace, each with its own identifier, name and resources.
- Single Workspace: perUser
-
Exactly one workspace will be generated for each unique user that clicks on the Factory URL. If the workspace has previously been generated, we will reopen the existing workspace.
See JSON reference to learn how to configure Factory policies.
IDE Customization
You can instruct the Factory to invoke a series of IDE actions based upon events in the lifecycle of the workspace.
Lifecycle Events
The lifecycle of the workspace is defined with the following events:
-
onAppLoaded: Triggered when the IDE is loaded. -
onProjectsLoaded: Triggered when the workspace and all projects have been activated. -
onAppClosed: Triggered when the IDE is closed.
Each event type has a set of actions that can be triggered. There is no ordering of actions executed when you provide a list; Che will asynchronously invoke multiple actions if appropriate.
Factory Actions
Below is the list of all possible actions which can be configured with your Factory.
- Run Command
-
Description: Specify the name of the command to invoke after the IDE is loaded.
Associated Event:onProjectsLoaded - Open File
-
Description: Open project files in the editor. Optionally define line to be highlighted.
Associated Event:onProjectsLoaded - Open a Welcome Page
-
Description: Customize content of a welcome panel displayed when the workspace is loaded.
Associated Event:onAppLoaded - Warm on Uncommitted Changes
-
Description: Opens a warning popup when the user closes the browser tab with a project that has uncommitted changes.
Associated Event:onAppClosed
See the Factory JSON reference to learn how to configure Factory actions.
Find and Replace
Sometimes you may not want to expose certain sensitive information in source code (passwords, URLs, account names, API keys etc). Factories make it possible to replace variables or placeholders with real values. Find and replace can be run as a Run Command during onProjectsLoaded event. You can use sed, awk or any other tools that are available in your workspace environment.
Find in the Factory JSON reference a sample showing how to configure a "Find and Replace" command. Alternatively, you may also add IDE actions in Factory tab, in User Dashboard.
Use regular expressions in sed, both in find/replace and file/file types patterns.
Pull Request Workflow
Factories can be configured with a dedicated pull request workflow. The PR workflow handles local & remote branching, forking, and issuing the pull request. Pull requests generated from within Che have another Factory placed into the comments of the pull requests that a PR reviewer can use to quickly start the workspace.
When enabled, the pull request workflow adds a contribution panel to the IDE.
Repository Badging
If you have projects in GitHub or GitLab, you can help your contributors to get started by providing them ready-to-code developer workspaces. Create a factory and add the following badge on your repositories readme.md:
[](your-factory-url)
Nest Steps
Read on to learn more about:
-
Customizing factories with the Factory JSON reference. Or jump back to the Factory getting started page if you missed it.