{"action":"created","comment":{"url":"https://api.github.com/repos/stripe/skycfg/pulls/comments/238841029","pull_request_review_id":181482536,"id":238841029,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzODg0MTAyOQ==","diff_hunk":"@@ -149,25 +149,48 @@ func WithProtoRegistry(r unstableProtoRegistry) LoadOption {\n \t})\n }\n \n+// UnstablePredeclaredModules returns a Starlark string dictionary with\n+// predeclared Skycfg modules which can be used in starlark.ExecFile.\n+//\n+// Takes in unstableProtoRegistry as param (if nil will use standard proto\n+// registry).\n+//\n+// Currently provides these modules (see REAMDE for more detailed description):\n+//  * fail   - interrupts execution and prints a stacktrace.\n+//  * hash   - supports md5, sha1 and sha245 functions.\n+//  * json   - marshals plain values (dicts, lists, etc) to JSON.\n+//  * proto  - package for constructing Protobuf messages.\n+//  * struct - experimental Starlark struct support.\n+//  * yaml   - same as \"json\" package but for YAML.\n+//  * url    - utility package for encoding URL query string.\n+func UnstablePredeclaredModules(r unstableProtoRegistry) starlark.StringDict {\n+\treturn starlark.StringDict{\n+\t\t\"fail\":   starlark.NewBuiltin(\"fail\", skyFail),\n+\t\t\"hash\":   impl.HashModule(),\n+\t\t\"json\":   impl.JsonModule(),\n+\t\t\"proto\":  impl.NewProtoModule(r),\n+\t\t\"struct\": starlark.NewBuiltin(\"struct\", starlarkstruct.Make),\n+\t\t\"yaml\":   impl.YamlModule(),\n+\t\t\"url\":    impl.UrlModule(),\n+\t}\n+}\n+\n // Load reads a Skycfg config file from the filesystem.\n func Load(ctx context.Context, filename string, opts ...LoadOption) (*Config, error) {\n-\tprotoModule := impl.NewProtoModule(nil /* TODO: registry from options */)\n \tparsedOpts := &loadOptions{\n-\t\tglobals: starlark.StringDict{\n-\t\t\t\"fail\":   starlark.NewBuiltin(\"fail\", skyFail),\n-\t\t\t\"hash\":   impl.HashModule(),\n-\t\t\t\"json\":   impl.JsonModule(),\n-\t\t\t\"proto\":  protoModule,\n-\t\t\t\"struct\": starlark.NewBuiltin(\"struct\", starlarkstruct.Make),\n-\t\t\t\"yaml\":   impl.YamlModule(),\n-\t\t\t\"url\":    impl.UrlModule(),\n-\t\t},\n+\t\tglobals:    UnstablePredeclaredModules(nil),\n \t\tfileReader: LocalFileReader(filepath.Dir(filename)),\n \t}\n+\n \tfor _, opt := range opts {\n \t\topt.applyLoad(parsedOpts)\n \t}\n-\tprotoModule.Registry = parsedOpts.protoRegistry\n+\n+\t// Set the proto registry option if proto package was configured.\n+\tif p, ok := parsedOpts.globals[\"proto\"]; ok {\n+\t\tp.(*impl.ProtoModule).Registry = parsedOpts.protoRegistry","path":"skycfg.go","position":54,"original_position":54,"commit_id":"a5dacb476de74623753fa44197909f65164d60aa","original_commit_id":"a5dacb476de74623753fa44197909f65164d60aa","user":{"login":"jmillikin-stripe","id":28275929,"node_id":"MDQ6VXNlcjI4Mjc1OTI5","avatar_url":"https://avatars3.githubusercontent.com/u/28275929?v=4","gravatar_id":"","url":"https://api.github.com/users/jmillikin-stripe","html_url":"https://github.com/jmillikin-stripe","followers_url":"https://api.github.com/users/jmillikin-stripe/followers","following_url":"https://api.github.com/users/jmillikin-stripe/following{/other_user}","gists_url":"https://api.github.com/users/jmillikin-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/jmillikin-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmillikin-stripe/subscriptions","organizations_url":"https://api.github.com/users/jmillikin-stripe/orgs","repos_url":"https://api.github.com/users/jmillikin-stripe/repos","events_url":"https://api.github.com/users/jmillikin-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/jmillikin-stripe/received_events","type":"User","site_admin":false},"body":"If constructing the default globals is moved into a helper, then we can safely provide both the new interface (returning a single dict) and support the existing `Load()` semantics.","created_at":"2018-12-04T21:14:58Z","updated_at":"2018-12-04T21:14:59Z","html_url":"https://github.com/stripe/skycfg/pull/19#discussion_r238841029","pull_request_url":"https://api.github.com/repos/stripe/skycfg/pulls/19","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/comments/238841029"},"html":{"href":"https://github.com/stripe/skycfg/pull/19#discussion_r238841029"},"pull_request":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/19"}},"in_reply_to_id":238052427},"pull_request":{"url":"https://api.github.com/repos/stripe/skycfg/pulls/19","id":235118644,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM1MTE4NjQ0","html_url":"https://github.com/stripe/skycfg/pull/19","diff_url":"https://github.com/stripe/skycfg/pull/19.diff","patch_url":"https://github.com/stripe/skycfg/pull/19.patch","issue_url":"https://api.github.com/repos/stripe/skycfg/issues/19","number":19,"state":"open","locked":false,"title":"Re-export Skycfg modules as Stalark predeclared values.","user":{"login":"dilyevsky","id":767232,"node_id":"MDQ6VXNlcjc2NzIzMg==","avatar_url":"https://avatars2.githubusercontent.com/u/767232?v=4","gravatar_id":"","url":"https://api.github.com/users/dilyevsky","html_url":"https://github.com/dilyevsky","followers_url":"https://api.github.com/users/dilyevsky/followers","following_url":"https://api.github.com/users/dilyevsky/following{/other_user}","gists_url":"https://api.github.com/users/dilyevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dilyevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilyevsky/subscriptions","organizations_url":"https://api.github.com/users/dilyevsky/orgs","repos_url":"https://api.github.com/users/dilyevsky/repos","events_url":"https://api.github.com/users/dilyevsky/events{/privacy}","received_events_url":"https://api.github.com/users/dilyevsky/received_events","type":"User","site_admin":false},"body":"This would allow users to use Skycfg modules as additional predeclared packages in their own Starlark runtime.","created_at":"2018-11-30T21:21:37Z","updated_at":"2018-12-04T21:14:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f8bb2082a70d81e873eef39b782bde73fce877c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stripe/skycfg/pulls/19/commits","review_comments_url":"https://api.github.com/repos/stripe/skycfg/pulls/19/comments","review_comment_url":"https://api.github.com/repos/stripe/skycfg/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stripe/skycfg/issues/19/comments","statuses_url":"https://api.github.com/repos/stripe/skycfg/statuses/a5dacb476de74623753fa44197909f65164d60aa","head":{"label":"dilyevsky:feature/re-export-internal","ref":"feature/re-export-internal","sha":"a5dacb476de74623753fa44197909f65164d60aa","user":{"login":"dilyevsky","id":767232,"node_id":"MDQ6VXNlcjc2NzIzMg==","avatar_url":"https://avatars2.githubusercontent.com/u/767232?v=4","gravatar_id":"","url":"https://api.github.com/users/dilyevsky","html_url":"https://github.com/dilyevsky","followers_url":"https://api.github.com/users/dilyevsky/followers","following_url":"https://api.github.com/users/dilyevsky/following{/other_user}","gists_url":"https://api.github.com/users/dilyevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dilyevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilyevsky/subscriptions","organizations_url":"https://api.github.com/users/dilyevsky/orgs","repos_url":"https://api.github.com/users/dilyevsky/repos","events_url":"https://api.github.com/users/dilyevsky/events{/privacy}","received_events_url":"https://api.github.com/users/dilyevsky/received_events","type":"User","site_admin":false},"repo":{"id":159879759,"node_id":"MDEwOlJlcG9zaXRvcnkxNTk4Nzk3NTk=","name":"skycfg","full_name":"dilyevsky/skycfg","private":false,"owner":{"login":"dilyevsky","id":767232,"node_id":"MDQ6VXNlcjc2NzIzMg==","avatar_url":"https://avatars2.githubusercontent.com/u/767232?v=4","gravatar_id":"","url":"https://api.github.com/users/dilyevsky","html_url":"https://github.com/dilyevsky","followers_url":"https://api.github.com/users/dilyevsky/followers","following_url":"https://api.github.com/users/dilyevsky/following{/other_user}","gists_url":"https://api.github.com/users/dilyevsky/gists{/gist_id}","starred_url":"https://api.github.com/users/dilyevsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dilyevsky/subscriptions","organizations_url":"https://api.github.com/users/dilyevsky/orgs","repos_url":"https://api.github.com/users/dilyevsky/repos","events_url":"https://api.github.com/users/dilyevsky/events{/privacy}","received_events_url":"https://api.github.com/users/dilyevsky/received_events","type":"User","site_admin":false},"html_url":"https://github.com/dilyevsky/skycfg","description":"Skycfg is an extension library for the Starlark language that adds support for constructing Protocol Buffer messages.","fork":true,"url":"https://api.github.com/repos/dilyevsky/skycfg","forks_url":"https://api.github.com/repos/dilyevsky/skycfg/forks","keys_url":"https://api.github.com/repos/dilyevsky/skycfg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dilyevsky/skycfg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dilyevsky/skycfg/teams","hooks_url":"https://api.github.com/repos/dilyevsky/skycfg/hooks","issue_events_url":"https://api.github.com/repos/dilyevsky/skycfg/issues/events{/number}","events_url":"https://api.github.com/repos/dilyevsky/skycfg/events","assignees_url":"https://api.github.com/repos/dilyevsky/skycfg/assignees{/user}","branches_url":"https://api.github.com/repos/dilyevsky/skycfg/branches{/branch}","tags_url":"https://api.github.com/repos/dilyevsky/skycfg/tags","blobs_url":"https://api.github.com/repos/dilyevsky/skycfg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dilyevsky/skycfg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dilyevsky/skycfg/git/refs{/sha}","trees_url":"https://api.github.com/repos/dilyevsky/skycfg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dilyevsky/skycfg/statuses/{sha}","languages_url":"https://api.github.com/repos/dilyevsky/skycfg/languages","stargazers_url":"https://api.github.com/repos/dilyevsky/skycfg/stargazers","contributors_url":"https://api.github.com/repos/dilyevsky/skycfg/contributors","subscribers_url":"https://api.github.com/repos/dilyevsky/skycfg/subscribers","subscription_url":"https://api.github.com/repos/dilyevsky/skycfg/subscription","commits_url":"https://api.github.com/repos/dilyevsky/skycfg/commits{/sha}","git_commits_url":"https://api.github.com/repos/dilyevsky/skycfg/git/commits{/sha}","comments_url":"https://api.github.com/repos/dilyevsky/skycfg/comments{/number}","issue_comment_url":"https://api.github.com/repos/dilyevsky/skycfg/issues/comments{/number}","contents_url":"https://api.github.com/repos/dilyevsky/skycfg/contents/{+path}","compare_url":"https://api.github.com/repos/dilyevsky/skycfg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dilyevsky/skycfg/merges","archive_url":"https://api.github.com/repos/dilyevsky/skycfg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dilyevsky/skycfg/downloads","issues_url":"https://api.github.com/repos/dilyevsky/skycfg/issues{/number}","pulls_url":"https://api.github.com/repos/dilyevsky/skycfg/pulls{/number}","milestones_url":"https://api.github.com/repos/dilyevsky/skycfg/milestones{/number}","notifications_url":"https://api.github.com/repos/dilyevsky/skycfg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dilyevsky/skycfg/labels{/name}","releases_url":"https://api.github.com/repos/dilyevsky/skycfg/releases{/id}","deployments_url":"https://api.github.com/repos/dilyevsky/skycfg/deployments","created_at":"2018-11-30T21:19:08Z","updated_at":"2018-11-30T21:19:10Z","pushed_at":"2018-12-01T00:56:22Z","git_url":"git://github.com/dilyevsky/skycfg.git","ssh_url":"git@github.com:dilyevsky/skycfg.git","clone_url":"https://github.com/dilyevsky/skycfg.git","svn_url":"https://github.com/dilyevsky/skycfg","homepage":"","size":142,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"stripe:master","ref":"master","sha":"4b4966454e89a00e5bec6888d21241beb15c48e0","user":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"repo":{"id":145074684,"node_id":"MDEwOlJlcG9zaXRvcnkxNDUwNzQ2ODQ=","name":"skycfg","full_name":"stripe/skycfg","private":false,"owner":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stripe/skycfg","description":"Skycfg is an extension library for the Starlark language that adds support for constructing Protocol Buffer messages.","fork":false,"url":"https://api.github.com/repos/stripe/skycfg","forks_url":"https://api.github.com/repos/stripe/skycfg/forks","keys_url":"https://api.github.com/repos/stripe/skycfg/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stripe/skycfg/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stripe/skycfg/teams","hooks_url":"https://api.github.com/repos/stripe/skycfg/hooks","issue_events_url":"https://api.github.com/repos/stripe/skycfg/issues/events{/number}","events_url":"https://api.github.com/repos/stripe/skycfg/events","assignees_url":"https://api.github.com/repos/stripe/skycfg/assignees{/user}","branches_url":"https://api.github.com/repos/stripe/skycfg/branches{/branch}","tags_url":"https://api.github.com/repos/stripe/skycfg/tags","blobs_url":"https://api.github.com/repos/stripe/skycfg/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stripe/skycfg/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stripe/skycfg/git/refs{/sha}","trees_url":"https://api.github.com/repos/stripe/skycfg/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stripe/skycfg/statuses/{sha}","languages_url":"https://api.github.com/repos/stripe/skycfg/languages","stargazers_url":"https://api.github.com/repos/stripe/skycfg/stargazers","contributors_url":"https://api.github.com/repos/stripe/skycfg/contributors","subscribers_url":"https://api.github.com/repos/stripe/skycfg/subscribers","subscription_url":"https://api.github.com/repos/stripe/skycfg/subscription","commits_url":"https://api.github.com/repos/stripe/skycfg/commits{/sha}","git_commits_url":"https://api.github.com/repos/stripe/skycfg/git/commits{/sha}","comments_url":"https://api.github.com/repos/stripe/skycfg/comments{/number}","issue_comment_url":"https://api.github.com/repos/stripe/skycfg/issues/comments{/number}","contents_url":"https://api.github.com/repos/stripe/skycfg/contents/{+path}","compare_url":"https://api.github.com/repos/stripe/skycfg/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stripe/skycfg/merges","archive_url":"https://api.github.com/repos/stripe/skycfg/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stripe/skycfg/downloads","issues_url":"https://api.github.com/repos/stripe/skycfg/issues{/number}","pulls_url":"https://api.github.com/repos/stripe/skycfg/pulls{/number}","milestones_url":"https://api.github.com/repos/stripe/skycfg/milestones{/number}","notifications_url":"https://api.github.com/repos/stripe/skycfg/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stripe/skycfg/labels{/name}","releases_url":"https://api.github.com/repos/stripe/skycfg/releases{/id}","deployments_url":"https://api.github.com/repos/stripe/skycfg/deployments","created_at":"2018-08-17T05:14:38Z","updated_at":"2018-12-04T20:43:14Z","pushed_at":"2018-12-01T06:30:05Z","git_url":"git://github.com/stripe/skycfg.git","ssh_url":"git@github.com:stripe/skycfg.git","clone_url":"https://github.com/stripe/skycfg.git","svn_url":"https://github.com/stripe/skycfg","homepage":"","size":133,"stargazers_count":194,"watchers_count":194,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":5,"open_issues":6,"watchers":194,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/19"},"html":{"href":"https://github.com/stripe/skycfg/pull/19"},"issue":{"href":"https://api.github.com/repos/stripe/skycfg/issues/19"},"comments":{"href":"https://api.github.com/repos/stripe/skycfg/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stripe/skycfg/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/stripe/skycfg/statuses/a5dacb476de74623753fa44197909f65164d60aa"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jmillikin-stripe"}}