{"action":"created","comment":{"url":"https://api.github.com/repos/Runnable/octobear/pulls/comments/89413654","pull_request_review_id":9959479,"id":89413654,"diff_hunk":"@@ -0,0 +1,220 @@\n+'use strict'\n+\n+const Promise = require('bluebird')\n+const yaml = require('js-yaml')\n+const Joi = require('joi')\n+const hostname = require('@runnable/hostname')\n+\n+const removeNullAndUndefinedKeys = require('./util').removeNullAndUndefinedKeys\n+const validate = require('./util').validate\n+const Parser = require('./parser')\n+const Mapper = require('./mapper')\n+const Warning = require('./warning')\n+\n+const dockerComposeFileSchema = Joi.object({\n+  version: Joi.string().valid('2').required(),\n+  services: Joi.object().required()\n+}).unknown().required()\n+\n+const arrayOfStrings = Joi.array().items(Joi.string())\n+\n+const serviceSchemaKeys = {\n+  build: Joi.alternatives().try(Joi.string(), Joi.object()),\n+  image: Joi.string(),\n+  command: Joi.alternatives().try(Joi.string(), arrayOfStrings),\n+  ports: arrayOfStrings,\n+  expose: arrayOfStrings,\n+  links: arrayOfStrings,\n+  depends_on: arrayOfStrings,\n+  environment: Joi.alternatives().try(Joi.object(), arrayOfStrings)\n+}\n+const serviceSchema = Joi.object(serviceSchemaKeys).unknown().required()\n+\n+module.exports = class DockerComposeParser {\n+\n+  /**\n+   * Parse a docker-compose.yml file into an array of instances that can be\n+   * used by Runnable API Client\n+   *\n+   * @param {Object} opts\n+   * @param {String} opts.dockerComposeFileString - YML File string\n+   * @param {String} opts.repositoryName - Name of repository in GH or other service\n+   * @param {String} opts.userContentDomain - User content domain for API environment. Used for creating hostnames.\n+   * @param {String} opts.ownerUsername - Organization name in Runnable. Used for creating hostnames.\n+   * @return {Promise}\n+   * @resolves {Array<Object>}\n+   */\n+  static parse (opts) {\n+    const dockerComposeFileString = opts.dockerComposeFileString\n+    const repositoryName = opts.repositoryName\n+    const userContentDomain = opts.userContentDomain\n+    const ownerUsername = opts.ownerUsername\n+\n+    return DockerComposeParser._parseDockerComposeFile(dockerComposeFileString)\n+    .then(services => DockerComposeParser._convertToArrayAndAddMetadata(services))\n+    .map(service => DockerComposeParser._serviceParser({ service, repositoryName }))\n+    .map(service => DockerComposeParser._addHostname(service, ownerUsername, userContentDomain))\n+    .then(services => DockerComposeParser._populateEnvsWithHost(services))","path":"lib/index.js","position":57,"original_position":57,"commit_id":"83a59c38a5f08586b8d18d78f6a732effb733934","original_commit_id":"9929a6d2837946eebc0e45b72cbe7b4d8a4b75cd","user":{"login":"thejsj","id":1981198,"avatar_url":"https://avatars.githubusercontent.com/u/1981198?v=3","gravatar_id":"","url":"https://api.github.com/users/thejsj","html_url":"https://github.com/thejsj","followers_url":"https://api.github.com/users/thejsj/followers","following_url":"https://api.github.com/users/thejsj/following{/other_user}","gists_url":"https://api.github.com/users/thejsj/gists{/gist_id}","starred_url":"https://api.github.com/users/thejsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejsj/subscriptions","organizations_url":"https://api.github.com/users/thejsj/orgs","repos_url":"https://api.github.com/users/thejsj/repos","events_url":"https://api.github.com/users/thejsj/events{/privacy}","received_events_url":"https://api.github.com/users/thejsj/received_events","type":"User","site_admin":false},"body":"Fixed.\r\n","created_at":"2016-11-23T23:11:08Z","updated_at":"2016-11-23T23:11:08Z","html_url":"https://github.com/Runnable/octobear/pull/1#discussion_r89413654","pull_request_url":"https://api.github.com/repos/Runnable/octobear/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/comments/89413654"},"html":{"href":"https://github.com/Runnable/octobear/pull/1#discussion_r89413654"},"pull_request":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Runnable/octobear/pulls/1","id":94909710,"html_url":"https://github.com/Runnable/octobear/pull/1","diff_url":"https://github.com/Runnable/octobear/pull/1.diff","patch_url":"https://github.com/Runnable/octobear/pull/1.patch","issue_url":"https://api.github.com/repos/Runnable/octobear/issues/1","number":1,"state":"open","locked":false,"title":"Initial implementation","user":{"login":"thejsj","id":1981198,"avatar_url":"https://avatars.githubusercontent.com/u/1981198?v=3","gravatar_id":"","url":"https://api.github.com/users/thejsj","html_url":"https://github.com/thejsj","followers_url":"https://api.github.com/users/thejsj/followers","following_url":"https://api.github.com/users/thejsj/following{/other_user}","gists_url":"https://api.github.com/users/thejsj/gists{/gist_id}","starred_url":"https://api.github.com/users/thejsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thejsj/subscriptions","organizations_url":"https://api.github.com/users/thejsj/orgs","repos_url":"https://api.github.com/users/thejsj/repos","events_url":"https://api.github.com/users/thejsj/events{/privacy}","received_events_url":"https://api.github.com/users/thejsj/received_events","type":"User","site_admin":false},"body":"Initial Implementation for Docker Compose\r\n\r\n### Missing/TODO:\r\n\r\n- [x] `expose` command support in ports\r\n- [ ] Better warnings for ports\r\n- [ ] Add warning for `Dockerfile` not named `Dockerfile`\r\n- [x] Unit tests for parser\r\n- [x] JSDoc for all functions\r\n- [ ] Add more checks in integration test (Container running?,  HTTP Request with correct response?)\r\n\r\n### Questions\r\n\r\n* How many unit tests should we have? Functional tests currently cover 90%+. Want to write unit tests for some of the parsers `envReplacementParser`, `portParser`, but actually think we don't need 80%+ unit coverage right now. Happy to write them if anyone objects.\r\n* Should test repos be included in current way? Currently some of these are in `RunnableTest` in order to run integration tests. Should we have them as git submodules? \r\n* Is main `parse` function still too long? Should I break it down even more?\r\n* I named this `octobear` (Docker Compose Octopus + Runnable Bear). Any objections?\r\n","created_at":"2016-11-22T22:19:20Z","updated_at":"2016-11-23T23:11:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e99e4cda63b6b60fa175aa37cf89fab85140c10","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Runnable/octobear/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Runnable/octobear/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Runnable/octobear/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Runnable/octobear/issues/1/comments","statuses_url":"https://api.github.com/repos/Runnable/octobear/statuses/83a59c38a5f08586b8d18d78f6a732effb733934","head":{"label":"Runnable:initial-implementation","ref":"initial-implementation","sha":"83a59c38a5f08586b8d18d78f6a732effb733934","user":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"repo":{"id":74503061,"name":"octobear","full_name":"Runnable/octobear","owner":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Runnable/octobear","description":"Docker Compose File parser for Runnable API Client","fork":false,"url":"https://api.github.com/repos/Runnable/octobear","forks_url":"https://api.github.com/repos/Runnable/octobear/forks","keys_url":"https://api.github.com/repos/Runnable/octobear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Runnable/octobear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Runnable/octobear/teams","hooks_url":"https://api.github.com/repos/Runnable/octobear/hooks","issue_events_url":"https://api.github.com/repos/Runnable/octobear/issues/events{/number}","events_url":"https://api.github.com/repos/Runnable/octobear/events","assignees_url":"https://api.github.com/repos/Runnable/octobear/assignees{/user}","branches_url":"https://api.github.com/repos/Runnable/octobear/branches{/branch}","tags_url":"https://api.github.com/repos/Runnable/octobear/tags","blobs_url":"https://api.github.com/repos/Runnable/octobear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Runnable/octobear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Runnable/octobear/git/refs{/sha}","trees_url":"https://api.github.com/repos/Runnable/octobear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Runnable/octobear/statuses/{sha}","languages_url":"https://api.github.com/repos/Runnable/octobear/languages","stargazers_url":"https://api.github.com/repos/Runnable/octobear/stargazers","contributors_url":"https://api.github.com/repos/Runnable/octobear/contributors","subscribers_url":"https://api.github.com/repos/Runnable/octobear/subscribers","subscription_url":"https://api.github.com/repos/Runnable/octobear/subscription","commits_url":"https://api.github.com/repos/Runnable/octobear/commits{/sha}","git_commits_url":"https://api.github.com/repos/Runnable/octobear/git/commits{/sha}","comments_url":"https://api.github.com/repos/Runnable/octobear/comments{/number}","issue_comment_url":"https://api.github.com/repos/Runnable/octobear/issues/comments{/number}","contents_url":"https://api.github.com/repos/Runnable/octobear/contents/{+path}","compare_url":"https://api.github.com/repos/Runnable/octobear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Runnable/octobear/merges","archive_url":"https://api.github.com/repos/Runnable/octobear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Runnable/octobear/downloads","issues_url":"https://api.github.com/repos/Runnable/octobear/issues{/number}","pulls_url":"https://api.github.com/repos/Runnable/octobear/pulls{/number}","milestones_url":"https://api.github.com/repos/Runnable/octobear/milestones{/number}","notifications_url":"https://api.github.com/repos/Runnable/octobear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Runnable/octobear/labels{/name}","releases_url":"https://api.github.com/repos/Runnable/octobear/releases{/id}","deployments_url":"https://api.github.com/repos/Runnable/octobear/deployments","created_at":"2016-11-22T18:46:36Z","updated_at":"2016-11-22T21:22:36Z","pushed_at":"2016-11-23T22:55:52Z","git_url":"git://github.com/Runnable/octobear.git","ssh_url":"git@github.com:Runnable/octobear.git","clone_url":"https://github.com/Runnable/octobear.git","svn_url":"https://github.com/Runnable/octobear","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Runnable:master","ref":"master","sha":"010ffaafac8c028f4b23f9a02228cf41902a7d59","user":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"repo":{"id":74503061,"name":"octobear","full_name":"Runnable/octobear","owner":{"login":"Runnable","id":2828361,"avatar_url":"https://avatars.githubusercontent.com/u/2828361?v=3","gravatar_id":"","url":"https://api.github.com/users/Runnable","html_url":"https://github.com/Runnable","followers_url":"https://api.github.com/users/Runnable/followers","following_url":"https://api.github.com/users/Runnable/following{/other_user}","gists_url":"https://api.github.com/users/Runnable/gists{/gist_id}","starred_url":"https://api.github.com/users/Runnable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Runnable/subscriptions","organizations_url":"https://api.github.com/users/Runnable/orgs","repos_url":"https://api.github.com/users/Runnable/repos","events_url":"https://api.github.com/users/Runnable/events{/privacy}","received_events_url":"https://api.github.com/users/Runnable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Runnable/octobear","description":"Docker Compose File parser for Runnable API Client","fork":false,"url":"https://api.github.com/repos/Runnable/octobear","forks_url":"https://api.github.com/repos/Runnable/octobear/forks","keys_url":"https://api.github.com/repos/Runnable/octobear/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Runnable/octobear/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Runnable/octobear/teams","hooks_url":"https://api.github.com/repos/Runnable/octobear/hooks","issue_events_url":"https://api.github.com/repos/Runnable/octobear/issues/events{/number}","events_url":"https://api.github.com/repos/Runnable/octobear/events","assignees_url":"https://api.github.com/repos/Runnable/octobear/assignees{/user}","branches_url":"https://api.github.com/repos/Runnable/octobear/branches{/branch}","tags_url":"https://api.github.com/repos/Runnable/octobear/tags","blobs_url":"https://api.github.com/repos/Runnable/octobear/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Runnable/octobear/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Runnable/octobear/git/refs{/sha}","trees_url":"https://api.github.com/repos/Runnable/octobear/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Runnable/octobear/statuses/{sha}","languages_url":"https://api.github.com/repos/Runnable/octobear/languages","stargazers_url":"https://api.github.com/repos/Runnable/octobear/stargazers","contributors_url":"https://api.github.com/repos/Runnable/octobear/contributors","subscribers_url":"https://api.github.com/repos/Runnable/octobear/subscribers","subscription_url":"https://api.github.com/repos/Runnable/octobear/subscription","commits_url":"https://api.github.com/repos/Runnable/octobear/commits{/sha}","git_commits_url":"https://api.github.com/repos/Runnable/octobear/git/commits{/sha}","comments_url":"https://api.github.com/repos/Runnable/octobear/comments{/number}","issue_comment_url":"https://api.github.com/repos/Runnable/octobear/issues/comments{/number}","contents_url":"https://api.github.com/repos/Runnable/octobear/contents/{+path}","compare_url":"https://api.github.com/repos/Runnable/octobear/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Runnable/octobear/merges","archive_url":"https://api.github.com/repos/Runnable/octobear/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Runnable/octobear/downloads","issues_url":"https://api.github.com/repos/Runnable/octobear/issues{/number}","pulls_url":"https://api.github.com/repos/Runnable/octobear/pulls{/number}","milestones_url":"https://api.github.com/repos/Runnable/octobear/milestones{/number}","notifications_url":"https://api.github.com/repos/Runnable/octobear/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Runnable/octobear/labels{/name}","releases_url":"https://api.github.com/repos/Runnable/octobear/releases{/id}","deployments_url":"https://api.github.com/repos/Runnable/octobear/deployments","created_at":"2016-11-22T18:46:36Z","updated_at":"2016-11-22T21:22:36Z","pushed_at":"2016-11-23T22:55:52Z","git_url":"git://github.com/Runnable/octobear.git","ssh_url":"git@github.com:Runnable/octobear.git","clone_url":"https://github.com/Runnable/octobear.git","svn_url":"https://github.com/Runnable/octobear","homepage":null,"size":33,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/1"},"html":{"href":"https://github.com/Runnable/octobear/pull/1"},"issue":{"href":"https://api.github.com/repos/Runnable/octobear/issues/1"},"comments":{"href":"https://api.github.com/repos/Runnable/octobear/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Runnable/octobear/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Runnable/octobear/statuses/83a59c38a5f08586b8d18d78f6a732effb733934"}}}}
{"actor":{"display_login":"thejsj"}}