diff options
author | Stan Hu <stanhu@gmail.com> | 2016-08-19 20:38:44 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-08-19 20:38:44 +0000 |
commit | 310eef45213b56f17686045cc12ac9297585a1d8 (patch) | |
tree | dde202349dea1a43ee91be8ed39f97f106622210 /app/helpers | |
parent | b06f9211b0c3a90200c030e84ae425778bac6412 (diff) | |
parent | a927a9bf6baa99be94181c3ab980947621ae2fe0 (diff) | |
download | gitlab-ce-310eef45213b56f17686045cc12ac9297585a1d8.tar.gz |
Merge branch 'gokmengoksel/gitlab-ce-koding' into 'master'
Koding Integration
## What does this MR do?
Will provide Koding integration with GitLab services. Forked from !4914.
## Are there points in the code the reviewer needs to double check?
I've introduced new layouts which might not be necessary, first time contributor.
## Why was this MR needed?
We're planning to ship Koding with GitLab.
## What are the relevant issue numbers?
#12759 #14698
## Screenshots (if relevant)
### Screencasts
http://recordit.co/BDMbhwgxPD
http://recordit.co/By0qiz1ClC
### Enable Koding in Application Settings
![image](/uploads/73a69421105c03aa2b0b47e2617d3fbc/image.png)
### Koding Dashboard
![image](/uploads/6c7dda34792280c0e4791e36af4eba11/image.png)
### Set up Koding Stack
1 - ![image](/uploads/d5c2b93f8e61b5cbffdb06f0267d485f/image.png)
2 - ![image](/uploads/44d9a9b574b8ac0c5eb553fb9653d5da/image.png)
### Run on Koding on Project Page
![image](/uploads/7d2b46221009074ffff75d66d5a1a555/image.png)
### Run in IDE on Merge Requests
![image](/uploads/65eed90c34c34b5fe7ad29ef9c717640/image.png)
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5909
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_settings_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/projects_helper.rb | 54 |
2 files changed, 58 insertions, 0 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 78c0b79d2bd..6de25bea654 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -31,6 +31,10 @@ module ApplicationSettingsHelper current_application_settings.akismet_enabled? end + def koding_enabled? + current_application_settings.koding_enabled? + end + def allowed_protocols_present? current_application_settings.enabled_git_access_protocol.present? end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 505545fbabb..249d18c4486 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -236,6 +236,60 @@ module ProjectsHelper ) end + def add_koding_stack_path(project) + namespace_project_new_blob_path( + project.namespace, + project, + project.default_branch || 'master', + file_name: '.koding.yml', + commit_message: "Add Koding stack script", + content: <<-CONTENT.strip_heredoc + provider: + aws: + access_key: '${var.aws_access_key}' + secret_key: '${var.aws_secret_key}' + resource: + aws_instance: + #{project.path}-vm: + instance_type: t2.nano + user_data: |- + + # Created by GitLab UI for :> + + echo _KD_NOTIFY_@Installing Base packages...@ + + apt-get update -y + apt-get install git -y + + echo _KD_NOTIFY_@Cloning #{project.name}...@ + + export KODING_USER=${var.koding_user_username} + export REPO_URL=#{root_url}${var.koding_queryString_repo}.git + export BRANCH=${var.koding_queryString_branch} + + sudo -i -u $KODING_USER git clone $REPO_URL -b $BRANCH + + echo _KD_NOTIFY_@#{project.name} cloned.@ + CONTENT + ) + end + + def koding_project_url(project = nil, branch = nil, sha = nil) + if project + import_path = "/Home/Stacks/import" + + repo = project.path_with_namespace + branch ||= project.default_branch + sha ||= project.commit.short_id + + path = "#{import_path}?repo=#{repo}&branch=#{branch}&sha=#{sha}" + + return URI.join(current_application_settings.koding_url, path).to_s + end + + current_application_settings.koding_url + end + def contribution_guide_path(project) if project && contribution_guide = project.repository.contribution_guide namespace_project_blob_path( |