{"action":"created","comment":{"url":"https://api.github.com/repos/istio/istio/pulls/comments/180929818","pull_request_review_id":111439789,"id":180929818,"diff_hunk":"@@ -0,0 +1,354 @@\n+// Copyright 2018 Istio Authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package validation\n+\n+import (\n+\t\"crypto/tls\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"path/filepath\"\n+\t\"sync\"\n+\t\"time\"\n+\n+\t\"github.com/ghodss/yaml\"\n+\t\"github.com/howeyc/fsnotify\"\n+\tadmissionv1beta1 \"k8s.io/api/admission/v1beta1\"\n+\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n+\t\"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured\"\n+\t\"k8s.io/apimachinery/pkg/runtime\"\n+\t\"k8s.io/apimachinery/pkg/runtime/serializer\"\n+\n+\t\"istio.io/istio/mixer/adapter\"\n+\t\"istio.io/istio/mixer/pkg/config\"\n+\tmixerCrd \"istio.io/istio/mixer/pkg/config/crd\"\n+\t\"istio.io/istio/mixer/pkg/config/store\"\n+\t\"istio.io/istio/mixer/pkg/lang/checker\"\n+\truntimeConfig \"istio.io/istio/mixer/pkg/runtime/config\"\n+\t\"istio.io/istio/mixer/pkg/runtime/validator\"\n+\t\"istio.io/istio/mixer/pkg/template\"\n+\tgeneratedTmplRepo \"istio.io/istio/mixer/template\"\n+\t\"istio.io/istio/pilot/pkg/config/kube/crd\"\n+\t\"istio.io/istio/pilot/pkg/model\"\n+\t\"istio.io/istio/pkg/log\"\n+)\n+\n+var (\n+\truntimeScheme = runtime.NewScheme()\n+\tcodecs        = serializer.NewCodecFactory(runtimeScheme)\n+\tdeserializer  = codecs.UniversalDeserializer()\n+)\n+\n+const (\n+\twatchDebounceDelay = 100 * time.Millisecond\n+)\n+\n+// WebhookParameters contains the configuration for the Istio Pilot validation\n+// admission controller.\n+type WebhookParameters struct {\n+\t// MixerValidator implements the backend validator functions for mixer configuration.\n+\tMixerValidator store.BackendValidator\n+\n+\t// PilotDescriptor provides a description of all pilot configuration resources.\n+\tPilotDescriptor model.ConfigDescriptor\n+\n+\t// DomainSuffix is the DNS domain suffix for Pilot CRD resources,\n+\t// e.g. cluster.local.\n+\tDomainSuffix string\n+\n+\t// Port where the webhook is served. Per k8s admission\n+\t// registration requirements this should be 443 unless there is\n+\t// only a single port for the service.\n+\tPort uint\n+\n+\t// CertFile is the path to the x509 certificate for https.\n+\tCertFile string\n+\n+\t// KeyFile is the path to the x509 private key matching `CertFile`.\n+\tKeyFile string\n+\n+\t// HealthCheckInterval configures how frequently the health check\n+\t// file is updated. Value of zero disables the health check\n+\t// update.\n+\tHealthCheckInterval time.Duration\n+\n+\t// HealthCheckFile specifies the path to the health check file\n+\t// that is periodically updated.\n+\tHealthCheckFile string\n+}\n+\n+// Webhook implements the validating admission webhook for validating Istio configuration.\n+type Webhook struct {\n+\tmu   sync.RWMutex\n+\tcert *tls.Certificate\n+\n+\t// pilot\n+\tdescriptor   model.ConfigDescriptor\n+\tdomainSuffix string\n+\n+\t// mixer\n+\tvalidator store.BackendValidator\n+\n+\thealthCheckInterval time.Duration\n+\thealthCheckFile     string\n+\tserver              *http.Server\n+\twatcher             *fsnotify.Watcher\n+\tcertFile            string\n+\tkeyFile             string\n+}\n+\n+// CreateMixerValidator creates a mixer backend validator.\n+func CreateMixerValidator(kubeconfig string) (store.BackendValidator, error) {\n+\tinfo := generatedTmplRepo.SupportedTmplInfo","path":"galley/pkg/crd/validation/webhook.go","position":115,"original_position":115,"commit_id":"c76d6c2b6b458ee7a068d7b11db7124e97b2ca78","original_commit_id":"c76d6c2b6b458ee7a068d7b11db7124e97b2ca78","user":{"login":"ayj","id":116378,"avatar_url":"https://avatars1.githubusercontent.com/u/116378?v=4","gravatar_id":"","url":"https://api.github.com/users/ayj","html_url":"https://github.com/ayj","followers_url":"https://api.github.com/users/ayj/followers","following_url":"https://api.github.com/users/ayj/following{/other_user}","gists_url":"https://api.github.com/users/ayj/gists{/gist_id}","starred_url":"https://api.github.com/users/ayj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayj/subscriptions","organizations_url":"https://api.github.com/users/ayj/orgs","repos_url":"https://api.github.com/users/ayj/repos","events_url":"https://api.github.com/users/ayj/events{/privacy}","received_events_url":"https://api.github.com/users/ayj/received_events","type":"User","site_admin":false},"body":"Per our offline discussion I'd prefer to reverse the order since config validation is P0 for Istio 1.0. I created https://github.com/istio/istio/issues/4887 to track the follow-up refactoring.","created_at":"2018-04-11T23:43:19Z","updated_at":"2018-04-11T23:43:20Z","html_url":"https://github.com/istio/istio/pull/4811#discussion_r180929818","pull_request_url":"https://api.github.com/repos/istio/istio/pulls/4811","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/istio/istio/pulls/comments/180929818"},"html":{"href":"https://github.com/istio/istio/pull/4811#discussion_r180929818"},"pull_request":{"href":"https://api.github.com/repos/istio/istio/pulls/4811"}},"in_reply_to_id":180570387},"pull_request":{"url":"https://api.github.com/repos/istio/istio/pulls/4811","id":180080548,"html_url":"https://github.com/istio/istio/pull/4811","diff_url":"https://github.com/istio/istio/pull/4811.diff","patch_url":"https://github.com/istio/istio/pull/4811.patch","issue_url":"https://api.github.com/repos/istio/istio/issues/4811","number":4811,"state":"open","locked":false,"title":"Add common config validation service","user":{"login":"ayj","id":116378,"avatar_url":"https://avatars1.githubusercontent.com/u/116378?v=4","gravatar_id":"","url":"https://api.github.com/users/ayj","html_url":"https://github.com/ayj","followers_url":"https://api.github.com/users/ayj/followers","following_url":"https://api.github.com/users/ayj/following{/other_user}","gists_url":"https://api.github.com/users/ayj/gists{/gist_id}","starred_url":"https://api.github.com/users/ayj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayj/subscriptions","organizations_url":"https://api.github.com/users/ayj/orgs","repos_url":"https://api.github.com/users/ayj/repos","events_url":"https://api.github.com/users/ayj/events{/privacy}","received_events_url":"https://api.github.com/users/ayj/received_events","type":"User","site_admin":false},"body":"Create a common webhook service for server-side configuration validation. This uses the existing pilot and mixer validation code for now. The k8s webhook specific code, cert provisioning, and registration has been copied from the sidecar-injector. \r\n\r\nThis service is optional (requires >= k8s 1.9) so I created a new component. Instead of creating a throwaway service (i.e. config-validator), and since Galley will be responsible for config validation anyway, I went ahead and created the galley component, charts, etc. The validation service is run from the `validator` subcommand. \r\n\r\nfixes https://github.com/istio/istio/issues/1894\r\n\r\nTODO in follow-up PRs\r\n- [ ] add integration test\r\n- [ ] update e2e test(s) to use server-side validation. Depends on https://github.com/istio/istio/issues/4340\r\n- [ ] update istio.io documentation","created_at":"2018-04-07T00:43:09Z","updated_at":"2018-04-11T23:43:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7e2e3f6b31e19603dfd0e10673d82d46339d967","assignee":{"login":"xiaolanz","id":28876302,"avatar_url":"https://avatars1.githubusercontent.com/u/28876302?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaolanz","html_url":"https://github.com/xiaolanz","followers_url":"https://api.github.com/users/xiaolanz/followers","following_url":"https://api.github.com/users/xiaolanz/following{/other_user}","gists_url":"https://api.github.com/users/xiaolanz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaolanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaolanz/subscriptions","organizations_url":"https://api.github.com/users/xiaolanz/orgs","repos_url":"https://api.github.com/users/xiaolanz/repos","events_url":"https://api.github.com/users/xiaolanz/events{/privacy}","received_events_url":"https://api.github.com/users/xiaolanz/received_events","type":"User","site_admin":false},"assignees":[{"login":"xiaolanz","id":28876302,"avatar_url":"https://avatars1.githubusercontent.com/u/28876302?v=4","gravatar_id":"","url":"https://api.github.com/users/xiaolanz","html_url":"https://github.com/xiaolanz","followers_url":"https://api.github.com/users/xiaolanz/followers","following_url":"https://api.github.com/users/xiaolanz/following{/other_user}","gists_url":"https://api.github.com/users/xiaolanz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiaolanz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiaolanz/subscriptions","organizations_url":"https://api.github.com/users/xiaolanz/orgs","repos_url":"https://api.github.com/users/xiaolanz/repos","events_url":"https://api.github.com/users/xiaolanz/events{/privacy}","received_events_url":"https://api.github.com/users/xiaolanz/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":753784566,"url":"https://api.github.com/repos/istio/istio/labels/area/config","name":"area/config","color":"0e8a16","default":false},{"id":491318011,"url":"https://api.github.com/repos/istio/istio/labels/cla:%20yes","name":"cla: yes","color":"bfdadc","default":false},{"id":484582415,"url":"https://api.github.com/repos/istio/istio/labels/kind/enhancement","name":"kind/enhancement","color":"fbca04","default":false},{"id":671106566,"url":"https://api.github.com/repos/istio/istio/labels/kind/needed%20for%201.0","name":"kind/needed for 1.0","color":"fbca04","default":false},{"id":663804851,"url":"https://api.github.com/repos/istio/istio/labels/needs-rebase","name":"needs-rebase","color":"bfdadc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/istio/istio/pulls/4811/commits","review_comments_url":"https://api.github.com/repos/istio/istio/pulls/4811/comments","review_comment_url":"https://api.github.com/repos/istio/istio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/istio/istio/issues/4811/comments","statuses_url":"https://api.github.com/repos/istio/istio/statuses/c76d6c2b6b458ee7a068d7b11db7124e97b2ca78","head":{"label":"ayj:enable-config-validation","ref":"enable-config-validation","sha":"c76d6c2b6b458ee7a068d7b11db7124e97b2ca78","user":{"login":"ayj","id":116378,"avatar_url":"https://avatars1.githubusercontent.com/u/116378?v=4","gravatar_id":"","url":"https://api.github.com/users/ayj","html_url":"https://github.com/ayj","followers_url":"https://api.github.com/users/ayj/followers","following_url":"https://api.github.com/users/ayj/following{/other_user}","gists_url":"https://api.github.com/users/ayj/gists{/gist_id}","starred_url":"https://api.github.com/users/ayj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayj/subscriptions","organizations_url":"https://api.github.com/users/ayj/orgs","repos_url":"https://api.github.com/users/ayj/repos","events_url":"https://api.github.com/users/ayj/events{/privacy}","received_events_url":"https://api.github.com/users/ayj/received_events","type":"User","site_admin":false},"repo":{"id":109037660,"name":"istio","full_name":"ayj/istio","owner":{"login":"ayj","id":116378,"avatar_url":"https://avatars1.githubusercontent.com/u/116378?v=4","gravatar_id":"","url":"https://api.github.com/users/ayj","html_url":"https://github.com/ayj","followers_url":"https://api.github.com/users/ayj/followers","following_url":"https://api.github.com/users/ayj/following{/other_user}","gists_url":"https://api.github.com/users/ayj/gists{/gist_id}","starred_url":"https://api.github.com/users/ayj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayj/subscriptions","organizations_url":"https://api.github.com/users/ayj/orgs","repos_url":"https://api.github.com/users/ayj/repos","events_url":"https://api.github.com/users/ayj/events{/privacy}","received_events_url":"https://api.github.com/users/ayj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ayj/istio","description":"Sample code, build and tests and governance material for the Istio project.","fork":true,"url":"https://api.github.com/repos/ayj/istio","forks_url":"https://api.github.com/repos/ayj/istio/forks","keys_url":"https://api.github.com/repos/ayj/istio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ayj/istio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ayj/istio/teams","hooks_url":"https://api.github.com/repos/ayj/istio/hooks","issue_events_url":"https://api.github.com/repos/ayj/istio/issues/events{/number}","events_url":"https://api.github.com/repos/ayj/istio/events","assignees_url":"https://api.github.com/repos/ayj/istio/assignees{/user}","branches_url":"https://api.github.com/repos/ayj/istio/branches{/branch}","tags_url":"https://api.github.com/repos/ayj/istio/tags","blobs_url":"https://api.github.com/repos/ayj/istio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ayj/istio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ayj/istio/git/refs{/sha}","trees_url":"https://api.github.com/repos/ayj/istio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ayj/istio/statuses/{sha}","languages_url":"https://api.github.com/repos/ayj/istio/languages","stargazers_url":"https://api.github.com/repos/ayj/istio/stargazers","contributors_url":"https://api.github.com/repos/ayj/istio/contributors","subscribers_url":"https://api.github.com/repos/ayj/istio/subscribers","subscription_url":"https://api.github.com/repos/ayj/istio/subscription","commits_url":"https://api.github.com/repos/ayj/istio/commits{/sha}","git_commits_url":"https://api.github.com/repos/ayj/istio/git/commits{/sha}","comments_url":"https://api.github.com/repos/ayj/istio/comments{/number}","issue_comment_url":"https://api.github.com/repos/ayj/istio/issues/comments{/number}","contents_url":"https://api.github.com/repos/ayj/istio/contents/{+path}","compare_url":"https://api.github.com/repos/ayj/istio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ayj/istio/merges","archive_url":"https://api.github.com/repos/ayj/istio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ayj/istio/downloads","issues_url":"https://api.github.com/repos/ayj/istio/issues{/number}","pulls_url":"https://api.github.com/repos/ayj/istio/pulls{/number}","milestones_url":"https://api.github.com/repos/ayj/istio/milestones{/number}","notifications_url":"https://api.github.com/repos/ayj/istio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ayj/istio/labels{/name}","releases_url":"https://api.github.com/repos/ayj/istio/releases{/id}","deployments_url":"https://api.github.com/repos/ayj/istio/deployments","created_at":"2017-10-31T18:35:53Z","updated_at":"2017-10-31T18:35:57Z","pushed_at":"2018-04-11T21:42:34Z","git_url":"git://github.com/ayj/istio.git","ssh_url":"git@github.com:ayj/istio.git","clone_url":"https://github.com/ayj/istio.git","svn_url":"https://github.com/ayj/istio","homepage":"https://istio.io","size":19451,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"istio:master","ref":"master","sha":"7e3dba366e669481358e97ef498c330015f93ac4","user":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"repo":{"id":74175805,"name":"istio","full_name":"istio/istio","owner":{"login":"istio","id":23534644,"avatar_url":"https://avatars1.githubusercontent.com/u/23534644?v=4","gravatar_id":"","url":"https://api.github.com/users/istio","html_url":"https://github.com/istio","followers_url":"https://api.github.com/users/istio/followers","following_url":"https://api.github.com/users/istio/following{/other_user}","gists_url":"https://api.github.com/users/istio/gists{/gist_id}","starred_url":"https://api.github.com/users/istio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istio/subscriptions","organizations_url":"https://api.github.com/users/istio/orgs","repos_url":"https://api.github.com/users/istio/repos","events_url":"https://api.github.com/users/istio/events{/privacy}","received_events_url":"https://api.github.com/users/istio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/istio/istio","description":"An open platform to connect, manage, and secure microservices.","fork":false,"url":"https://api.github.com/repos/istio/istio","forks_url":"https://api.github.com/repos/istio/istio/forks","keys_url":"https://api.github.com/repos/istio/istio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/istio/istio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/istio/istio/teams","hooks_url":"https://api.github.com/repos/istio/istio/hooks","issue_events_url":"https://api.github.com/repos/istio/istio/issues/events{/number}","events_url":"https://api.github.com/repos/istio/istio/events","assignees_url":"https://api.github.com/repos/istio/istio/assignees{/user}","branches_url":"https://api.github.com/repos/istio/istio/branches{/branch}","tags_url":"https://api.github.com/repos/istio/istio/tags","blobs_url":"https://api.github.com/repos/istio/istio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/istio/istio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/istio/istio/git/refs{/sha}","trees_url":"https://api.github.com/repos/istio/istio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/istio/istio/statuses/{sha}","languages_url":"https://api.github.com/repos/istio/istio/languages","stargazers_url":"https://api.github.com/repos/istio/istio/stargazers","contributors_url":"https://api.github.com/repos/istio/istio/contributors","subscribers_url":"https://api.github.com/repos/istio/istio/subscribers","subscription_url":"https://api.github.com/repos/istio/istio/subscription","commits_url":"https://api.github.com/repos/istio/istio/commits{/sha}","git_commits_url":"https://api.github.com/repos/istio/istio/git/commits{/sha}","comments_url":"https://api.github.com/repos/istio/istio/comments{/number}","issue_comment_url":"https://api.github.com/repos/istio/istio/issues/comments{/number}","contents_url":"https://api.github.com/repos/istio/istio/contents/{+path}","compare_url":"https://api.github.com/repos/istio/istio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/istio/istio/merges","archive_url":"https://api.github.com/repos/istio/istio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/istio/istio/downloads","issues_url":"https://api.github.com/repos/istio/istio/issues{/number}","pulls_url":"https://api.github.com/repos/istio/istio/pulls{/number}","milestones_url":"https://api.github.com/repos/istio/istio/milestones{/number}","notifications_url":"https://api.github.com/repos/istio/istio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/istio/istio/labels{/name}","releases_url":"https://api.github.com/repos/istio/istio/releases{/id}","deployments_url":"https://api.github.com/repos/istio/istio/deployments","created_at":"2016-11-18T23:57:21Z","updated_at":"2018-04-11T20:48:36Z","pushed_at":"2018-04-11T23:24:20Z","git_url":"git://github.com/istio/istio.git","ssh_url":"git@github.com:istio/istio.git","clone_url":"https://github.com/istio/istio.git","svn_url":"https://github.com/istio/istio","homepage":"https://istio.io","size":19803,"stargazers_count":7162,"watchers_count":7162,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":935,"mirror_url":null,"archived":false,"open_issues_count":824,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":935,"open_issues":824,"watchers":7162,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/istio/istio/pulls/4811"},"html":{"href":"https://github.com/istio/istio/pull/4811"},"issue":{"href":"https://api.github.com/repos/istio/istio/issues/4811"},"comments":{"href":"https://api.github.com/repos/istio/istio/issues/4811/comments"},"review_comments":{"href":"https://api.github.com/repos/istio/istio/pulls/4811/comments"},"review_comment":{"href":"https://api.github.com/repos/istio/istio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/istio/istio/pulls/4811/commits"},"statuses":{"href":"https://api.github.com/repos/istio/istio/statuses/c76d6c2b6b458ee7a068d7b11db7124e97b2ca78"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ayj"}}