{"action":"created","comment":{"url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments/28974175","id":28974175,"diff_hunk":"@@ -0,0 +1,464 @@\n+/*\n+ * This file is part of Cockpit.\n+ *\n+ * Copyright (C) 2015 Red Hat, Inc.\n+ *\n+ * Cockpit is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU Lesser General Public License as published by\n+ * the Free Software Foundation; either version 2.1 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * Cockpit is distributed in the hope that it will be useful, but\n+ * WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public License\n+ * along with Cockpit; If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+define([\n+    \"jquery\",\n+    \"base1/cockpit\",\n+    \"kubernetes/client\",\n+    \"base1/mustache\"\n+], function($, cockpit, kubernetes, Mustache) {\n+    \"use strict\";\n+\n+    var _ = cockpit.gettext;\n+\n+    var appdeployer = {};\n+    var client = kubernetes.k8client();\n+    var POD = \"Pod\";\n+    var SERVICE = \"Service\";\n+    var RC = \"ReplicationController\";\n+    var NS = \"Namespace\";\n+    var valid_manifest = false;\n+    var valid_ns = false;\n+    var namespacetxt = \"\";\n+\n+\n+    function failure(ex) {\n+        console.warn(ex);\n+    }\n+\n+    function isJsonString(str) {\n+        try {\n+            JSON.parse(str);\n+        } catch (e) {\n+            return false;\n+        }\n+        return true;\n+    }\n+\n+    function deploy_manager() {\n+\n+        var is_deploying = $('#deploy-app-deploying');\n+\n+        function deploy(namespace, jsonData) {\n+\n+            remove_notifications();\n+\n+            var services = [];\n+            var rcs = [];\n+            var pods = [];\n+            var namespaces = [];\n+            var has_errors = false;\n+            var text = \"\";\n+            var file_note = $('#deploy-app-manifest-file-note');\n+            var file_note_details = $('#deploy-app-manifest-file-note-details');\n+            var deploying_app_details = $('#deploy-app-deploying-details');\n+            show_progress_message();\n+\n+            var deploy_btn = $('#deploy-app-start');\n+            deploy_btn.prop(\"disabled\", true);\n+\n+            if (isJsonString(jsonData)) {\n+                var jdata = JSON.parse(jsonData);\n+                if(jdata.kind === \"List\") {\n+                    if (jdata.items) {\n+                        for (var i = 0; i < jdata.items.length; i++) {\n+                            var ent_json = jdata.items[i];\n+                            if (ent_json.kind === SERVICE) {\n+                                services.push(ent_json);\n+                            } else if (ent_json.kind === POD) {\n+                                pods.push(ent_json);\n+                            } else if (ent_json.kind === RC) {\n+                                rcs.push(ent_json);\n+                            } else if (ent_json.kind === NS) {\n+                                namespaces.push(ent_json);\n+                            }\n+                        }\n+                    } else {\n+                        text = _(\"Unable to read the Kubernetes application manifest file. \");\n+                        file_note.show().text(text);\n+                        return;\n+                    }\n+                } else {\n+                    if (jdata.kind === SERVICE) {\n+                        services.push(jdata);\n+                    } else if (jdata.kind === POD) {\n+                        pods.push(jdata);\n+                    } else if (jdata.kind === RC) {\n+                        rcs.push(jdata);\n+                    } else if (jdata.kind === NS) {\n+                        namespaces.push(jdata);\n+                    } else {\n+                        text = _(\"Unsupported Entity. \");\n+                        file_note.show().text(text);\n+                        return;\n+                    }\n+                }\n+            } else {\n+                text = _(\"Unable to read the Kubernetes application manifest file. \");\n+                file_note.show().text(text);\n+                return;\n+            }\n+\n+            create_everything(namespace, services, rcs, pods)\n+                .progress(function(code, response, n, total) {\n+                    //TODO Progress bar\n+\n+                })\n+                .done(function() {\n+                    /* code gets run when everything is created */\n+                    disable_deploy_button();\n+                    hide_progress_message();\n+                     $('#deploy-app-dialog').modal('hide');\n+\n+                })\n+                .fail(function(ex, response) {\n+                    /* ex containst the failure */\n+                    enable_deploy_button();\n+                    var jdata = JSON.parse(response);\n+                    var err_msg = jdata.message;\n+                    if(jdata.code === 409){\n+                        err_msg = \"Please create another namespace for \"+ jdata.details.kind + \"\\\"\"+ jdata.details.id +\"\\\"\";","path":"pkg/kubernetes/deploy.js","position":136,"original_position":136,"commit_id":"46ed7a9bc5931484efe844e2cb66368ece086957","original_commit_id":"46ed7a9bc5931484efe844e2cb66368ece086957","user":{"login":"stefwalter","id":795070,"avatar_url":"https://avatars.githubusercontent.com/u/795070?v=3","gravatar_id":"","url":"https://api.github.com/users/stefwalter","html_url":"https://github.com/stefwalter","followers_url":"https://api.github.com/users/stefwalter/followers","following_url":"https://api.github.com/users/stefwalter/following{/other_user}","gists_url":"https://api.github.com/users/stefwalter/gists{/gist_id}","starred_url":"https://api.github.com/users/stefwalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefwalter/subscriptions","organizations_url":"https://api.github.com/users/stefwalter/orgs","repos_url":"https://api.github.com/users/stefwalter/repos","events_url":"https://api.github.com/users/stefwalter/events{/privacy}","received_events_url":"https://api.github.com/users/stefwalter/received_events","type":"User","site_admin":false},"body":"We should use cockpit.format() here, and then wrap the text in _(\"\") so it can be translated.","created_at":"2015-04-23T15:36:55Z","updated_at":"2015-04-23T15:36:55Z","html_url":"https://github.com/cockpit-project/cockpit/pull/1989#discussion_r28974175","pull_request_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989","_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments/28974175"},"html":{"href":"https://github.com/cockpit-project/cockpit/pull/1989#discussion_r28974175"},"pull_request":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989"}}},"pull_request":{"url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989","id":31730686,"html_url":"https://github.com/cockpit-project/cockpit/pull/1989","diff_url":"https://github.com/cockpit-project/cockpit/pull/1989.diff","patch_url":"https://github.com/cockpit-project/cockpit/pull/1989.patch","issue_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/1989","number":1989,"state":"open","locked":false,"title":"Deploy kubernetes application","user":{"login":"sub-mod","id":7363264,"avatar_url":"https://avatars.githubusercontent.com/u/7363264?v=3","gravatar_id":"","url":"https://api.github.com/users/sub-mod","html_url":"https://github.com/sub-mod","followers_url":"https://api.github.com/users/sub-mod/followers","following_url":"https://api.github.com/users/sub-mod/following{/other_user}","gists_url":"https://api.github.com/users/sub-mod/gists{/gist_id}","starred_url":"https://api.github.com/users/sub-mod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sub-mod/subscriptions","organizations_url":"https://api.github.com/users/sub-mod/orgs","repos_url":"https://api.github.com/users/sub-mod/repos","events_url":"https://api.github.com/users/sub-mod/events{/privacy}","received_events_url":"https://api.github.com/users/sub-mod/received_events","type":"User","site_admin":false},"body":"deploy kubernetes application\r\nhttps://github.com/cockpit-project/cockpit/wiki/Feature:-Kubernetes:-Deploy-application","created_at":"2015-03-23T13:18:14Z","updated_at":"2015-04-23T15:36:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8168365dc151a945bd5339100bd1cd8109b6d7f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989/commits","review_comments_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989/comments","review_comment_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/1989/comments","statuses_url":"https://api.github.com/repos/cockpit-project/cockpit/statuses/46ed7a9bc5931484efe844e2cb66368ece086957","head":{"label":"sub-mod:deploy_app","ref":"deploy_app","sha":"46ed7a9bc5931484efe844e2cb66368ece086957","user":{"login":"sub-mod","id":7363264,"avatar_url":"https://avatars.githubusercontent.com/u/7363264?v=3","gravatar_id":"","url":"https://api.github.com/users/sub-mod","html_url":"https://github.com/sub-mod","followers_url":"https://api.github.com/users/sub-mod/followers","following_url":"https://api.github.com/users/sub-mod/following{/other_user}","gists_url":"https://api.github.com/users/sub-mod/gists{/gist_id}","starred_url":"https://api.github.com/users/sub-mod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sub-mod/subscriptions","organizations_url":"https://api.github.com/users/sub-mod/orgs","repos_url":"https://api.github.com/users/sub-mod/repos","events_url":"https://api.github.com/users/sub-mod/events{/privacy}","received_events_url":"https://api.github.com/users/sub-mod/received_events","type":"User","site_admin":false},"repo":{"id":29312092,"name":"cockpit","full_name":"sub-mod/cockpit","owner":{"login":"sub-mod","id":7363264,"avatar_url":"https://avatars.githubusercontent.com/u/7363264?v=3","gravatar_id":"","url":"https://api.github.com/users/sub-mod","html_url":"https://github.com/sub-mod","followers_url":"https://api.github.com/users/sub-mod/followers","following_url":"https://api.github.com/users/sub-mod/following{/other_user}","gists_url":"https://api.github.com/users/sub-mod/gists{/gist_id}","starred_url":"https://api.github.com/users/sub-mod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sub-mod/subscriptions","organizations_url":"https://api.github.com/users/sub-mod/orgs","repos_url":"https://api.github.com/users/sub-mod/repos","events_url":"https://api.github.com/users/sub-mod/events{/privacy}","received_events_url":"https://api.github.com/users/sub-mod/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sub-mod/cockpit","description":"Cockpit, a user interface for GNU/Linux servers","fork":true,"url":"https://api.github.com/repos/sub-mod/cockpit","forks_url":"https://api.github.com/repos/sub-mod/cockpit/forks","keys_url":"https://api.github.com/repos/sub-mod/cockpit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sub-mod/cockpit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sub-mod/cockpit/teams","hooks_url":"https://api.github.com/repos/sub-mod/cockpit/hooks","issue_events_url":"https://api.github.com/repos/sub-mod/cockpit/issues/events{/number}","events_url":"https://api.github.com/repos/sub-mod/cockpit/events","assignees_url":"https://api.github.com/repos/sub-mod/cockpit/assignees{/user}","branches_url":"https://api.github.com/repos/sub-mod/cockpit/branches{/branch}","tags_url":"https://api.github.com/repos/sub-mod/cockpit/tags","blobs_url":"https://api.github.com/repos/sub-mod/cockpit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sub-mod/cockpit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sub-mod/cockpit/git/refs{/sha}","trees_url":"https://api.github.com/repos/sub-mod/cockpit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sub-mod/cockpit/statuses/{sha}","languages_url":"https://api.github.com/repos/sub-mod/cockpit/languages","stargazers_url":"https://api.github.com/repos/sub-mod/cockpit/stargazers","contributors_url":"https://api.github.com/repos/sub-mod/cockpit/contributors","subscribers_url":"https://api.github.com/repos/sub-mod/cockpit/subscribers","subscription_url":"https://api.github.com/repos/sub-mod/cockpit/subscription","commits_url":"https://api.github.com/repos/sub-mod/cockpit/commits{/sha}","git_commits_url":"https://api.github.com/repos/sub-mod/cockpit/git/commits{/sha}","comments_url":"https://api.github.com/repos/sub-mod/cockpit/comments{/number}","issue_comment_url":"https://api.github.com/repos/sub-mod/cockpit/issues/comments{/number}","contents_url":"https://api.github.com/repos/sub-mod/cockpit/contents/{+path}","compare_url":"https://api.github.com/repos/sub-mod/cockpit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sub-mod/cockpit/merges","archive_url":"https://api.github.com/repos/sub-mod/cockpit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sub-mod/cockpit/downloads","issues_url":"https://api.github.com/repos/sub-mod/cockpit/issues{/number}","pulls_url":"https://api.github.com/repos/sub-mod/cockpit/pulls{/number}","milestones_url":"https://api.github.com/repos/sub-mod/cockpit/milestones{/number}","notifications_url":"https://api.github.com/repos/sub-mod/cockpit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sub-mod/cockpit/labels{/name}","releases_url":"https://api.github.com/repos/sub-mod/cockpit/releases{/id}","created_at":"2015-01-15T18:40:27Z","updated_at":"2015-01-23T12:01:29Z","pushed_at":"2015-04-23T15:09:05Z","git_url":"git://github.com/sub-mod/cockpit.git","ssh_url":"git@github.com:sub-mod/cockpit.git","clone_url":"https://github.com/sub-mod/cockpit.git","svn_url":"https://github.com/sub-mod/cockpit","homepage":"http://www.cockpit-project.org/","size":14323,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockpit-project:master","ref":"master","sha":"f504a1adb5d8cca93068bd6dc32d2c59ef701ecf","user":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars.githubusercontent.com/u/5765104?v=3","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"repo":{"id":14049216,"name":"cockpit","full_name":"cockpit-project/cockpit","owner":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars.githubusercontent.com/u/5765104?v=3","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockpit-project/cockpit","description":"Cockpit, a user interface for Linux servers","fork":false,"url":"https://api.github.com/repos/cockpit-project/cockpit","forks_url":"https://api.github.com/repos/cockpit-project/cockpit/forks","keys_url":"https://api.github.com/repos/cockpit-project/cockpit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockpit-project/cockpit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockpit-project/cockpit/teams","hooks_url":"https://api.github.com/repos/cockpit-project/cockpit/hooks","issue_events_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/events{/number}","events_url":"https://api.github.com/repos/cockpit-project/cockpit/events","assignees_url":"https://api.github.com/repos/cockpit-project/cockpit/assignees{/user}","branches_url":"https://api.github.com/repos/cockpit-project/cockpit/branches{/branch}","tags_url":"https://api.github.com/repos/cockpit-project/cockpit/tags","blobs_url":"https://api.github.com/repos/cockpit-project/cockpit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockpit-project/cockpit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockpit-project/cockpit/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockpit-project/cockpit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockpit-project/cockpit/statuses/{sha}","languages_url":"https://api.github.com/repos/cockpit-project/cockpit/languages","stargazers_url":"https://api.github.com/repos/cockpit-project/cockpit/stargazers","contributors_url":"https://api.github.com/repos/cockpit-project/cockpit/contributors","subscribers_url":"https://api.github.com/repos/cockpit-project/cockpit/subscribers","subscription_url":"https://api.github.com/repos/cockpit-project/cockpit/subscription","commits_url":"https://api.github.com/repos/cockpit-project/cockpit/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockpit-project/cockpit/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockpit-project/cockpit/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockpit-project/cockpit/contents/{+path}","compare_url":"https://api.github.com/repos/cockpit-project/cockpit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockpit-project/cockpit/merges","archive_url":"https://api.github.com/repos/cockpit-project/cockpit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockpit-project/cockpit/downloads","issues_url":"https://api.github.com/repos/cockpit-project/cockpit/issues{/number}","pulls_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls{/number}","milestones_url":"https://api.github.com/repos/cockpit-project/cockpit/milestones{/number}","notifications_url":"https://api.github.com/repos/cockpit-project/cockpit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockpit-project/cockpit/labels{/name}","releases_url":"https://api.github.com/repos/cockpit-project/cockpit/releases{/id}","created_at":"2013-11-01T17:36:46Z","updated_at":"2015-04-23T07:19:32Z","pushed_at":"2015-04-23T15:09:06Z","git_url":"git://github.com/cockpit-project/cockpit.git","ssh_url":"git@github.com:cockpit-project/cockpit.git","clone_url":"https://github.com/cockpit-project/cockpit.git","svn_url":"https://github.com/cockpit-project/cockpit","homepage":"http://www.cockpit-project.org/","size":33763,"stargazers_count":972,"watchers_count":972,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":106,"mirror_url":null,"open_issues_count":294,"forks":106,"open_issues":294,"watchers":972,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989"},"html":{"href":"https://github.com/cockpit-project/cockpit/pull/1989"},"issue":{"href":"https://api.github.com/repos/cockpit-project/cockpit/issues/1989"},"comments":{"href":"https://api.github.com/repos/cockpit-project/cockpit/issues/1989/comments"},"review_comments":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989/comments"},"review_comment":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/1989/commits"},"statuses":{"href":"https://api.github.com/repos/cockpit-project/cockpit/statuses/46ed7a9bc5931484efe844e2cb66368ece086957"}}}}