├── .gitignore ├── comments ├── vendor │ └── github.com │ │ ├── lib │ │ └── pq │ │ │ ├── go.mod │ │ │ ├── .gitignore │ │ │ ├── oid │ │ │ ├── doc.go │ │ │ └── gen.go │ │ │ ├── ssl_windows.go │ │ │ ├── user_posix.go │ │ │ ├── ssl_permissions.go │ │ │ ├── uuid.go │ │ │ ├── TESTS.md │ │ │ ├── user_windows.go │ │ │ ├── LICENSE.md │ │ │ ├── .travis.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── url.go │ │ │ ├── buf.go │ │ │ ├── .travis.sh │ │ │ ├── rows.go │ │ │ └── README.md │ │ ├── pkg │ │ └── errors │ │ │ ├── .travis.yml │ │ │ ├── .gitignore │ │ │ ├── appveyor.yml │ │ │ ├── Makefile │ │ │ ├── LICENSE │ │ │ ├── go113.go │ │ │ └── README.md │ │ ├── openfaas │ │ ├── openfaas-cloud │ │ │ ├── sdk │ │ │ │ ├── Gopkg.toml │ │ │ │ ├── build.go │ │ │ │ ├── constants.go │ │ │ │ ├── pipeline.go │ │ │ │ ├── interfaces.go │ │ │ │ ├── function.go │ │ │ │ ├── secrets.go │ │ │ │ ├── audit.go │ │ │ │ ├── service.go │ │ │ │ ├── Gopkg.lock │ │ │ │ ├── hmac.go │ │ │ │ ├── auth.go │ │ │ │ ├── event.go │ │ │ │ ├── events_scm.go │ │ │ │ └── url_builders.go │ │ │ ├── LICENSE │ │ │ └── dashboard │ │ │ │ └── LICENSE │ │ └── faas-provider │ │ │ ├── auth │ │ │ ├── basic_auth.go │ │ │ └── credentials.go │ │ │ └── LICENSE │ │ └── alexellis │ │ └── hmac │ │ ├── README.md │ │ └── pkg.go ├── Gopkg.toml ├── Gopkg.lock └── handler.go ├── import-comment ├── vendor │ ├── github.com │ │ ├── lib │ │ │ └── pq │ │ │ │ ├── go.mod │ │ │ │ ├── .gitignore │ │ │ │ ├── oid │ │ │ │ ├── doc.go │ │ │ │ └── gen.go │ │ │ │ ├── ssl_windows.go │ │ │ │ ├── user_posix.go │ │ │ │ ├── ssl_permissions.go │ │ │ │ ├── uuid.go │ │ │ │ ├── TESTS.md │ │ │ │ ├── user_windows.go │ │ │ │ ├── LICENSE.md │ │ │ │ ├── .travis.yml │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── url.go │ │ │ │ ├── buf.go │ │ │ │ ├── .travis.sh │ │ │ │ ├── rows.go │ │ │ │ └── README.md │ │ ├── brankas │ │ │ └── emoji │ │ │ │ ├── go.mod │ │ │ │ ├── .travis.yml │ │ │ │ ├── emoticon_data.go │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ └── gen.go │ │ ├── pkg │ │ │ └── errors │ │ │ │ ├── .travis.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── appveyor.yml │ │ │ │ ├── Makefile │ │ │ │ ├── LICENSE │ │ │ │ ├── go113.go │ │ │ │ └── README.md │ │ ├── openfaas │ │ │ ├── openfaas-cloud │ │ │ │ ├── sdk │ │ │ │ │ ├── Gopkg.toml │ │ │ │ │ ├── constants.go │ │ │ │ │ ├── build.go │ │ │ │ │ ├── pipeline.go │ │ │ │ │ ├── interfaces.go │ │ │ │ │ ├── function.go │ │ │ │ │ ├── secrets.go │ │ │ │ │ ├── audit.go │ │ │ │ │ ├── service.go │ │ │ │ │ ├── Gopkg.lock │ │ │ │ │ ├── hmac.go │ │ │ │ │ ├── auth.go │ │ │ │ │ ├── event.go │ │ │ │ │ ├── events_scm.go │ │ │ │ │ └── url_builders.go │ │ │ │ ├── LICENSE │ │ │ │ └── dashboard │ │ │ │ │ └── LICENSE │ │ │ └── faas-provider │ │ │ │ ├── auth │ │ │ │ ├── basic_auth.go │ │ │ │ └── credentials.go │ │ │ │ └── LICENSE │ │ ├── alexellis │ │ │ └── hmac │ │ │ │ ├── README.md │ │ │ │ └── pkg.go │ │ └── google │ │ │ ├── go-github │ │ │ ├── github │ │ │ │ ├── git.go │ │ │ │ ├── actions.go │ │ │ │ ├── without_appengine.go │ │ │ │ ├── with_appengine.go │ │ │ │ ├── repos_merging.go │ │ │ │ ├── timestamp.go │ │ │ │ ├── interactions.go │ │ │ │ ├── admin_orgs.go │ │ │ │ ├── gitignore.go │ │ │ │ ├── orgs_projects.go │ │ │ │ ├── apps_manifest.go │ │ │ │ ├── users_projects.go │ │ │ │ ├── strings.go │ │ │ │ ├── repos_community_health.go │ │ │ │ ├── users_emails.go │ │ │ │ ├── repos_projects.go │ │ │ │ ├── git_blobs.go │ │ │ │ ├── users_administration.go │ │ │ │ ├── git_tags.go │ │ │ │ ├── pulls_reviewers.go │ │ │ │ ├── actions_workflows.go │ │ │ │ ├── users_blocking.go │ │ │ │ ├── activity.go │ │ │ │ └── issues_assignees.go │ │ │ └── LICENSE │ │ │ └── go-querystring │ │ │ └── LICENSE │ └── golang.org │ │ └── x │ │ └── crypto │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── PATENTS │ │ ├── openpgp │ │ ├── canonical_text.go │ │ ├── packet │ │ │ ├── one_pass_signature.go │ │ │ ├── literal.go │ │ │ ├── reader.go │ │ │ ├── userattribute.go │ │ │ └── config.go │ │ └── errors │ │ │ └── errors.go │ │ └── LICENSE ├── Gopkg.toml └── handler_test.go ├── docs ├── tick.png ├── comments.png ├── example.png └── webhook.png ├── .DEREK.yml ├── crossplane ├── gcp.yaml ├── credentials.sh ├── postgres.yaml ├── cloudsql.yaml └── gcp-provider.yaml ├── LICENSE ├── stack.yml ├── schema.sql ├── view ├── handler.go └── public │ └── index.html ├── README.md └── crossplane.md /.gitignore: -------------------------------------------------------------------------------- 1 | template 2 | build 3 | /secrets.txt 4 | service-account.json -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lib/pq 2 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/lib/pq 2 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/.gitignore: -------------------------------------------------------------------------------- 1 | .db 2 | *.test 3 | *~ 4 | *.swp 5 | -------------------------------------------------------------------------------- /docs/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexellis/comment-vibes/HEAD/docs/tick.png -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/.gitignore: -------------------------------------------------------------------------------- 1 | .db 2 | *.test 3 | *~ 4 | *.swp 5 | -------------------------------------------------------------------------------- /.DEREK.yml: -------------------------------------------------------------------------------- 1 | redirect: https://raw.githubusercontent.com/openfaas/faas/master/.DEREK.yml 2 | -------------------------------------------------------------------------------- /docs/comments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexellis/comment-vibes/HEAD/docs/comments.png -------------------------------------------------------------------------------- /docs/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexellis/comment-vibes/HEAD/docs/example.png -------------------------------------------------------------------------------- /docs/webhook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexellis/comment-vibes/HEAD/docs/webhook.png -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/brankas/emoji 2 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.11.x 5 | - 1.12.x 6 | - 1.13.x 7 | - tip 8 | 9 | script: 10 | - make check 11 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/errors 3 | go: 4 | - 1.11.x 5 | - 1.12.x 6 | - 1.13.x 7 | - tip 8 | 9 | script: 10 | - make check 11 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /crossplane/gcp.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: gcp 5 | --- 6 | apiVersion: stacks.crossplane.io/v1alpha1 7 | kind: ClusterStackInstall 8 | metadata: 9 | name: provider-gcp 10 | namespace: gcp 11 | spec: 12 | package: "crossplane/provider-gcp:master" -------------------------------------------------------------------------------- /crossplane/credentials.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export PROJECT_ID=$1 4 | export BASE64ENCODED_GCP_PROVIDER_CREDS=$(base64 service-account.json | tr -d "\n") 5 | sed "s/BASE64ENCODED_GCP_PROVIDER_CREDS/$BASE64ENCODED_GCP_PROVIDER_CREDS/g;s/PROJECT_ID/$PROJECT_ID/g" gcp-provider.yaml | kubectl apply -f - 6 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.10.x 4 | - 1.11.x 5 | - tip 6 | before_install: 7 | - go get github.com/mattn/goveralls 8 | script: 9 | - go test -v -coverprofile=coverage.out 10 | - goveralls -service=travis-ci -coverprofile=coverage.out 11 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | go-tests = true 3 | unused-packages = true 4 | 5 | [[constraint]] 6 | name = "github.com/alexellis/hmac" 7 | version = "1.2.0" 8 | 9 | [[constraint]] 10 | name = "github.com/openfaas/faas-provider" 11 | version = "0.7.1" 12 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | go-tests = true 3 | unused-packages = true 4 | 5 | [[constraint]] 6 | name = "github.com/alexellis/hmac" 7 | version = "1.2.0" 8 | 9 | [[constraint]] 10 | name = "github.com/openfaas/faas-provider" 11 | version = "0.7.1" 12 | -------------------------------------------------------------------------------- /crossplane/postgres.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: database.crossplane.io/v1alpha1 2 | kind: PostgreSQLInstance 3 | metadata: 4 | name: comment-vibes-db 5 | namespace: openfaas-fn 6 | spec: 7 | classSelector: 8 | matchLabels: 9 | app: comment-vibes 10 | writeConnectionSecretToRef: 11 | name: pgconn 12 | engineVersion: "11" 13 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/build.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // BuildResult represents a successful Docker build and 4 | // push operation to a remote registry 5 | type BuildResult struct { 6 | Log []string `json:"log"` 7 | ImageName string `json:"imageName"` 8 | Status string `json:"status"` 9 | } 10 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/constants.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | const ( 4 | //CloudSignatureHeader header name to pass signed payload secret 5 | CloudSignatureHeader = "X-Cloud-Signature" 6 | // FunctionLabelPrefix is a prefix for openfaas labels inside functions 7 | FunctionLabelPrefix = "com.openfaas.cloud." 8 | ) 9 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/pipeline.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // PipelineLog stores a log output from a given stage of 4 | // a pipeline such as the container builder 5 | type PipelineLog struct { 6 | RepoPath string 7 | CommitSHA string 8 | Function string 9 | Source string 10 | Data string 11 | } 12 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/constants.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | const ( 4 | //CloudSignatureHeader header name to pass signed payload secret 5 | CloudSignatureHeader = "X-Cloud-Signature" 6 | // FunctionLabelPrefix is a prefix for openfaas labels inside functions 7 | FunctionLabelPrefix = "com.openfaas.cloud." 8 | ) 9 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/ssl_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pq 4 | 5 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 6 | // The key file should have very little access. 7 | // 8 | // libpq does not check key file permissions on Windows. 9 | func sslKeyPermissions(string) error { return nil } 10 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/build.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // BuildResult represents a successful Docker build and 4 | // push operation to a remote registry 5 | type BuildResult struct { 6 | Log []string `json:"log"` 7 | ImageName string `json:"imageName"` 8 | Status string `json:"status"` 9 | } 10 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/pipeline.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // PipelineLog stores a log output from a given stage of 4 | // a pipeline such as the container builder 5 | type PipelineLog struct { 6 | RepoPath string 7 | CommitSHA string 8 | Function string 9 | Source string 10 | Data string 11 | } 12 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/ssl_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pq 4 | 5 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 6 | // The key file should have very little access. 7 | // 8 | // libpq does not check key file permissions on Windows. 9 | func sslKeyPermissions(string) error { return nil } 10 | -------------------------------------------------------------------------------- /comments/vendor/github.com/alexellis/hmac/README.md: -------------------------------------------------------------------------------- 1 | # hmac 2 | 3 | Validate HMAC in Golang. 4 | 5 | ## Example: 6 | 7 | ``` 8 | import "github.com/alexellis/hmac" 9 | 10 | ... 11 | var input []byte 12 | var signature string 13 | var secret string 14 | 15 | valid := hmac.Validate(input, signature, secret) 16 | 17 | fmt.Printf("Valid HMAC? %t\n") 18 | ``` 19 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/alexellis/hmac/README.md: -------------------------------------------------------------------------------- 1 | # hmac 2 | 3 | Validate HMAC in Golang. 4 | 5 | ## Example: 6 | 7 | ``` 8 | import "github.com/alexellis/hmac" 9 | 10 | ... 11 | var input []byte 12 | var signature string 13 | var secret string 14 | 15 | valid := hmac.Validate(input, signature, secret) 16 | 17 | fmt.Printf("Valid HMAC? %t\n") 18 | ``` 19 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/interfaces.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | type Audit interface { 4 | Post(AuditEvent) error 5 | } 6 | 7 | type NilLogger struct { 8 | } 9 | 10 | func (l NilLogger) Post(auditEvent AuditEvent) error { 11 | return nil 12 | } 13 | 14 | type AuditLogger struct { 15 | } 16 | 17 | func (l AuditLogger) Post(auditEvent AuditEvent) error { 18 | PostAudit(auditEvent) 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/interfaces.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | type Audit interface { 4 | Post(AuditEvent) error 5 | } 6 | 7 | type NilLogger struct { 8 | } 9 | 10 | func (l NilLogger) Post(auditEvent AuditEvent) error { 11 | return nil 12 | } 13 | 14 | type AuditLogger struct { 15 | } 16 | 17 | func (l AuditLogger) Post(auditEvent AuditEvent) error { 18 | PostAudit(auditEvent) 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/function.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | type Function struct { 4 | Name string `json:"name"` 5 | Image string `json:"image"` 6 | InvocationCount float64 `json:"invocationCount"` 7 | Replicas uint64 `json:"replicas"` 8 | Labels map[string]string `json:"labels"` 9 | Annotations map[string]string `json:"annotations"` 10 | } 11 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/function.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | type Function struct { 4 | Name string `json:"name"` 5 | Image string `json:"image"` 6 | InvocationCount float64 `json:"invocationCount"` 7 | Replicas uint64 `json:"replicas"` 8 | Labels map[string]string `json:"labels"` 9 | Annotations map[string]string `json:"annotations"` 10 | } 11 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/git.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | // GitService handles communication with the git data related 9 | // methods of the GitHub API. 10 | // 11 | // GitHub API docs: https://developer.github.com/v3/git/ 12 | type GitService service 13 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/actions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | // ActionsService handles communication with the actions related 9 | // methods of the GitHub API. 10 | // 11 | // GitHub API docs: https://developer.github.com/v3/actions/ 12 | type ActionsService service 13 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris rumprun 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/ssl_permissions.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pq 4 | 5 | import "os" 6 | 7 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 8 | // The key file should have very little access. 9 | // 10 | // libpq does not check key file permissions on Windows. 11 | func sslKeyPermissions(sslkey string) error { 12 | info, err := os.Stat(sslkey) 13 | if err != nil { 14 | return err 15 | } 16 | if info.Mode().Perm()&0077 != 0 { 17 | return ErrSSLKeyHasWorldPermissions 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris rumprun 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/ssl_permissions.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pq 4 | 5 | import "os" 6 | 7 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 8 | // The key file should have very little access. 9 | // 10 | // libpq does not check key file permissions on Windows. 11 | func sslKeyPermissions(sslkey string) error { 12 | info, err := os.Stat(sslkey) 13 | if err != nil { 14 | return err 15 | } 16 | if info.Mode().Perm()&0077 != 0 { 17 | return ErrSSLKeyHasWorldPermissions 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/without_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | // This file provides glue for making github work without App Engine. 9 | 10 | package github 11 | 12 | import ( 13 | "context" 14 | "net/http" 15 | ) 16 | 17 | func withContext(ctx context.Context, req *http.Request) *http.Request { 18 | return req.WithContext(ctx) 19 | } 20 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/with_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build appengine 7 | 8 | // This file provides glue for making github work on App Engine. 9 | 10 | package github 11 | 12 | import ( 13 | "context" 14 | "net/http" 15 | ) 16 | 17 | func withContext(ctx context.Context, req *http.Request) *http.Request { 18 | // No-op because App Engine adds context to a request differently. 19 | return req 20 | } 21 | -------------------------------------------------------------------------------- /crossplane/cloudsql.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: database.gcp.crossplane.io/v1beta1 3 | kind: CloudSQLInstanceClass 4 | metadata: 5 | name: standard 6 | labels: 7 | app: comment-vibes 8 | specTemplate: 9 | writeConnectionSecretsToNamespace: crossplane-system 10 | forProvider: 11 | databaseVersion: POSTGRES_11 12 | region: us-west2 13 | settings: 14 | tier: db-custom-1-3840 15 | dataDiskType: PD_SSD 16 | dataDiskSizeGb: 10 17 | ipConfiguration: 18 | ipv4Enabled: true 19 | authorizedNetworks: 20 | - value: "0.0.0.0/0" 21 | providerRef: 22 | name: gcp-provider 23 | reclaimPolicy: Delete 24 | -------------------------------------------------------------------------------- /crossplane/gcp-provider.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # GCP Admin service account secret - used by GCP Provider 3 | apiVersion: v1 4 | kind: Secret 5 | metadata: 6 | namespace: crossplane-system 7 | name: example-provider-gcp 8 | type: Opaque 9 | data: 10 | credentials.json: BASE64ENCODED_GCP_PROVIDER_CREDS 11 | --- 12 | # GCP Provider with service account secret reference - used to provision cache resources 13 | apiVersion: gcp.crossplane.io/v1alpha3 14 | kind: Provider 15 | metadata: 16 | name: gcp-provider 17 | spec: 18 | credentialsSecretRef: 19 | namespace: crossplane-system 20 | name: example-provider-gcp 21 | key: credentials.json 22 | projectID: PROJECT_ID -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/uuid.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | ) 7 | 8 | // decodeUUIDBinary interprets the binary format of a uuid, returning it in text format. 9 | func decodeUUIDBinary(src []byte) ([]byte, error) { 10 | if len(src) != 16 { 11 | return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src)) 12 | } 13 | 14 | dst := make([]byte, 36) 15 | dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-' 16 | hex.Encode(dst[0:], src[0:4]) 17 | hex.Encode(dst[9:], src[4:6]) 18 | hex.Encode(dst[14:], src[6:8]) 19 | hex.Encode(dst[19:], src[8:10]) 20 | hex.Encode(dst[24:], src[10:16]) 21 | 22 | return dst, nil 23 | } 24 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/uuid.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | ) 7 | 8 | // decodeUUIDBinary interprets the binary format of a uuid, returning it in text format. 9 | func decodeUUIDBinary(src []byte) ([]byte, error) { 10 | if len(src) != 16 { 11 | return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src)) 12 | } 13 | 14 | dst := make([]byte, 36) 15 | dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-' 16 | hex.Encode(dst[0:], src[0:4]) 17 | hex.Encode(dst[9:], src[4:6]) 18 | hex.Encode(dst[14:], src[6:8]) 19 | hex.Encode(dst[19:], src[8:10]) 20 | hex.Encode(dst[24:], src[10:16]) 21 | 22 | return dst, nil 23 | } 24 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/secrets.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "strings" 9 | ) 10 | 11 | // ReadSecret reads a secret from /var/openfaas/secrets or from 12 | // env-var 'secret_mount_path' if set. 13 | func ReadSecret(key string) (string, error) { 14 | basePath := "/var/openfaas/secrets/" 15 | if len(os.Getenv("secret_mount_path")) > 0 { 16 | basePath = os.Getenv("secret_mount_path") 17 | } 18 | 19 | readPath := path.Join(basePath, key) 20 | secretBytes, readErr := ioutil.ReadFile(readPath) 21 | if readErr != nil { 22 | return "", fmt.Errorf("unable to read secret: %s, error: %s", readPath, readErr) 23 | } 24 | val := strings.TrimSpace(string(secretBytes)) 25 | return val, nil 26 | } 27 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/secrets.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "strings" 9 | ) 10 | 11 | // ReadSecret reads a secret from /var/openfaas/secrets or from 12 | // env-var 'secret_mount_path' if set. 13 | func ReadSecret(key string) (string, error) { 14 | basePath := "/var/openfaas/secrets/" 15 | if len(os.Getenv("secret_mount_path")) > 0 { 16 | basePath = os.Getenv("secret_mount_path") 17 | } 18 | 19 | readPath := path.Join(basePath, key) 20 | secretBytes, readErr := ioutil.ReadFile(readPath) 21 | if readErr != nil { 22 | return "", fmt.Errorf("unable to read secret: %s, error: %s", readPath, readErr) 23 | } 24 | val := strings.TrimSpace(string(secretBytes)) 25 | return val, nil 26 | } 27 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: build-{build}.{branch} 2 | 3 | clone_folder: C:\gopath\src\github.com\pkg\errors 4 | shallow_clone: true # for startup speed 5 | 6 | environment: 7 | GOPATH: C:\gopath 8 | 9 | platform: 10 | - x64 11 | 12 | # http://www.appveyor.com/docs/installed-software 13 | install: 14 | # some helpful output for debugging builds 15 | - go version 16 | - go env 17 | # pre-installed MinGW at C:\MinGW is 32bit only 18 | # but MSYS2 at C:\msys64 has mingw64 19 | - set PATH=C:\msys64\mingw64\bin;%PATH% 20 | - gcc --version 21 | - g++ --version 22 | 23 | build_script: 24 | - go install -v ./... 25 | 26 | test_script: 27 | - set PATH=C:\gopath\bin;%PATH% 28 | - go test -v ./... 29 | 30 | #artifacts: 31 | # - path: '%GOPATH%\bin\*.exe' 32 | deploy: off 33 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/TESTS.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | ## Running Tests 4 | 5 | `go test` is used for testing. A running PostgreSQL 6 | server is required, with the ability to log in. The 7 | database to connect to test with is "pqgotest," on 8 | "localhost" but these can be overridden using [environment 9 | variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html). 10 | 11 | Example: 12 | 13 | PGHOST=/run/postgresql go test 14 | 15 | ## Benchmarks 16 | 17 | A benchmark suite can be run as part of the tests: 18 | 19 | go test -bench . 20 | 21 | ## Example setup (Docker) 22 | 23 | Run a postgres container: 24 | 25 | ``` 26 | docker run --expose 5432:5432 postgres 27 | ``` 28 | 29 | Run tests: 30 | 31 | ``` 32 | PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test 33 | ``` 34 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/TESTS.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | ## Running Tests 4 | 5 | `go test` is used for testing. A running PostgreSQL 6 | server is required, with the ability to log in. The 7 | database to connect to test with is "pqgotest," on 8 | "localhost" but these can be overridden using [environment 9 | variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html). 10 | 11 | Example: 12 | 13 | PGHOST=/run/postgresql go test 14 | 15 | ## Benchmarks 16 | 17 | A benchmark suite can be run as part of the tests: 18 | 19 | go test -bench . 20 | 21 | ## Example setup (Docker) 22 | 23 | Run a postgres container: 24 | 25 | ``` 26 | docker run --expose 5432:5432 postgres 27 | ``` 28 | 29 | Run tests: 30 | 31 | ``` 32 | PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test 33 | ``` 34 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/audit.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "log" 7 | "net/http" 8 | "os" 9 | ) 10 | 11 | func PostAudit(auditEvent AuditEvent) { 12 | c := http.Client{} 13 | bytesOut, _ := json.Marshal(&auditEvent) 14 | reader := bytes.NewBuffer(bytesOut) 15 | auditURL := os.Getenv("audit_url") 16 | 17 | if len(auditURL) == 0 { 18 | log.Println("PostAudit invalid auditURL, empty string") 19 | return 20 | } 21 | 22 | req, _ := http.NewRequest(http.MethodPost, auditURL, reader) 23 | 24 | res, err := c.Do(req) 25 | if err != nil { 26 | log.Println("PostAudit", err) 27 | return 28 | } 29 | if res.Body != nil { 30 | defer res.Body.Close() 31 | } 32 | } 33 | 34 | type AuditEvent struct { 35 | Source string 36 | Message string 37 | Owner string 38 | Repo string 39 | } 40 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/audit.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "log" 7 | "net/http" 8 | "os" 9 | ) 10 | 11 | func PostAudit(auditEvent AuditEvent) { 12 | c := http.Client{} 13 | bytesOut, _ := json.Marshal(&auditEvent) 14 | reader := bytes.NewBuffer(bytesOut) 15 | auditURL := os.Getenv("audit_url") 16 | 17 | if len(auditURL) == 0 { 18 | log.Println("PostAudit invalid auditURL, empty string") 19 | return 20 | } 21 | 22 | req, _ := http.NewRequest(http.MethodPost, auditURL, reader) 23 | 24 | res, err := c.Do(req) 25 | if err != nil { 26 | log.Println("PostAudit", err) 27 | return 28 | } 29 | if res.Body != nil { 30 | defer res.Body.Close() 31 | } 32 | } 33 | 34 | type AuditEvent struct { 35 | Source string 36 | Message string 37 | Owner string 38 | Repo string 39 | } 40 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/service.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func FormatServiceName(owner, functionName string) string { 9 | return fmt.Sprintf("%s-%s", strings.ToLower(owner), functionName) 10 | } 11 | 12 | func CreateServiceURL(URL, suffix string) string { 13 | if strings.Contains(URL, suffix) { 14 | return URL 15 | } 16 | columns := strings.Count(URL, ":") 17 | //columns in URL with port are 2 i.e. http://url:port 18 | if columns == 2 { 19 | baseURL := URL[:strings.LastIndex(URL, ":")] 20 | port := URL[strings.LastIndex(URL, ":"):] 21 | return fmt.Sprintf("%s.%s%s", baseURL, suffix, port) 22 | } 23 | return fmt.Sprintf("%s.%s", URL, suffix) 24 | } 25 | 26 | // FormatShortSHA returns a 7-digit SHA 27 | func FormatShortSHA(sha string) string { 28 | if len(sha) <= 7 { 29 | return sha 30 | } 31 | return sha[:7] 32 | } 33 | -------------------------------------------------------------------------------- /import-comment/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [[constraint]] 29 | name = "github.com/openfaas-incubator/go-function-sdk" 30 | version = "1.0.0" 31 | 32 | [prune] 33 | go-tests = true 34 | unused-packages = true 35 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/service.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func FormatServiceName(owner, functionName string) string { 9 | return fmt.Sprintf("%s-%s", strings.ToLower(owner), functionName) 10 | } 11 | 12 | func CreateServiceURL(URL, suffix string) string { 13 | if strings.Contains(URL, suffix) { 14 | return URL 15 | } 16 | columns := strings.Count(URL, ":") 17 | //columns in URL with port are 2 i.e. http://url:port 18 | if columns == 2 { 19 | baseURL := URL[:strings.LastIndex(URL, ":")] 20 | port := URL[strings.LastIndex(URL, ":"):] 21 | return fmt.Sprintf("%s.%s%s", baseURL, suffix, port) 22 | } 23 | return fmt.Sprintf("%s.%s", URL, suffix) 24 | } 25 | 26 | // FormatShortSHA returns a 7-digit SHA 27 | func FormatShortSHA(sha string) string { 28 | if len(sha) <= 7 { 29 | return sha 30 | } 31 | return sha[:7] 32 | } 33 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/faas-provider/auth/basic_auth.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) OpenFaaS Author(s). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package auth 5 | 6 | import ( 7 | "net/http" 8 | ) 9 | 10 | // DecorateWithBasicAuth enforces basic auth as a middleware with given credentials 11 | func DecorateWithBasicAuth(next http.HandlerFunc, credentials *BasicAuthCredentials) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | 14 | user, password, ok := r.BasicAuth() 15 | w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`) 16 | 17 | if !ok || !(credentials.Password == password && user == credentials.User) { 18 | 19 | w.WriteHeader(http.StatusUnauthorized) 20 | w.Write([]byte("invalid credentials")) 21 | return 22 | } 23 | 24 | next.ServeHTTP(w, r) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/faas-provider/auth/basic_auth.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) OpenFaaS Author(s). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package auth 5 | 6 | import ( 7 | "net/http" 8 | ) 9 | 10 | // DecorateWithBasicAuth enforces basic auth as a middleware with given credentials 11 | func DecorateWithBasicAuth(next http.HandlerFunc, credentials *BasicAuthCredentials) http.HandlerFunc { 12 | return func(w http.ResponseWriter, r *http.Request) { 13 | 14 | user, password, ok := r.BasicAuth() 15 | w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`) 16 | 17 | if !ok || !(credentials.Password == password && user == credentials.User) { 18 | 19 | w.WriteHeader(http.StatusUnauthorized) 20 | w.Write([]byte("invalid credentials")) 21 | return 22 | } 23 | 24 | next.ServeHTTP(w, r) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:871b7cfa5fe18bfdbd4bf117c166c3cff8d3b61c8afe4e998b5b8ac0c160ca24" 6 | name = "github.com/alexellis/hmac" 7 | packages = ["."] 8 | pruneopts = "UT" 9 | revision = "d5d71edd7bc74eb6ae4b99eccc6bda738435f43f" 10 | version = "1.2" 11 | 12 | [[projects]] 13 | digest = "1:deb76da5396c9f641ddea9ca79e31a14bdb09c787cdfda90488768b7539b1fd6" 14 | name = "github.com/openfaas/faas-provider" 15 | packages = ["auth"] 16 | pruneopts = "UT" 17 | revision = "845bf7aa58cb08352c5b2501807837e464ab071d" 18 | version = "0.7.1" 19 | 20 | [solve-meta] 21 | analyzer-name = "dep" 22 | analyzer-version = 1 23 | input-imports = [ 24 | "github.com/alexellis/hmac", 25 | "github.com/openfaas/faas-provider/auth", 26 | ] 27 | solver-name = "gps-cdcl" 28 | solver-version = 1 29 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:871b7cfa5fe18bfdbd4bf117c166c3cff8d3b61c8afe4e998b5b8ac0c160ca24" 6 | name = "github.com/alexellis/hmac" 7 | packages = ["."] 8 | pruneopts = "UT" 9 | revision = "d5d71edd7bc74eb6ae4b99eccc6bda738435f43f" 10 | version = "1.2" 11 | 12 | [[projects]] 13 | digest = "1:deb76da5396c9f641ddea9ca79e31a14bdb09c787cdfda90488768b7539b1fd6" 14 | name = "github.com/openfaas/faas-provider" 15 | packages = ["auth"] 16 | pruneopts = "UT" 17 | revision = "845bf7aa58cb08352c5b2501807837e464ab071d" 18 | version = "0.7.1" 19 | 20 | [solve-meta] 21 | analyzer-name = "dep" 22 | analyzer-version = 1 23 | input-imports = [ 24 | "github.com/alexellis/hmac", 25 | "github.com/openfaas/faas-provider/auth", 26 | ] 27 | solver-name = "gps-cdcl" 28 | solver-version = 1 29 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /comments/Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | 28 | [[constraint]] 29 | name = "github.com/lib/pq" 30 | version = "1.3.0" 31 | 32 | [[constraint]] 33 | name = "github.com/openfaas/openfaas-cloud" 34 | version = "0.13.8" 35 | 36 | [[constraint]] 37 | name = "github.com/pkg/errors" 38 | version = "0.9.1" 39 | 40 | [prune] 41 | go-tests = true 42 | unused-packages = true 43 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/Makefile: -------------------------------------------------------------------------------- 1 | PKGS := github.com/pkg/errors 2 | SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) 3 | GO := go 4 | 5 | check: test vet gofmt misspell unconvert staticcheck ineffassign unparam 6 | 7 | test: 8 | $(GO) test $(PKGS) 9 | 10 | vet: | test 11 | $(GO) vet $(PKGS) 12 | 13 | staticcheck: 14 | $(GO) get honnef.co/go/tools/cmd/staticcheck 15 | staticcheck -checks all $(PKGS) 16 | 17 | misspell: 18 | $(GO) get github.com/client9/misspell/cmd/misspell 19 | misspell \ 20 | -locale GB \ 21 | -error \ 22 | *.md *.go 23 | 24 | unconvert: 25 | $(GO) get github.com/mdempsky/unconvert 26 | unconvert -v $(PKGS) 27 | 28 | ineffassign: 29 | $(GO) get github.com/gordonklaus/ineffassign 30 | find $(SRCDIRS) -name '*.go' | xargs ineffassign 31 | 32 | pedantic: check errcheck 33 | 34 | unparam: 35 | $(GO) get mvdan.cc/unparam 36 | unparam ./... 37 | 38 | errcheck: 39 | $(GO) get github.com/kisielk/errcheck 40 | errcheck $(PKGS) 41 | 42 | gofmt: 43 | @echo Checking code is gofmted 44 | @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" 45 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/Makefile: -------------------------------------------------------------------------------- 1 | PKGS := github.com/pkg/errors 2 | SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) 3 | GO := go 4 | 5 | check: test vet gofmt misspell unconvert staticcheck ineffassign unparam 6 | 7 | test: 8 | $(GO) test $(PKGS) 9 | 10 | vet: | test 11 | $(GO) vet $(PKGS) 12 | 13 | staticcheck: 14 | $(GO) get honnef.co/go/tools/cmd/staticcheck 15 | staticcheck -checks all $(PKGS) 16 | 17 | misspell: 18 | $(GO) get github.com/client9/misspell/cmd/misspell 19 | misspell \ 20 | -locale GB \ 21 | -error \ 22 | *.md *.go 23 | 24 | unconvert: 25 | $(GO) get github.com/mdempsky/unconvert 26 | unconvert -v $(PKGS) 27 | 28 | ineffassign: 29 | $(GO) get github.com/gordonklaus/ineffassign 30 | find $(SRCDIRS) -name '*.go' | xargs ineffassign 31 | 32 | pedantic: check errcheck 33 | 34 | unparam: 35 | $(GO) get mvdan.cc/unparam 36 | unparam ./... 37 | 38 | errcheck: 39 | $(GO) get github.com/kisielk/errcheck 40 | errcheck $(PKGS) 41 | 42 | gofmt: 43 | @echo Checking code is gofmted 44 | @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /stack.yml: -------------------------------------------------------------------------------- 1 | version: 1.0 2 | provider: 3 | name: openfaas 4 | gateway: http://127.0.0.1:8080 5 | 6 | functions: 7 | view: 8 | lang: golang-middleware 9 | handler: ./view 10 | image: alexellis2/view:latest 11 | secrets: 12 | - host 13 | - password 14 | - username 15 | - webhook-secret 16 | environment: 17 | postgres_db: defaultdb 18 | postgres_sslmode: require 19 | postgres_port: 25060 20 | init_db: true 21 | 22 | import-comment: 23 | lang: golang-middleware 24 | handler: ./import-comment 25 | image: alexellis2/import-comment:latest 26 | secrets: 27 | - host 28 | - password 29 | - username 30 | - webhook-secret 31 | environment: 32 | postgres_db: defaultdb 33 | postgres_sslmode: require 34 | postgres_port: 25060 35 | 36 | comments: 37 | lang: golang-middleware 38 | handler: ./comments 39 | image: alexellis2/comments:latest 40 | secrets: 41 | - host 42 | - password 43 | - username 44 | - webhook-secret 45 | environment: 46 | postgres_db: defaultdb 47 | postgres_sslmode: require 48 | postgres_port: 25060 49 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/emoticon_data.go: -------------------------------------------------------------------------------- 1 | package emoji 2 | 3 | // emoticonMap is a map of emoji aliases to emoticon counterparts. 4 | var emoticonMap = map[string][]string{ 5 | "angry": {">:(", ">:-("}, 6 | "anguished": {"D:"}, 7 | "broken_heart": {"", ":->"}, 13 | "monkey_face": {":o)"}, 14 | "neutral_face": {":|"}, 15 | "open_mouth": {":o", ":O", ":-o", ":-O"}, 16 | "slightly_smiling_face": {":)", "(:", ":-)"}, 17 | "smile": {":D", ":-D"}, 18 | "smiley": {"=)", "=-)"}, 19 | "stuck_out_tongue": {":p", ":P", ":-p", ":-P", ":b", ":-b"}, 20 | "stuck_out_tongue_winking_eye": {";p", ";P", ";-p", ";-P", ";b", ";-b"}, 21 | "sunglasses": {"8)"}, 22 | "wink": {";)", ";-)"}, 23 | } 24 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/faas-provider/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/faas-provider/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 Kenneth Shaw 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /schema.sql: -------------------------------------------------------------------------------- 1 | drop table activity cascade; 2 | drop table users; 3 | 4 | CREATE TABLE users ( 5 | user_id integer PRIMARY KEY NOT NULL, 6 | user_login text NOT NULL, 7 | track BOOLEAN NOT NULL, 8 | created_at timestamp not null 9 | ); 10 | 11 | insert into users (user_id,user_login,track, created_at) values (653013,'alexellisuk',true,now()); 12 | insert into users (user_id,user_login,track, created_at) values (103022,'rgee0',true,now()); 13 | 14 | CREATE TABLE activity ( 15 | id INT GENERATED ALWAYS AS IDENTITY, 16 | user_id integer NOT NULL references users(user_id), 17 | activity_date timestamp NOT NULL, 18 | emoji text NOT NULL 19 | ); 20 | 21 | insert into activity (user_id, activity_date, emoji) values (653013, now(), '👍'); 22 | 23 | drop function get_emojis; 24 | 25 | CREATE or REPLACE FUNCTION get_emojis() 26 | RETURNS TABLE(emoji text, total bigint) 27 | AS 28 | $$ 29 | BEGIN 30 | RETURN QUERY select 31 | a.emoji, 32 | count(a.emoji) as total 33 | from activity a 34 | group by a.emoji 35 | order by total desc; 36 | END 37 | $$ LANGUAGE 'plpgsql' VOLATILE; 38 | 39 | 40 | select * from get_emojis(); 41 | 42 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.11.x 5 | - 1.12.x 6 | - master 7 | 8 | sudo: true 9 | 10 | env: 11 | global: 12 | - PGUSER=postgres 13 | - PQGOSSLTESTS=1 14 | - PQSSLCERTTEST_PATH=$PWD/certs 15 | - PGHOST=127.0.0.1 16 | matrix: 17 | - PGVERSION=10 18 | - PGVERSION=9.6 19 | - PGVERSION=9.5 20 | - PGVERSION=9.4 21 | 22 | before_install: 23 | - ./.travis.sh postgresql_uninstall 24 | - ./.travis.sh pgdg_repository 25 | - ./.travis.sh postgresql_install 26 | - ./.travis.sh postgresql_configure 27 | - ./.travis.sh client_configure 28 | - go get golang.org/x/tools/cmd/goimports 29 | - go get golang.org/x/lint/golint 30 | - GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck@2019.2.1 31 | 32 | before_script: 33 | - createdb pqgotest 34 | - createuser -DRS pqgossltest 35 | - createuser -DRS pqgosslcert 36 | 37 | script: 38 | - > 39 | goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }' 40 | - go vet ./... 41 | - staticcheck -go 1.11 ./... 42 | - golint ./... 43 | - PQTEST_BINARY_PARAMETERS=no go test -race -v ./... 44 | - PQTEST_BINARY_PARAMETERS=yes go test -race -v ./... 45 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.11.x 5 | - 1.12.x 6 | - master 7 | 8 | sudo: true 9 | 10 | env: 11 | global: 12 | - PGUSER=postgres 13 | - PQGOSSLTESTS=1 14 | - PQSSLCERTTEST_PATH=$PWD/certs 15 | - PGHOST=127.0.0.1 16 | matrix: 17 | - PGVERSION=10 18 | - PGVERSION=9.6 19 | - PGVERSION=9.5 20 | - PGVERSION=9.4 21 | 22 | before_install: 23 | - ./.travis.sh postgresql_uninstall 24 | - ./.travis.sh pgdg_repository 25 | - ./.travis.sh postgresql_install 26 | - ./.travis.sh postgresql_configure 27 | - ./.travis.sh client_configure 28 | - go get golang.org/x/tools/cmd/goimports 29 | - go get golang.org/x/lint/golint 30 | - GO111MODULE=on go get honnef.co/go/tools/cmd/staticcheck@2019.2.1 31 | 32 | before_script: 33 | - createdb pqgotest 34 | - createuser -DRS pqgossltest 35 | - createuser -DRS pqgosslcert 36 | 37 | script: 38 | - > 39 | goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }' 40 | - go vet ./... 41 | - staticcheck -go 1.11 ./... 42 | - golint ./... 43 | - PQTEST_BINARY_PARAMETERS=no go test -race -v ./... 44 | - PQTEST_BINARY_PARAMETERS=yes go test -race -v ./... 45 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2019 Alex Ellis 4 | Copyright (c) 2018-2019 OpenFaaS Author(s) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/dashboard/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Ellis 4 | Copyright (c) 2018 OpenFaaS Cloud Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2019 Alex Ellis 4 | Copyright (c) 2018-2019 OpenFaaS Author(s) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/dashboard/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Ellis 4 | Copyright (c) 2018 OpenFaaS Cloud Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/hmac.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/alexellis/hmac" 8 | ) 9 | 10 | // HmacEnabled uses validate_hmac env-var to verify if the 11 | // feature is disabled 12 | func HmacEnabled() bool { 13 | if val, exists := os.LookupEnv("validate_hmac"); exists { 14 | return val != "false" && val != "0" 15 | } 16 | return true 17 | } 18 | 19 | // ValidHMAC returns an error if HMAC could not be validated or if 20 | // the signature could not be loaded. 21 | func ValidHMAC(payload *[]byte, secretKey string, digest string) error { 22 | key, err := ReadSecret(secretKey) 23 | if err != nil { 24 | return fmt.Errorf("unable to load HMAC symmetric key, %s", err.Error()) 25 | } 26 | 27 | return validHMACWithSecretKey(payload, key, digest) 28 | } 29 | 30 | func validHMACWithSecretKey(payload *[]byte, secretText string, digest string) error { 31 | validated := hmac.Validate(*payload, digest, secretText) 32 | 33 | if validated != nil { 34 | return fmt.Errorf("unable to validate HMAC") 35 | } 36 | return nil 37 | } 38 | 39 | func readBool(key string) bool { 40 | if val, exists := os.LookupEnv(key); exists { 41 | return val != "false" && val != "0" 42 | } 43 | return true 44 | } 45 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/hmac.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/alexellis/hmac" 8 | ) 9 | 10 | // HmacEnabled uses validate_hmac env-var to verify if the 11 | // feature is disabled 12 | func HmacEnabled() bool { 13 | if val, exists := os.LookupEnv("validate_hmac"); exists { 14 | return val != "false" && val != "0" 15 | } 16 | return true 17 | } 18 | 19 | // ValidHMAC returns an error if HMAC could not be validated or if 20 | // the signature could not be loaded. 21 | func ValidHMAC(payload *[]byte, secretKey string, digest string) error { 22 | key, err := ReadSecret(secretKey) 23 | if err != nil { 24 | return fmt.Errorf("unable to load HMAC symmetric key, %s", err.Error()) 25 | } 26 | 27 | return validHMACWithSecretKey(payload, key, digest) 28 | } 29 | 30 | func validHMACWithSecretKey(payload *[]byte, secretText string, digest string) error { 31 | validated := hmac.Validate(*payload, digest, secretText) 32 | 33 | if validated != nil { 34 | return fmt.Errorf("unable to validate HMAC") 35 | } 36 | return nil 37 | } 38 | 39 | func readBool(key string) bool { 40 | if val, exists := os.LookupEnv(key); exists { 41 | return val != "false" && val != "0" 42 | } 43 | return true 44 | } 45 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/repos_merging.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // RepositoryMergeRequest represents a request to merge a branch in a 14 | // repository. 15 | type RepositoryMergeRequest struct { 16 | Base *string `json:"base,omitempty"` 17 | Head *string `json:"head,omitempty"` 18 | CommitMessage *string `json:"commit_message,omitempty"` 19 | } 20 | 21 | // Merge a branch in the specified repository. 22 | // 23 | // GitHub API docs: https://developer.github.com/v3/repos/merging/#perform-a-merge 24 | func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) { 25 | u := fmt.Sprintf("repos/%v/%v/merges", owner, repo) 26 | req, err := s.client.NewRequest("POST", u, request) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | commit := new(RepositoryCommit) 32 | resp, err := s.client.Do(ctx, req, commit) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return commit, resp, nil 38 | } 39 | -------------------------------------------------------------------------------- /import-comment/handler_test.go: -------------------------------------------------------------------------------- 1 | package function 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func Test_TrimNewLine(t *testing.T) { 8 | 9 | str := `👍 10 | ` 11 | want := `:+1:` 12 | 13 | got := trim(str) 14 | 15 | if got != want { 16 | t.Errorf("Want: %s\ngot: %s", want, got) 17 | } 18 | } 19 | 20 | func Test_NoTrim(t *testing.T) { 21 | 22 | str := `👍` 23 | want := `:+1:` 24 | 25 | got := trim(str) 26 | 27 | if got != want { 28 | t.Errorf("Want: %s\ngot: %s", want, got) 29 | } 30 | } 31 | 32 | func Test_CantFind(t *testing.T) { 33 | 34 | str := `That looks 👀` 35 | want := `That looks :eyes:` 36 | 37 | got := trim(str) 38 | 39 | if got != want { 40 | t.Errorf("Want: %s\ngot: %s", want, got) 41 | } 42 | } 43 | 44 | func Test_IsValid_ThumbsUp(t *testing.T) { 45 | got := isEmoji(trim(`👍`)) 46 | 47 | if got != true { 48 | t.Errorf("Want: %v\ngot: %v", true, got) 49 | } 50 | } 51 | 52 | func Test_IsValid_NoComposites(t *testing.T) { 53 | got := isEmoji(trim(`👍😎`)) 54 | 55 | if got != false { 56 | t.Errorf("Want: %v\ngot: %v", false, got) 57 | } 58 | } 59 | 60 | func Test_NoResult(t *testing.T) { 61 | str := `no result` 62 | want := "no result" 63 | 64 | got := trim(str) 65 | 66 | if got != want { 67 | t.Errorf("Want: %x\ngot: %x", want, got) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/timestamp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "strconv" 10 | "time" 11 | ) 12 | 13 | // Timestamp represents a time that can be unmarshalled from a JSON string 14 | // formatted as either an RFC3339 or Unix timestamp. This is necessary for some 15 | // fields since the GitHub API is inconsistent in how it represents times. All 16 | // exported methods of time.Time can be called on Timestamp. 17 | type Timestamp struct { 18 | time.Time 19 | } 20 | 21 | func (t Timestamp) String() string { 22 | return t.Time.String() 23 | } 24 | 25 | // UnmarshalJSON implements the json.Unmarshaler interface. 26 | // Time is expected in RFC3339 or Unix format. 27 | func (t *Timestamp) UnmarshalJSON(data []byte) (err error) { 28 | str := string(data) 29 | i, err := strconv.ParseInt(str, 10, 64) 30 | if err == nil { 31 | t.Time = time.Unix(i, 0) 32 | } else { 33 | t.Time, err = time.Parse(`"`+time.RFC3339+`"`, str) 34 | } 35 | return 36 | } 37 | 38 | // Equal reports whether t and u are equal based on time.Equal 39 | func (t Timestamp) Equal(u Timestamp) bool { 40 | return t.Time.Equal(u.Time) 41 | } 42 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/interactions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | // InteractionsService handles communication with the repository and organization related 9 | // methods of the GitHub API. 10 | // 11 | // GitHub API docs: https://developer.github.com/v3/interactions/ 12 | type InteractionsService service 13 | 14 | // InteractionRestriction represents the interaction restrictions for repository and organization. 15 | type InteractionRestriction struct { 16 | // Specifies the group of GitHub users who can 17 | // comment, open issues, or create pull requests for the given repository. 18 | // Possible values are: "existing_users", "contributors_only" and "collaborators_only". 19 | Limit *string `json:"limit,omitempty"` 20 | 21 | // Origin specifies the type of the resource to interact with. 22 | // Possible values are: "repository" and "organization". 23 | Origin *string `json:"origin,omitempty"` 24 | 25 | // ExpiresAt specifies the time after which the interaction restrictions expire. 26 | // The default expiry time is 24 hours from the time restriction is created. 27 | ExpiresAt *Timestamp `json:"expires_at,omitempty"` 28 | } 29 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /view/handler.go: -------------------------------------------------------------------------------- 1 | package function 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "log" 8 | "net/http" 9 | "text/template" 10 | ) 11 | 12 | func Handle(w http.ResponseWriter, r *http.Request) { 13 | tmpl, err := template.ParseFiles("public/index.html") 14 | if err != nil { 15 | log.Println(err.Error()) 16 | http.Error(w, err.Error(), http.StatusInternalServerError) 17 | return 18 | } 19 | 20 | res, err := http.Get("http://gateway.openfaas:8080/function/comments") 21 | 22 | if err != nil { 23 | log.Println(err.Error()) 24 | http.Error(w, err.Error(), http.StatusInternalServerError) 25 | return 26 | } 27 | 28 | defer res.Body.Close() 29 | 30 | body, _ := ioutil.ReadAll(res.Body) 31 | 32 | results := []Result{} 33 | err = json.Unmarshal(body, &results) 34 | if err != nil { 35 | log.Println(err.Error()) 36 | http.Error(w, err.Error(), http.StatusInternalServerError) 37 | return 38 | } 39 | 40 | var tpl bytes.Buffer 41 | err = tmpl.Execute(&tpl, results) 42 | 43 | if err != nil { 44 | log.Println(err.Error()) 45 | http.Error(w, err.Error(), http.StatusInternalServerError) 46 | return 47 | } 48 | 49 | w.Header().Set("Content-Type", "text/html; charset=utf-8") 50 | w.Write(tpl.Bytes()) 51 | } 52 | 53 | type Result struct { 54 | Emoji string `json:"emoji"` 55 | Total int `json:"total"` 56 | } 57 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/admin_orgs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // createOrgRequest is a subset of Organization and is used internally 11 | // by CreateOrg to pass only the known fields for the endpoint. 12 | type createOrgRequest struct { 13 | Login *string `json:"login,omitempty"` 14 | Admin *string `json:"admin,omitempty"` 15 | } 16 | 17 | // CreateOrg creates a new organization in GitHub Enterprise. 18 | // 19 | // Note that only a subset of the org fields are used and org must 20 | // not be nil. 21 | // 22 | // GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#create-an-organization 23 | func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) { 24 | u := "admin/organizations" 25 | 26 | orgReq := &createOrgRequest{ 27 | Login: org.Login, 28 | Admin: &admin, 29 | } 30 | 31 | req, err := s.client.NewRequest("POST", u, orgReq) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | 36 | o := new(Organization) 37 | resp, err := s.client.Do(ctx, req, o) 38 | if err != nil { 39 | return nil, resp, err 40 | } 41 | 42 | return o, resp, nil 43 | } 44 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /view/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Fun with emojis 4 | 5 | 21 | 22 | 23 |

Fun with OpenFaaS & Emoji-voting

24 |

25 | Comment on a proposal here 26 |

27 | 28 | 29 | {{ range . }} 30 | 31 | 32 | 33 | 34 | 35 | {{ end }} 36 |
{{ .Emoji }}{{ .Total }}
37 |

38 | Connect with the OpenFaaS community 39 |

40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Dave Cheney 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/canonical_text.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package openpgp 6 | 7 | import "hash" 8 | 9 | // NewCanonicalTextHash reformats text written to it into the canonical 10 | // form and then applies the hash h. See RFC 4880, section 5.2.1. 11 | func NewCanonicalTextHash(h hash.Hash) hash.Hash { 12 | return &canonicalTextHash{h, 0} 13 | } 14 | 15 | type canonicalTextHash struct { 16 | h hash.Hash 17 | s int 18 | } 19 | 20 | var newline = []byte{'\r', '\n'} 21 | 22 | func (cth *canonicalTextHash) Write(buf []byte) (int, error) { 23 | start := 0 24 | 25 | for i, c := range buf { 26 | switch cth.s { 27 | case 0: 28 | if c == '\r' { 29 | cth.s = 1 30 | } else if c == '\n' { 31 | cth.h.Write(buf[start:i]) 32 | cth.h.Write(newline) 33 | start = i + 1 34 | } 35 | case 1: 36 | cth.s = 0 37 | } 38 | } 39 | 40 | cth.h.Write(buf[start:]) 41 | return len(buf), nil 42 | } 43 | 44 | func (cth *canonicalTextHash) Sum(in []byte) []byte { 45 | return cth.h.Sum(in) 46 | } 47 | 48 | func (cth *canonicalTextHash) Reset() { 49 | cth.h.Reset() 50 | cth.s = 0 51 | } 52 | 53 | func (cth *canonicalTextHash) Size() int { 54 | return cth.h.Size() 55 | } 56 | 57 | func (cth *canonicalTextHash) BlockSize() int { 58 | return cth.h.BlockSize() 59 | } 60 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-querystring/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Google. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The go-github AUTHORS. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/go113.go: -------------------------------------------------------------------------------- 1 | // +build go1.13 2 | 3 | package errors 4 | 5 | import ( 6 | stderrors "errors" 7 | ) 8 | 9 | // Is reports whether any error in err's chain matches target. 10 | // 11 | // The chain consists of err itself followed by the sequence of errors obtained by 12 | // repeatedly calling Unwrap. 13 | // 14 | // An error is considered to match a target if it is equal to that target or if 15 | // it implements a method Is(error) bool such that Is(target) returns true. 16 | func Is(err, target error) bool { return stderrors.Is(err, target) } 17 | 18 | // As finds the first error in err's chain that matches target, and if so, sets 19 | // target to that error value and returns true. 20 | // 21 | // The chain consists of err itself followed by the sequence of errors obtained by 22 | // repeatedly calling Unwrap. 23 | // 24 | // An error matches target if the error's concrete value is assignable to the value 25 | // pointed to by target, or if the error has a method As(interface{}) bool such that 26 | // As(target) returns true. In the latter case, the As method is responsible for 27 | // setting target. 28 | // 29 | // As will panic if target is not a non-nil pointer to either a type that implements 30 | // error, or to any interface type. As returns false if err is nil. 31 | func As(err error, target interface{}) bool { return stderrors.As(err, target) } 32 | 33 | // Unwrap returns the result of calling the Unwrap method on err, if err's 34 | // type contains an Unwrap method returning error. 35 | // Otherwise, Unwrap returns nil. 36 | func Unwrap(err error) error { 37 | return stderrors.Unwrap(err) 38 | } 39 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/auth.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/openfaas/faas-provider/auth" 10 | ) 11 | 12 | const ( 13 | defaultPrivateKeyName = "private-key" 14 | defaultSecretMountPath = "/var/openfaas/secrets" 15 | ) 16 | 17 | // AddBasicAuth to a request by reading secrets when available 18 | func AddBasicAuth(req *http.Request) error { 19 | if len(os.Getenv("basic_auth")) > 0 && os.Getenv("basic_auth") == "true" { 20 | 21 | reader := auth.ReadBasicAuthFromDisk{} 22 | 23 | if len(os.Getenv("secret_mount_path")) > 0 { 24 | reader.SecretMountPath = os.Getenv("secret_mount_path") 25 | } 26 | 27 | credentials, err := reader.Read() 28 | 29 | if err != nil { 30 | return fmt.Errorf("error with AddBasicAuth %s", err.Error()) 31 | } 32 | 33 | req.SetBasicAuth(credentials.User, credentials.Password) 34 | } 35 | return nil 36 | } 37 | 38 | func GetPrivateKeyPath() string { 39 | // Private key name can be different from the default 'private-key' 40 | // When providing a different name in the stack.yaml, user need to specify the name 41 | // in github.yml as `private_key_filename: ` 42 | privateKeyName := os.Getenv("private_key_filename") 43 | 44 | if privateKeyName == "" { 45 | privateKeyName = defaultPrivateKeyName 46 | } 47 | 48 | secretMountPath := os.Getenv("secret_mount_path") 49 | 50 | if secretMountPath == "" { 51 | secretMountPath = defaultSecretMountPath 52 | } 53 | 54 | privateKeyPath := filepath.Join(secretMountPath, privateKeyName) 55 | 56 | return privateKeyPath 57 | } 58 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/go113.go: -------------------------------------------------------------------------------- 1 | // +build go1.13 2 | 3 | package errors 4 | 5 | import ( 6 | stderrors "errors" 7 | ) 8 | 9 | // Is reports whether any error in err's chain matches target. 10 | // 11 | // The chain consists of err itself followed by the sequence of errors obtained by 12 | // repeatedly calling Unwrap. 13 | // 14 | // An error is considered to match a target if it is equal to that target or if 15 | // it implements a method Is(error) bool such that Is(target) returns true. 16 | func Is(err, target error) bool { return stderrors.Is(err, target) } 17 | 18 | // As finds the first error in err's chain that matches target, and if so, sets 19 | // target to that error value and returns true. 20 | // 21 | // The chain consists of err itself followed by the sequence of errors obtained by 22 | // repeatedly calling Unwrap. 23 | // 24 | // An error matches target if the error's concrete value is assignable to the value 25 | // pointed to by target, or if the error has a method As(interface{}) bool such that 26 | // As(target) returns true. In the latter case, the As method is responsible for 27 | // setting target. 28 | // 29 | // As will panic if target is not a non-nil pointer to either a type that implements 30 | // error, or to any interface type. As returns false if err is nil. 31 | func As(err error, target interface{}) bool { return stderrors.As(err, target) } 32 | 33 | // Unwrap returns the result of calling the Unwrap method on err, if err's 34 | // type contains an Unwrap method returning error. 35 | // Otherwise, Unwrap returns nil. 36 | func Unwrap(err error) error { 37 | return stderrors.Unwrap(err) 38 | } 39 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/auth.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "os" 7 | "path/filepath" 8 | 9 | "github.com/openfaas/faas-provider/auth" 10 | ) 11 | 12 | const ( 13 | defaultPrivateKeyName = "private-key" 14 | defaultSecretMountPath = "/var/openfaas/secrets" 15 | ) 16 | 17 | // AddBasicAuth to a request by reading secrets when available 18 | func AddBasicAuth(req *http.Request) error { 19 | if len(os.Getenv("basic_auth")) > 0 && os.Getenv("basic_auth") == "true" { 20 | 21 | reader := auth.ReadBasicAuthFromDisk{} 22 | 23 | if len(os.Getenv("secret_mount_path")) > 0 { 24 | reader.SecretMountPath = os.Getenv("secret_mount_path") 25 | } 26 | 27 | credentials, err := reader.Read() 28 | 29 | if err != nil { 30 | return fmt.Errorf("error with AddBasicAuth %s", err.Error()) 31 | } 32 | 33 | req.SetBasicAuth(credentials.User, credentials.Password) 34 | } 35 | return nil 36 | } 37 | 38 | func GetPrivateKeyPath() string { 39 | // Private key name can be different from the default 'private-key' 40 | // When providing a different name in the stack.yaml, user need to specify the name 41 | // in github.yml as `private_key_filename: ` 42 | privateKeyName := os.Getenv("private_key_filename") 43 | 44 | if privateKeyName == "" { 45 | privateKeyName = defaultPrivateKeyName 46 | } 47 | 48 | secretMountPath := os.Getenv("secret_mount_path") 49 | 50 | if secretMountPath == "" { 51 | secretMountPath = defaultSecretMountPath 52 | } 53 | 54 | privateKeyPath := filepath.Join(secretMountPath, privateKeyName) 55 | 56 | return privateKeyPath 57 | } 58 | -------------------------------------------------------------------------------- /comments/vendor/github.com/alexellis/hmac/pkg.go: -------------------------------------------------------------------------------- 1 | package hmac 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha1" 6 | "encoding/hex" 7 | "fmt" 8 | ) 9 | 10 | // CheckMAC verifies hash checksum 11 | func CheckMAC(message, messageMAC, key []byte) bool { 12 | mac := hmac.New(sha1.New, key) 13 | mac.Write(message) 14 | expectedMAC := mac.Sum(nil) 15 | 16 | return hmac.Equal(messageMAC, expectedMAC) 17 | } 18 | 19 | // Sign a message with the key and return bytes. 20 | // Note: for human readable output see encoding/hex and 21 | // encode string functions. 22 | func Sign(message, key []byte) []byte { 23 | mac := hmac.New(sha1.New, key) 24 | mac.Write(message) 25 | signed := mac.Sum(nil) 26 | return signed 27 | } 28 | 29 | // Validate validate an encodedHash taken 30 | // from GitHub via X-Hub-Signature HTTP Header. 31 | // Note: if using another source, just add a 5 letter prefix such as "sha1=" 32 | func Validate(bytesIn []byte, encodedHash string, secretKey string) error { 33 | var validated error 34 | 35 | if len(encodedHash) > 5 { 36 | 37 | hashingMethod := encodedHash[:5] 38 | if hashingMethod != "sha1=" { 39 | return fmt.Errorf("unexpected hashing method: %s", hashingMethod) 40 | } 41 | 42 | messageMAC := encodedHash[5:] // first few chars are: sha1= 43 | messageMACBuf, _ := hex.DecodeString(messageMAC) 44 | 45 | res := CheckMAC(bytesIn, []byte(messageMACBuf), []byte(secretKey)) 46 | if res == false { 47 | validated = fmt.Errorf("invalid message digest or secret") 48 | } 49 | } else { 50 | return fmt.Errorf("invalid encodedHash, should have at least 5 characters") 51 | } 52 | 53 | return validated 54 | } 55 | 56 | func init() { 57 | 58 | } 59 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/alexellis/hmac/pkg.go: -------------------------------------------------------------------------------- 1 | package hmac 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/sha1" 6 | "encoding/hex" 7 | "fmt" 8 | ) 9 | 10 | // CheckMAC verifies hash checksum 11 | func CheckMAC(message, messageMAC, key []byte) bool { 12 | mac := hmac.New(sha1.New, key) 13 | mac.Write(message) 14 | expectedMAC := mac.Sum(nil) 15 | 16 | return hmac.Equal(messageMAC, expectedMAC) 17 | } 18 | 19 | // Sign a message with the key and return bytes. 20 | // Note: for human readable output see encoding/hex and 21 | // encode string functions. 22 | func Sign(message, key []byte) []byte { 23 | mac := hmac.New(sha1.New, key) 24 | mac.Write(message) 25 | signed := mac.Sum(nil) 26 | return signed 27 | } 28 | 29 | // Validate validate an encodedHash taken 30 | // from GitHub via X-Hub-Signature HTTP Header. 31 | // Note: if using another source, just add a 5 letter prefix such as "sha1=" 32 | func Validate(bytesIn []byte, encodedHash string, secretKey string) error { 33 | var validated error 34 | 35 | if len(encodedHash) > 5 { 36 | 37 | hashingMethod := encodedHash[:5] 38 | if hashingMethod != "sha1=" { 39 | return fmt.Errorf("unexpected hashing method: %s", hashingMethod) 40 | } 41 | 42 | messageMAC := encodedHash[5:] // first few chars are: sha1= 43 | messageMACBuf, _ := hex.DecodeString(messageMAC) 44 | 45 | res := CheckMAC(bytesIn, []byte(messageMACBuf), []byte(secretKey)) 46 | if res == false { 47 | validated = fmt.Errorf("invalid message digest or secret") 48 | } 49 | } else { 50 | return fmt.Errorf("invalid encodedHash, should have at least 5 characters") 51 | } 52 | 53 | return validated 54 | } 55 | 56 | func init() { 57 | 58 | } 59 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/event.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // Event info used to pass events between functions 8 | type Event struct { 9 | EventKey string `json:"event_key"` 10 | Service string `json:"service"` 11 | Owner string `json:"owner"` 12 | OwnerID int `json:"owner-id"` 13 | Repository string `json:"repository"` 14 | Image string `json:"image"` 15 | SHA string `json:"sha"` 16 | URL string `json:"url"` 17 | InstallationID int `json:"installationID"` 18 | Environment map[string]string `json:"environment"` 19 | Secrets []string `json:"secrets"` 20 | Private bool `json:"private"` 21 | SCM string `json:"scm"` 22 | RepoURL string `json:"repourl"` 23 | Labels map[string]string `json:"labels"` 24 | Annotations map[string]string `json:"annotations"` 25 | } 26 | 27 | // BuildEventFromPushEvent function to build Event from PushEvent 28 | func BuildEventFromPushEvent(pushEvent PushEvent) *Event { 29 | info := Event{} 30 | 31 | shortRef := pushEvent.Ref 32 | 33 | if index := strings.LastIndex(shortRef, "/"); index > -1 { 34 | shortRef = shortRef[index+1:] 35 | } 36 | 37 | info.Service = pushEvent.Repository.Name 38 | info.EventKey = pushEvent.Repository.Name + "-" + shortRef 39 | info.Owner = pushEvent.Repository.Owner.Login 40 | info.Repository = pushEvent.Repository.Name 41 | info.URL = pushEvent.Repository.CloneURL 42 | info.Private = pushEvent.Repository.Private 43 | 44 | info.SHA = pushEvent.AfterCommitID 45 | info.InstallationID = pushEvent.Installation.ID 46 | 47 | return &info 48 | } 49 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/faas-provider/auth/credentials.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) OpenFaaS Author(s). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package auth 5 | 6 | import ( 7 | "fmt" 8 | "io/ioutil" 9 | "path" 10 | "strings" 11 | ) 12 | 13 | // BasicAuthCredentials for credentials 14 | type BasicAuthCredentials struct { 15 | User string 16 | Password string 17 | } 18 | 19 | type ReadBasicAuth interface { 20 | Read() (*BasicAuthCredentials, error) 21 | } 22 | 23 | type ReadBasicAuthFromDisk struct { 24 | SecretMountPath string 25 | 26 | UserFilename string 27 | 28 | PasswordFilename string 29 | } 30 | 31 | func (r *ReadBasicAuthFromDisk) Read() (*BasicAuthCredentials, error) { 32 | var credentials *BasicAuthCredentials 33 | 34 | if len(r.SecretMountPath) == 0 { 35 | return nil, fmt.Errorf("invalid SecretMountPath specified for reading secrets") 36 | } 37 | 38 | userKey := "basic-auth-user" 39 | if len(r.UserFilename) > 0 { 40 | userKey = r.UserFilename 41 | } 42 | 43 | passwordKey := "basic-auth-password" 44 | if len(r.PasswordFilename) > 0 { 45 | passwordKey = r.PasswordFilename 46 | } 47 | 48 | userPath := path.Join(r.SecretMountPath, userKey) 49 | user, userErr := ioutil.ReadFile(userPath) 50 | if userErr != nil { 51 | return nil, fmt.Errorf("unable to load %s", userPath) 52 | } 53 | 54 | userPassword := path.Join(r.SecretMountPath, passwordKey) 55 | password, passErr := ioutil.ReadFile(userPassword) 56 | if passErr != nil { 57 | return nil, fmt.Errorf("Unable to load %s", userPassword) 58 | } 59 | 60 | credentials = &BasicAuthCredentials{ 61 | User: strings.TrimSpace(string(user)), 62 | Password: strings.TrimSpace(string(password)), 63 | } 64 | 65 | return credentials, nil 66 | } 67 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/event.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // Event info used to pass events between functions 8 | type Event struct { 9 | EventKey string `json:"event_key"` 10 | Service string `json:"service"` 11 | Owner string `json:"owner"` 12 | OwnerID int `json:"owner-id"` 13 | Repository string `json:"repository"` 14 | Image string `json:"image"` 15 | SHA string `json:"sha"` 16 | URL string `json:"url"` 17 | InstallationID int `json:"installationID"` 18 | Environment map[string]string `json:"environment"` 19 | Secrets []string `json:"secrets"` 20 | Private bool `json:"private"` 21 | SCM string `json:"scm"` 22 | RepoURL string `json:"repourl"` 23 | Labels map[string]string `json:"labels"` 24 | Annotations map[string]string `json:"annotations"` 25 | } 26 | 27 | // BuildEventFromPushEvent function to build Event from PushEvent 28 | func BuildEventFromPushEvent(pushEvent PushEvent) *Event { 29 | info := Event{} 30 | 31 | shortRef := pushEvent.Ref 32 | 33 | if index := strings.LastIndex(shortRef, "/"); index > -1 { 34 | shortRef = shortRef[index+1:] 35 | } 36 | 37 | info.Service = pushEvent.Repository.Name 38 | info.EventKey = pushEvent.Repository.Name + "-" + shortRef 39 | info.Owner = pushEvent.Repository.Owner.Login 40 | info.Repository = pushEvent.Repository.Name 41 | info.URL = pushEvent.Repository.CloneURL 42 | info.Private = pushEvent.Repository.Private 43 | 44 | info.SHA = pushEvent.AfterCommitID 45 | info.InstallationID = pushEvent.Installation.ID 46 | 47 | return &info 48 | } 49 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/faas-provider/auth/credentials.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) OpenFaaS Author(s). All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package auth 5 | 6 | import ( 7 | "fmt" 8 | "io/ioutil" 9 | "path" 10 | "strings" 11 | ) 12 | 13 | // BasicAuthCredentials for credentials 14 | type BasicAuthCredentials struct { 15 | User string 16 | Password string 17 | } 18 | 19 | type ReadBasicAuth interface { 20 | Read() (*BasicAuthCredentials, error) 21 | } 22 | 23 | type ReadBasicAuthFromDisk struct { 24 | SecretMountPath string 25 | 26 | UserFilename string 27 | 28 | PasswordFilename string 29 | } 30 | 31 | func (r *ReadBasicAuthFromDisk) Read() (*BasicAuthCredentials, error) { 32 | var credentials *BasicAuthCredentials 33 | 34 | if len(r.SecretMountPath) == 0 { 35 | return nil, fmt.Errorf("invalid SecretMountPath specified for reading secrets") 36 | } 37 | 38 | userKey := "basic-auth-user" 39 | if len(r.UserFilename) > 0 { 40 | userKey = r.UserFilename 41 | } 42 | 43 | passwordKey := "basic-auth-password" 44 | if len(r.PasswordFilename) > 0 { 45 | passwordKey = r.PasswordFilename 46 | } 47 | 48 | userPath := path.Join(r.SecretMountPath, userKey) 49 | user, userErr := ioutil.ReadFile(userPath) 50 | if userErr != nil { 51 | return nil, fmt.Errorf("unable to load %s", userPath) 52 | } 53 | 54 | userPassword := path.Join(r.SecretMountPath, passwordKey) 55 | password, passErr := ioutil.ReadFile(userPassword) 56 | if passErr != nil { 57 | return nil, fmt.Errorf("Unable to load %s", userPassword) 58 | } 59 | 60 | credentials = &BasicAuthCredentials{ 61 | User: strings.TrimSpace(string(user)), 62 | Password: strings.TrimSpace(string(password)), 63 | } 64 | 65 | return credentials, nil 66 | } 67 | -------------------------------------------------------------------------------- /comments/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | digest = "1:871b7cfa5fe18bfdbd4bf117c166c3cff8d3b61c8afe4e998b5b8ac0c160ca24" 6 | name = "github.com/alexellis/hmac" 7 | packages = ["."] 8 | pruneopts = "UT" 9 | revision = "d5d71edd7bc74eb6ae4b99eccc6bda738435f43f" 10 | version = "1.2" 11 | 12 | [[projects]] 13 | digest = "1:9ff22c26414baf7deaf74f2a788fe7b97666048bcbe346c52cfe823442abbdfb" 14 | name = "github.com/lib/pq" 15 | packages = [ 16 | ".", 17 | "oid", 18 | "scram", 19 | ] 20 | pruneopts = "UT" 21 | revision = "99274577be97ac9b1d95a2d61d566dc9b7cc6a54" 22 | version = "v1.3.0" 23 | 24 | [[projects]] 25 | digest = "1:640b3b23db9a5542f998adcf5ca3527951855f93156784dd9592242a61b89598" 26 | name = "github.com/openfaas/faas-provider" 27 | packages = ["auth"] 28 | pruneopts = "UT" 29 | revision = "98c25c3919da1ca07bb93fad63fd9715b460963f" 30 | version = "012.1" 31 | 32 | [[projects]] 33 | digest = "1:df78e66063fb11e516c09941a5b11e7a311af88edd6972b9170128899fb28c1a" 34 | name = "github.com/openfaas/openfaas-cloud" 35 | packages = ["sdk"] 36 | pruneopts = "UT" 37 | revision = "fba4e3ffd97e7029bb554f27fa83259dcbd5d3d3" 38 | version = "0.13.8" 39 | 40 | [[projects]] 41 | digest = "1:9e1d37b58d17113ec3cb5608ac0382313c5b59470b94ed97d0976e69c7022314" 42 | name = "github.com/pkg/errors" 43 | packages = ["."] 44 | pruneopts = "UT" 45 | revision = "614d223910a179a466c1767a985424175c39b465" 46 | version = "v0.9.1" 47 | 48 | [solve-meta] 49 | analyzer-name = "dep" 50 | analyzer-version = 1 51 | input-imports = [ 52 | "github.com/lib/pq", 53 | "github.com/openfaas/openfaas-cloud/sdk", 54 | "github.com/pkg/errors", 55 | ] 56 | solver-name = "gps-cdcl" 57 | solver-version = 1 58 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/README.md: -------------------------------------------------------------------------------- 1 | # About emoji 2 | 3 | `emoji` provides standardized ways for translating unicode code points for 4 | Emoji to/from their [emoji cheat sheet][emoji-cheat-sheet] encoding, and is 5 | most useful when working with third-party APIs such as Slack, GitHub, etc. 6 | 7 | `emoji` was written because other emoji packages for Go only provided cheat 8 | sheet names to unicode conversion and not the inverse. Additionally, there were 9 | no comprehensive [emoticon][wiki-emoticon] packages available at the time. 10 | 11 | ## Gemoji Data 12 | 13 | Data for this package is generated from GitHub's [gemoji][gemoji] project: 14 | 15 | ```sh 16 | $ cd $GOPATH/src/github.com/brankas/emoji 17 | $ go generate 18 | ``` 19 | 20 | ## Installing 21 | 22 | Install in the usual [Go][go-project] fashion: 23 | 24 | ```sh 25 | $ go get -u github.com/brankas/emoji 26 | ``` 27 | 28 | ## Using 29 | 30 | `emoji` can be used similarly to the following: 31 | 32 | ```go 33 | // example/example.go 34 | package main 35 | 36 | import ( 37 | "log" 38 | 39 | "github.com/brankas/emoji" 40 | ) 41 | 42 | func main() { 43 | a := emoji.FromEmoticon(":-)") 44 | log.Printf(":-) %+v", a) 45 | 46 | b := emoji.FromAlias("slightly_smiling_face") 47 | log.Printf(":-) %+v", b) 48 | 49 | s := emoji.ReplaceEmoticonsWithAliases(":-) :D >:(") 50 | log.Printf("s: %s", s) 51 | 52 | n := emoji.ReplaceEmoticonsWithCodes(":-) :D >:(") 53 | log.Printf("n: %s", n) 54 | } 55 | ``` 56 | 57 | Please see the [GoDoc][godoc] listing for the complete API listing. 58 | 59 | ## TODO 60 | 61 | * Convert `UnicodeVersion` and `IOSVersion` fields of `Emoji` type to something 62 | more easily comparable (ie, int) 63 | 64 | [emoji-cheat-sheet]: http://www.webpagefx.com/tools/emoji-cheat-sheet/ 65 | [gemoji]: https://github.com/github/gemoji 66 | [godoc]: https://godoc.org/github.com/brankas/emoji 67 | [go-project]: https://golang.org/project 68 | [wiki-emoticon]: https://en.wikipedia.org/wiki/Emoticon 69 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/gitignore.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // GitignoresService provides access to the gitignore related functions in the 14 | // GitHub API. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/gitignore/ 17 | type GitignoresService service 18 | 19 | // Gitignore represents a .gitignore file as returned by the GitHub API. 20 | type Gitignore struct { 21 | Name *string `json:"name,omitempty"` 22 | Source *string `json:"source,omitempty"` 23 | } 24 | 25 | func (g Gitignore) String() string { 26 | return Stringify(g) 27 | } 28 | 29 | // List all available Gitignore templates. 30 | // 31 | // GitHub API docs: https://developer.github.com/v3/gitignore/#listing-available-templates 32 | func (s GitignoresService) List(ctx context.Context) ([]string, *Response, error) { 33 | req, err := s.client.NewRequest("GET", "gitignore/templates", nil) 34 | if err != nil { 35 | return nil, nil, err 36 | } 37 | 38 | var availableTemplates []string 39 | resp, err := s.client.Do(ctx, req, &availableTemplates) 40 | if err != nil { 41 | return nil, resp, err 42 | } 43 | 44 | return availableTemplates, resp, nil 45 | } 46 | 47 | // Get a Gitignore by name. 48 | // 49 | // GitHub API docs: https://developer.github.com/v3/gitignore/#get-a-single-template 50 | func (s GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) { 51 | u := fmt.Sprintf("gitignore/templates/%v", name) 52 | req, err := s.client.NewRequest("GET", u, nil) 53 | if err != nil { 54 | return nil, nil, err 55 | } 56 | 57 | gitignore := new(Gitignore) 58 | resp, err := s.client.Do(ctx, req, gitignore) 59 | if err != nil { 60 | return nil, resp, err 61 | } 62 | 63 | return gitignore, resp, nil 64 | } 65 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/orgs_projects.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListProjects lists the projects for an organization. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/projects/#list-organization-projects 16 | func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) { 17 | u := fmt.Sprintf("orgs/%v/projects", org) 18 | u, err := addOptions(u, opts) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeProjectsPreview) 30 | 31 | var projects []*Project 32 | resp, err := s.client.Do(ctx, req, &projects) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return projects, resp, nil 38 | } 39 | 40 | // CreateProject creates a GitHub Project for the specified organization. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/projects/#create-an-organization-project 43 | func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) { 44 | u := fmt.Sprintf("orgs/%v/projects", org) 45 | req, err := s.client.NewRequest("POST", u, opts) 46 | if err != nil { 47 | return nil, nil, err 48 | } 49 | 50 | // TODO: remove custom Accept header when this API fully launches. 51 | req.Header.Set("Accept", mediaTypeProjectsPreview) 52 | 53 | project := &Project{} 54 | resp, err := s.client.Do(ctx, req, project) 55 | if err != nil { 56 | return nil, resp, err 57 | } 58 | 59 | return project, resp, nil 60 | } 61 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | nurl "net/url" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 12 | // connection string to sql.Open() is now supported: 13 | // 14 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 15 | // 16 | // It remains exported here for backwards-compatibility. 17 | // 18 | // ParseURL converts a url to a connection string for driver.Open. 19 | // Example: 20 | // 21 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 22 | // 23 | // converts to: 24 | // 25 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 26 | // 27 | // A minimal example: 28 | // 29 | // "postgres://" 30 | // 31 | // This will be blank, causing driver.Open to use all of the defaults 32 | func ParseURL(url string) (string, error) { 33 | u, err := nurl.Parse(url) 34 | if err != nil { 35 | return "", err 36 | } 37 | 38 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 39 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 40 | } 41 | 42 | var kvs []string 43 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 44 | accrue := func(k, v string) { 45 | if v != "" { 46 | kvs = append(kvs, k+"="+escaper.Replace(v)) 47 | } 48 | } 49 | 50 | if u.User != nil { 51 | v := u.User.Username() 52 | accrue("user", v) 53 | 54 | v, _ = u.User.Password() 55 | accrue("password", v) 56 | } 57 | 58 | if host, port, err := net.SplitHostPort(u.Host); err != nil { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", host) 62 | accrue("port", port) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | nurl "net/url" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 12 | // connection string to sql.Open() is now supported: 13 | // 14 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 15 | // 16 | // It remains exported here for backwards-compatibility. 17 | // 18 | // ParseURL converts a url to a connection string for driver.Open. 19 | // Example: 20 | // 21 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 22 | // 23 | // converts to: 24 | // 25 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 26 | // 27 | // A minimal example: 28 | // 29 | // "postgres://" 30 | // 31 | // This will be blank, causing driver.Open to use all of the defaults 32 | func ParseURL(url string) (string, error) { 33 | u, err := nurl.Parse(url) 34 | if err != nil { 35 | return "", err 36 | } 37 | 38 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 39 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 40 | } 41 | 42 | var kvs []string 43 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 44 | accrue := func(k, v string) { 45 | if v != "" { 46 | kvs = append(kvs, k+"="+escaper.Replace(v)) 47 | } 48 | } 49 | 50 | if u.User != nil { 51 | v := u.User.Username() 52 | accrue("user", v) 53 | 54 | v, _ = u.User.Password() 55 | accrue("password", v) 56 | } 57 | 58 | if host, port, err := net.SplitHostPort(u.Host); err != nil { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", host) 62 | accrue("port", port) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(append(b.buf, s...), '\000') 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(append(b.buf, s...), '\000') 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/apps_manifest.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | const ( 14 | mediaTypeAppManifestPreview = "application/vnd.github.fury-preview+json" 15 | ) 16 | 17 | // AppConfig describes the configuration of a GitHub App. 18 | type AppConfig struct { 19 | ID *int64 `json:"id,omitempty"` 20 | NodeID *string `json:"node_id,omitempty"` 21 | Owner *User `json:"owner,omitempty"` 22 | Name *string `json:"name,omitempty"` 23 | Description *string `json:"description,omitempty"` 24 | ExternalURL *string `json:"external_url,omitempty"` 25 | HTMLURL *string `json:"html_url,omitempty"` 26 | CreatedAt *Timestamp `json:"created_at,omitempty"` 27 | UpdatedAt *Timestamp `json:"updated_at,omitempty"` 28 | ClientID *string `json:"client_id,omitempty"` 29 | ClientSecret *string `json:"client_secret,omitempty"` 30 | WebhookSecret *string `json:"webhook_secret,omitempty"` 31 | PEM *string `json:"pem,omitempty"` 32 | } 33 | 34 | // CompleteAppManifest completes the App manifest handshake flow for the given 35 | // code. 36 | // 37 | // GitHub API docs: https://developer.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/#3-you-exchange-the-temporary-code-to-retrieve-the-app-configuration 38 | func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) { 39 | u := fmt.Sprintf("app-manifests/%s/conversions", code) 40 | req, err := s.client.NewRequest("POST", u, nil) 41 | if err != nil { 42 | return nil, nil, err 43 | } 44 | req.Header.Set("Accept", mediaTypeAppManifestPreview) 45 | 46 | cfg := new(AppConfig) 47 | resp, err := s.client.Do(ctx, req, cfg) 48 | if err != nil { 49 | return nil, resp, err 50 | } 51 | 52 | return cfg, resp, nil 53 | } 54 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/packet/one_pass_signature.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "crypto" 9 | "encoding/binary" 10 | "golang.org/x/crypto/openpgp/errors" 11 | "golang.org/x/crypto/openpgp/s2k" 12 | "io" 13 | "strconv" 14 | ) 15 | 16 | // OnePassSignature represents a one-pass signature packet. See RFC 4880, 17 | // section 5.4. 18 | type OnePassSignature struct { 19 | SigType SignatureType 20 | Hash crypto.Hash 21 | PubKeyAlgo PublicKeyAlgorithm 22 | KeyId uint64 23 | IsLast bool 24 | } 25 | 26 | const onePassSignatureVersion = 3 27 | 28 | func (ops *OnePassSignature) parse(r io.Reader) (err error) { 29 | var buf [13]byte 30 | 31 | _, err = readFull(r, buf[:]) 32 | if err != nil { 33 | return 34 | } 35 | if buf[0] != onePassSignatureVersion { 36 | err = errors.UnsupportedError("one-pass-signature packet version " + strconv.Itoa(int(buf[0]))) 37 | } 38 | 39 | var ok bool 40 | ops.Hash, ok = s2k.HashIdToHash(buf[2]) 41 | if !ok { 42 | return errors.UnsupportedError("hash function: " + strconv.Itoa(int(buf[2]))) 43 | } 44 | 45 | ops.SigType = SignatureType(buf[1]) 46 | ops.PubKeyAlgo = PublicKeyAlgorithm(buf[3]) 47 | ops.KeyId = binary.BigEndian.Uint64(buf[4:12]) 48 | ops.IsLast = buf[12] != 0 49 | return 50 | } 51 | 52 | // Serialize marshals the given OnePassSignature to w. 53 | func (ops *OnePassSignature) Serialize(w io.Writer) error { 54 | var buf [13]byte 55 | buf[0] = onePassSignatureVersion 56 | buf[1] = uint8(ops.SigType) 57 | var ok bool 58 | buf[2], ok = s2k.HashToHashId(ops.Hash) 59 | if !ok { 60 | return errors.UnsupportedError("hash type: " + strconv.Itoa(int(ops.Hash))) 61 | } 62 | buf[3] = uint8(ops.PubKeyAlgo) 63 | binary.BigEndian.PutUint64(buf[4:12], ops.KeyId) 64 | if ops.IsLast { 65 | buf[12] = 1 66 | } 67 | 68 | if err := serializeHeader(w, packetTypeOnePassSignature, len(buf)); err != nil { 69 | return err 70 | } 71 | _, err := w.Write(buf[:]) 72 | return err 73 | } 74 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/oid/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Generate the table of OID values 4 | // Run with 'go run gen.go'. 5 | package main 6 | 7 | import ( 8 | "database/sql" 9 | "fmt" 10 | "log" 11 | "os" 12 | "os/exec" 13 | "strings" 14 | 15 | _ "github.com/lib/pq" 16 | ) 17 | 18 | // OID represent a postgres Object Identifier Type. 19 | type OID struct { 20 | ID int 21 | Type string 22 | } 23 | 24 | // Name returns an upper case version of the oid type. 25 | func (o OID) Name() string { 26 | return strings.ToUpper(o.Type) 27 | } 28 | 29 | func main() { 30 | datname := os.Getenv("PGDATABASE") 31 | sslmode := os.Getenv("PGSSLMODE") 32 | 33 | if datname == "" { 34 | os.Setenv("PGDATABASE", "pqgotest") 35 | } 36 | 37 | if sslmode == "" { 38 | os.Setenv("PGSSLMODE", "disable") 39 | } 40 | 41 | db, err := sql.Open("postgres", "") 42 | if err != nil { 43 | log.Fatal(err) 44 | } 45 | rows, err := db.Query(` 46 | SELECT typname, oid 47 | FROM pg_type WHERE oid < 10000 48 | ORDER BY oid; 49 | `) 50 | if err != nil { 51 | log.Fatal(err) 52 | } 53 | oids := make([]*OID, 0) 54 | for rows.Next() { 55 | var oid OID 56 | if err = rows.Scan(&oid.Type, &oid.ID); err != nil { 57 | log.Fatal(err) 58 | } 59 | oids = append(oids, &oid) 60 | } 61 | if err = rows.Err(); err != nil { 62 | log.Fatal(err) 63 | } 64 | cmd := exec.Command("gofmt") 65 | cmd.Stderr = os.Stderr 66 | w, err := cmd.StdinPipe() 67 | if err != nil { 68 | log.Fatal(err) 69 | } 70 | f, err := os.Create("types.go") 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | cmd.Stdout = f 75 | err = cmd.Start() 76 | if err != nil { 77 | log.Fatal(err) 78 | } 79 | fmt.Fprintln(w, "// Code generated by gen.go. DO NOT EDIT.") 80 | fmt.Fprintln(w, "\npackage oid") 81 | fmt.Fprintln(w, "const (") 82 | for _, oid := range oids { 83 | fmt.Fprintf(w, "T_%s Oid = %d\n", oid.Type, oid.ID) 84 | } 85 | fmt.Fprintln(w, ")") 86 | fmt.Fprintln(w, "var TypeName = map[Oid]string{") 87 | for _, oid := range oids { 88 | fmt.Fprintf(w, "T_%s: \"%s\",\n", oid.Type, oid.Name()) 89 | } 90 | fmt.Fprintln(w, "}") 91 | w.Close() 92 | cmd.Wait() 93 | } 94 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/oid/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Generate the table of OID values 4 | // Run with 'go run gen.go'. 5 | package main 6 | 7 | import ( 8 | "database/sql" 9 | "fmt" 10 | "log" 11 | "os" 12 | "os/exec" 13 | "strings" 14 | 15 | _ "github.com/lib/pq" 16 | ) 17 | 18 | // OID represent a postgres Object Identifier Type. 19 | type OID struct { 20 | ID int 21 | Type string 22 | } 23 | 24 | // Name returns an upper case version of the oid type. 25 | func (o OID) Name() string { 26 | return strings.ToUpper(o.Type) 27 | } 28 | 29 | func main() { 30 | datname := os.Getenv("PGDATABASE") 31 | sslmode := os.Getenv("PGSSLMODE") 32 | 33 | if datname == "" { 34 | os.Setenv("PGDATABASE", "pqgotest") 35 | } 36 | 37 | if sslmode == "" { 38 | os.Setenv("PGSSLMODE", "disable") 39 | } 40 | 41 | db, err := sql.Open("postgres", "") 42 | if err != nil { 43 | log.Fatal(err) 44 | } 45 | rows, err := db.Query(` 46 | SELECT typname, oid 47 | FROM pg_type WHERE oid < 10000 48 | ORDER BY oid; 49 | `) 50 | if err != nil { 51 | log.Fatal(err) 52 | } 53 | oids := make([]*OID, 0) 54 | for rows.Next() { 55 | var oid OID 56 | if err = rows.Scan(&oid.Type, &oid.ID); err != nil { 57 | log.Fatal(err) 58 | } 59 | oids = append(oids, &oid) 60 | } 61 | if err = rows.Err(); err != nil { 62 | log.Fatal(err) 63 | } 64 | cmd := exec.Command("gofmt") 65 | cmd.Stderr = os.Stderr 66 | w, err := cmd.StdinPipe() 67 | if err != nil { 68 | log.Fatal(err) 69 | } 70 | f, err := os.Create("types.go") 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | cmd.Stdout = f 75 | err = cmd.Start() 76 | if err != nil { 77 | log.Fatal(err) 78 | } 79 | fmt.Fprintln(w, "// Code generated by gen.go. DO NOT EDIT.") 80 | fmt.Fprintln(w, "\npackage oid") 81 | fmt.Fprintln(w, "const (") 82 | for _, oid := range oids { 83 | fmt.Fprintf(w, "T_%s Oid = %d\n", oid.Type, oid.ID) 84 | } 85 | fmt.Fprintln(w, ")") 86 | fmt.Fprintln(w, "var TypeName = map[Oid]string{") 87 | for _, oid := range oids { 88 | fmt.Fprintf(w, "T_%s: \"%s\",\n", oid.Type, oid.Name()) 89 | } 90 | fmt.Fprintln(w, "}") 91 | w.Close() 92 | cmd.Wait() 93 | } 94 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/errors/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package errors contains common error types for the OpenPGP packages. 6 | package errors // import "golang.org/x/crypto/openpgp/errors" 7 | 8 | import ( 9 | "strconv" 10 | ) 11 | 12 | // A StructuralError is returned when OpenPGP data is found to be syntactically 13 | // invalid. 14 | type StructuralError string 15 | 16 | func (s StructuralError) Error() string { 17 | return "openpgp: invalid data: " + string(s) 18 | } 19 | 20 | // UnsupportedError indicates that, although the OpenPGP data is valid, it 21 | // makes use of currently unimplemented features. 22 | type UnsupportedError string 23 | 24 | func (s UnsupportedError) Error() string { 25 | return "openpgp: unsupported feature: " + string(s) 26 | } 27 | 28 | // InvalidArgumentError indicates that the caller is in error and passed an 29 | // incorrect value. 30 | type InvalidArgumentError string 31 | 32 | func (i InvalidArgumentError) Error() string { 33 | return "openpgp: invalid argument: " + string(i) 34 | } 35 | 36 | // SignatureError indicates that a syntactically valid signature failed to 37 | // validate. 38 | type SignatureError string 39 | 40 | func (b SignatureError) Error() string { 41 | return "openpgp: invalid signature: " + string(b) 42 | } 43 | 44 | type keyIncorrectError int 45 | 46 | func (ki keyIncorrectError) Error() string { 47 | return "openpgp: incorrect key" 48 | } 49 | 50 | var ErrKeyIncorrect error = keyIncorrectError(0) 51 | 52 | type unknownIssuerError int 53 | 54 | func (unknownIssuerError) Error() string { 55 | return "openpgp: signature made by unknown entity" 56 | } 57 | 58 | var ErrUnknownIssuer error = unknownIssuerError(0) 59 | 60 | type keyRevokedError int 61 | 62 | func (keyRevokedError) Error() string { 63 | return "openpgp: signature made by revoked key" 64 | } 65 | 66 | var ErrKeyRevoked error = keyRevokedError(0) 67 | 68 | type UnknownPacketTypeError uint8 69 | 70 | func (upte UnknownPacketTypeError) Error() string { 71 | return "openpgp: unknown packet type: " + strconv.Itoa(int(upte)) 72 | } 73 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/users_projects.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListProjects lists the projects for the specified user. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/projects/#list-user-projects 16 | func (s *UsersService) ListProjects(ctx context.Context, user string, opts *ProjectListOptions) ([]*Project, *Response, error) { 17 | u := fmt.Sprintf("users/%v/projects", user) 18 | u, err := addOptions(u, opts) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeProjectsPreview) 30 | 31 | var projects []*Project 32 | resp, err := s.client.Do(ctx, req, &projects) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return projects, resp, nil 38 | } 39 | 40 | // CreateUserProjectOptions specifies the parameters to the UsersService.CreateProject method. 41 | type CreateUserProjectOptions struct { 42 | // The name of the project. (Required.) 43 | Name string `json:"name"` 44 | // The description of the project. (Optional.) 45 | Body *string `json:"body,omitempty"` 46 | } 47 | 48 | // CreateProject creates a GitHub Project for the current user. 49 | // 50 | // GitHub API docs: https://developer.github.com/v3/projects/#create-a-user-project 51 | func (s *UsersService) CreateProject(ctx context.Context, opts *CreateUserProjectOptions) (*Project, *Response, error) { 52 | u := "users/projects" 53 | req, err := s.client.NewRequest("POST", u, opts) 54 | if err != nil { 55 | return nil, nil, err 56 | } 57 | 58 | // TODO: remove custom Accept header when this API fully launches. 59 | req.Header.Set("Accept", mediaTypeProjectsPreview) 60 | 61 | project := &Project{} 62 | resp, err := s.client.Do(ctx, req, project) 63 | if err != nil { 64 | return nil, resp, err 65 | } 66 | 67 | return project, resp, nil 68 | } 69 | -------------------------------------------------------------------------------- /comments/handler.go: -------------------------------------------------------------------------------- 1 | package function 2 | 3 | import ( 4 | "database/sql" 5 | "encoding/json" 6 | "log" 7 | "net/http" 8 | "os" 9 | 10 | _ "github.com/lib/pq" 11 | "github.com/pkg/errors" 12 | 13 | "github.com/openfaas/openfaas-cloud/sdk" 14 | ) 15 | 16 | var db *sql.DB 17 | var cors string 18 | 19 | // init establishes a persistent connection to the remote database 20 | // the function will panic if it cannot establish a link and the 21 | // container will restart / go into a crash/back-off loop 22 | func init() { 23 | password, _ := sdk.ReadSecret("password") 24 | user, _ := sdk.ReadSecret("username") 25 | host, _ := sdk.ReadSecret("host") 26 | 27 | dbName := os.Getenv("postgres_db") 28 | port := os.Getenv("postgres_port") 29 | sslmode := os.Getenv("postgres_sslmode") 30 | 31 | connStr := "postgres://" + user + ":" + password + "@" + host + ":" + port + "/" + dbName + "?sslmode=" + sslmode 32 | 33 | var err error 34 | db, err = sql.Open("postgres", connStr) 35 | 36 | if err != nil { 37 | panic(err.Error()) 38 | } 39 | 40 | err = db.Ping() 41 | if err != nil { 42 | panic(err.Error()) 43 | } 44 | 45 | if val, ok := os.LookupEnv("allow_cors"); ok && len(val) > 0 { 46 | cors = val 47 | } 48 | } 49 | 50 | // Handle a HTTP request as a middleware processor. 51 | func Handle(w http.ResponseWriter, r *http.Request) { 52 | 53 | rows, getErr := db.Query(`select * from get_emojis();`) 54 | 55 | if getErr != nil { 56 | log.Printf("get error: %s", getErr.Error()) 57 | http.Error(w, errors.Wrap(getErr, "unable to get from get_emojis").Error(), 58 | http.StatusInternalServerError) 59 | return 60 | } 61 | 62 | results := []Result{} 63 | defer rows.Close() 64 | for rows.Next() { 65 | result := Result{} 66 | scanErr := rows.Scan(&result.Emoji, &result.Total) 67 | if scanErr != nil { 68 | log.Println("scan err:", scanErr) 69 | } 70 | results = append(results, result) 71 | } 72 | 73 | if len(cors) > 0 { 74 | w.Header().Set("Access-Control-Allow-Origin", cors) 75 | } 76 | 77 | w.Header().Set("Content-Type", "application/json; charset=utf-8") 78 | w.WriteHeader(http.StatusOK) 79 | 80 | res, _ := json.Marshal(results) 81 | w.Write(res) 82 | } 83 | 84 | type Result struct { 85 | Emoji string `json:"emoji"` 86 | Total int `json:"total"` 87 | } 88 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/strings.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "bytes" 10 | "fmt" 11 | "io" 12 | 13 | "reflect" 14 | ) 15 | 16 | var timestampType = reflect.TypeOf(Timestamp{}) 17 | 18 | // Stringify attempts to create a reasonable string representation of types in 19 | // the GitHub library. It does things like resolve pointers to their values 20 | // and omits struct fields with nil values. 21 | func Stringify(message interface{}) string { 22 | var buf bytes.Buffer 23 | v := reflect.ValueOf(message) 24 | stringifyValue(&buf, v) 25 | return buf.String() 26 | } 27 | 28 | // stringifyValue was heavily inspired by the goprotobuf library. 29 | 30 | func stringifyValue(w io.Writer, val reflect.Value) { 31 | if val.Kind() == reflect.Ptr && val.IsNil() { 32 | w.Write([]byte("")) 33 | return 34 | } 35 | 36 | v := reflect.Indirect(val) 37 | 38 | switch v.Kind() { 39 | case reflect.String: 40 | fmt.Fprintf(w, `"%s"`, v) 41 | case reflect.Slice: 42 | w.Write([]byte{'['}) 43 | for i := 0; i < v.Len(); i++ { 44 | if i > 0 { 45 | w.Write([]byte{' '}) 46 | } 47 | 48 | stringifyValue(w, v.Index(i)) 49 | } 50 | 51 | w.Write([]byte{']'}) 52 | return 53 | case reflect.Struct: 54 | if v.Type().Name() != "" { 55 | w.Write([]byte(v.Type().String())) 56 | } 57 | 58 | // special handling of Timestamp values 59 | if v.Type() == timestampType { 60 | fmt.Fprintf(w, "{%s}", v.Interface()) 61 | return 62 | } 63 | 64 | w.Write([]byte{'{'}) 65 | 66 | var sep bool 67 | for i := 0; i < v.NumField(); i++ { 68 | fv := v.Field(i) 69 | if fv.Kind() == reflect.Ptr && fv.IsNil() { 70 | continue 71 | } 72 | if fv.Kind() == reflect.Slice && fv.IsNil() { 73 | continue 74 | } 75 | 76 | if sep { 77 | w.Write([]byte(", ")) 78 | } else { 79 | sep = true 80 | } 81 | 82 | w.Write([]byte(v.Type().Field(i).Name)) 83 | w.Write([]byte{':'}) 84 | stringifyValue(w, fv) 85 | } 86 | 87 | w.Write([]byte{'}'}) 88 | default: 89 | if v.CanInterface() { 90 | fmt.Fprint(w, v.Interface()) 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/repos_community_health.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | "time" 12 | ) 13 | 14 | // Metric represents the different fields for one file in community health files. 15 | type Metric struct { 16 | Name *string `json:"name"` 17 | Key *string `json:"key"` 18 | URL *string `json:"url"` 19 | HTMLURL *string `json:"html_url"` 20 | } 21 | 22 | // CommunityHealthFiles represents the different files in the community health metrics response. 23 | type CommunityHealthFiles struct { 24 | CodeOfConduct *Metric `json:"code_of_conduct"` 25 | Contributing *Metric `json:"contributing"` 26 | IssueTemplate *Metric `json:"issue_template"` 27 | PullRequestTemplate *Metric `json:"pull_request_template"` 28 | License *Metric `json:"license"` 29 | Readme *Metric `json:"readme"` 30 | } 31 | 32 | // CommunityHealthMetrics represents a response containing the community metrics of a repository. 33 | type CommunityHealthMetrics struct { 34 | HealthPercentage *int `json:"health_percentage"` 35 | Files *CommunityHealthFiles `json:"files"` 36 | UpdatedAt *time.Time `json:"updated_at"` 37 | } 38 | 39 | // GetCommunityHealthMetrics retrieves all the community health metrics for a repository. 40 | // 41 | // GitHub API docs: https://developer.github.com/v3/repos/community/#retrieve-community-health-metrics 42 | func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) { 43 | u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo) 44 | req, err := s.client.NewRequest("GET", u, nil) 45 | if err != nil { 46 | return nil, nil, err 47 | } 48 | 49 | // TODO: remove custom Accept header when this API fully launches. 50 | req.Header.Set("Accept", mediaTypeRepositoryCommunityHealthMetricsPreview) 51 | 52 | metrics := &CommunityHealthMetrics{} 53 | resp, err := s.client.Do(ctx, req, metrics) 54 | if err != nil { 55 | return nil, resp, err 56 | } 57 | 58 | return metrics, resp, nil 59 | } 60 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/users_emails.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // UserEmail represents user's email address 11 | type UserEmail struct { 12 | Email *string `json:"email,omitempty"` 13 | Primary *bool `json:"primary,omitempty"` 14 | Verified *bool `json:"verified,omitempty"` 15 | Visibility *string `json:"visibility,omitempty"` 16 | } 17 | 18 | // ListEmails lists all email addresses for the authenticated user. 19 | // 20 | // GitHub API docs: https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user 21 | func (s *UsersService) ListEmails(ctx context.Context, opts *ListOptions) ([]*UserEmail, *Response, error) { 22 | u := "user/emails" 23 | u, err := addOptions(u, opts) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | req, err := s.client.NewRequest("GET", u, nil) 29 | if err != nil { 30 | return nil, nil, err 31 | } 32 | 33 | var emails []*UserEmail 34 | resp, err := s.client.Do(ctx, req, &emails) 35 | if err != nil { 36 | return nil, resp, err 37 | } 38 | 39 | return emails, resp, nil 40 | } 41 | 42 | // AddEmails adds email addresses of the authenticated user. 43 | // 44 | // GitHub API docs: https://developer.github.com/v3/users/emails/#add-email-addresses 45 | func (s *UsersService) AddEmails(ctx context.Context, emails []string) ([]*UserEmail, *Response, error) { 46 | u := "user/emails" 47 | req, err := s.client.NewRequest("POST", u, emails) 48 | if err != nil { 49 | return nil, nil, err 50 | } 51 | 52 | var e []*UserEmail 53 | resp, err := s.client.Do(ctx, req, &e) 54 | if err != nil { 55 | return nil, resp, err 56 | } 57 | 58 | return e, resp, nil 59 | } 60 | 61 | // DeleteEmails deletes email addresses from authenticated user. 62 | // 63 | // GitHub API docs: https://developer.github.com/v3/users/emails/#delete-email-addresses 64 | func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Response, error) { 65 | u := "user/emails" 66 | req, err := s.client.NewRequest("DELETE", u, emails) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | return s.client.Do(ctx, req, nil) 72 | } 73 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/packet/literal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "encoding/binary" 9 | "io" 10 | ) 11 | 12 | // LiteralData represents an encrypted file. See RFC 4880, section 5.9. 13 | type LiteralData struct { 14 | IsBinary bool 15 | FileName string 16 | Time uint32 // Unix epoch time. Either creation time or modification time. 0 means undefined. 17 | Body io.Reader 18 | } 19 | 20 | // ForEyesOnly returns whether the contents of the LiteralData have been marked 21 | // as especially sensitive. 22 | func (l *LiteralData) ForEyesOnly() bool { 23 | return l.FileName == "_CONSOLE" 24 | } 25 | 26 | func (l *LiteralData) parse(r io.Reader) (err error) { 27 | var buf [256]byte 28 | 29 | _, err = readFull(r, buf[:2]) 30 | if err != nil { 31 | return 32 | } 33 | 34 | l.IsBinary = buf[0] == 'b' 35 | fileNameLen := int(buf[1]) 36 | 37 | _, err = readFull(r, buf[:fileNameLen]) 38 | if err != nil { 39 | return 40 | } 41 | 42 | l.FileName = string(buf[:fileNameLen]) 43 | 44 | _, err = readFull(r, buf[:4]) 45 | if err != nil { 46 | return 47 | } 48 | 49 | l.Time = binary.BigEndian.Uint32(buf[:4]) 50 | l.Body = r 51 | return 52 | } 53 | 54 | // SerializeLiteral serializes a literal data packet to w and returns a 55 | // WriteCloser to which the data itself can be written and which MUST be closed 56 | // on completion. The fileName is truncated to 255 bytes. 57 | func SerializeLiteral(w io.WriteCloser, isBinary bool, fileName string, time uint32) (plaintext io.WriteCloser, err error) { 58 | var buf [4]byte 59 | buf[0] = 't' 60 | if isBinary { 61 | buf[0] = 'b' 62 | } 63 | if len(fileName) > 255 { 64 | fileName = fileName[:255] 65 | } 66 | buf[1] = byte(len(fileName)) 67 | 68 | inner, err := serializeStreamHeader(w, packetTypeLiteralData) 69 | if err != nil { 70 | return 71 | } 72 | 73 | _, err = inner.Write(buf[:2]) 74 | if err != nil { 75 | return 76 | } 77 | _, err = inner.Write([]byte(fileName)) 78 | if err != nil { 79 | return 80 | } 81 | binary.BigEndian.PutUint32(buf[:], time) 82 | _, err = inner.Write(buf[:]) 83 | if err != nil { 84 | return 85 | } 86 | 87 | plaintext = inner 88 | return 89 | } 90 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/repos_projects.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ProjectListOptions specifies the optional parameters to the 14 | // OrganizationsService.ListProjects and RepositoriesService.ListProjects methods. 15 | type ProjectListOptions struct { 16 | // Indicates the state of the projects to return. Can be either open, closed, or all. Default: open 17 | State string `url:"state,omitempty"` 18 | 19 | ListOptions 20 | } 21 | 22 | // ListProjects lists the projects for a repo. 23 | // 24 | // GitHub API docs: https://developer.github.com/v3/projects/#list-repository-projects 25 | func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opts *ProjectListOptions) ([]*Project, *Response, error) { 26 | u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) 27 | u, err := addOptions(u, opts) 28 | if err != nil { 29 | return nil, nil, err 30 | } 31 | 32 | req, err := s.client.NewRequest("GET", u, nil) 33 | if err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | // TODO: remove custom Accept headers when APIs fully launch. 38 | req.Header.Set("Accept", mediaTypeProjectsPreview) 39 | 40 | var projects []*Project 41 | resp, err := s.client.Do(ctx, req, &projects) 42 | if err != nil { 43 | return nil, resp, err 44 | } 45 | 46 | return projects, resp, nil 47 | } 48 | 49 | // CreateProject creates a GitHub Project for the specified repository. 50 | // 51 | // GitHub API docs: https://developer.github.com/v3/projects/#create-a-repository-project 52 | func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo string, opts *ProjectOptions) (*Project, *Response, error) { 53 | u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) 54 | req, err := s.client.NewRequest("POST", u, opts) 55 | if err != nil { 56 | return nil, nil, err 57 | } 58 | 59 | // TODO: remove custom Accept headers when APIs fully launch. 60 | req.Header.Set("Accept", mediaTypeProjectsPreview) 61 | 62 | project := &Project{} 63 | resp, err := s.client.Do(ctx, req, project) 64 | if err != nil { 65 | return nil, resp, err 66 | } 67 | 68 | return project, resp, nil 69 | } 70 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/brankas/emoji/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "encoding/json" 7 | "flag" 8 | "fmt" 9 | "go/format" 10 | "io/ioutil" 11 | "log" 12 | "net/http" 13 | "regexp" 14 | "strconv" 15 | "strings" 16 | 17 | . "github.com/brankas/emoji" 18 | ) 19 | 20 | const ( 21 | gemojiURL = "https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json" 22 | ) 23 | 24 | var ( 25 | flagOut = flag.String("o", "gemoji_data.go", "out") 26 | ) 27 | 28 | func main() { 29 | var err error 30 | 31 | flag.Parse() 32 | 33 | // generate data 34 | buf, err := generate() 35 | if err != nil { 36 | log.Fatal(err) 37 | } 38 | 39 | // write 40 | err = ioutil.WriteFile(*flagOut, buf, 0644) 41 | if err != nil { 42 | log.Fatal(err) 43 | } 44 | } 45 | 46 | var replacer = strings.NewReplacer( 47 | "emoji.Gemoji", "Gemoji", 48 | "emoji.Emoji", "\n", 49 | "}}", "},\n}", 50 | ", Description:", ", ", 51 | ", Category:", ", ", 52 | ", Aliases:", ", ", 53 | ", Tags:", ", ", 54 | ", UnicodeVersion:", ", ", 55 | ", IOSVersion:", ", ", 56 | ) 57 | 58 | var emojiRE = regexp.MustCompile(`\{Emoji:"([^"]*)"`) 59 | 60 | func generate() ([]byte, error) { 61 | var err error 62 | 63 | // load gemoji data 64 | res, err := http.Get(gemojiURL) 65 | if err != nil { 66 | return nil, err 67 | } 68 | defer res.Body.Close() 69 | 70 | // read all 71 | body, err := ioutil.ReadAll(res.Body) 72 | if err != nil { 73 | return nil, err 74 | } 75 | 76 | // unmarshal 77 | var data Gemoji 78 | err = json.Unmarshal(body, &data) 79 | if err != nil { 80 | return nil, err 81 | } 82 | 83 | // add header 84 | str := replacer.Replace(fmt.Sprintf(hdr, gemojiURL, data)) 85 | 86 | // change the format of the unicode string 87 | str = emojiRE.ReplaceAllStringFunc(str, func(s string) string { 88 | var err error 89 | s, err = strconv.Unquote(s[len("{Emoji:"):]) 90 | if err != nil { 91 | panic(err) 92 | } 93 | return "{" + strconv.QuoteToASCII(s) 94 | }) 95 | 96 | // format 97 | return format.Source([]byte(str)) 98 | } 99 | 100 | const hdr = ` 101 | package emoji 102 | 103 | // Code generated by gen.go. DO NOT EDIT. 104 | 105 | // GemojiData is the original Gemoji data. 106 | // 107 | // see: %s 108 | var GemojiData = %#v 109 | ` 110 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/git_blobs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "bytes" 10 | "context" 11 | "fmt" 12 | ) 13 | 14 | // Blob represents a blob object. 15 | type Blob struct { 16 | Content *string `json:"content,omitempty"` 17 | Encoding *string `json:"encoding,omitempty"` 18 | SHA *string `json:"sha,omitempty"` 19 | Size *int `json:"size,omitempty"` 20 | URL *string `json:"url,omitempty"` 21 | NodeID *string `json:"node_id,omitempty"` 22 | } 23 | 24 | // GetBlob fetches a blob from a repo given a SHA. 25 | // 26 | // GitHub API docs: https://developer.github.com/v3/git/blobs/#get-a-blob 27 | func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) { 28 | u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha) 29 | req, err := s.client.NewRequest("GET", u, nil) 30 | if err != nil { 31 | return nil, nil, err 32 | } 33 | 34 | blob := new(Blob) 35 | resp, err := s.client.Do(ctx, req, blob) 36 | return blob, resp, err 37 | } 38 | 39 | // GetBlobRaw fetches a blob's contents from a repo. 40 | // Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/git/blobs/#get-a-blob 43 | func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) { 44 | u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha) 45 | req, err := s.client.NewRequest("GET", u, nil) 46 | if err != nil { 47 | return nil, nil, err 48 | } 49 | req.Header.Set("Accept", "application/vnd.github.v3.raw") 50 | 51 | var buf bytes.Buffer 52 | resp, err := s.client.Do(ctx, req, &buf) 53 | return buf.Bytes(), resp, err 54 | } 55 | 56 | // CreateBlob creates a blob object. 57 | // 58 | // GitHub API docs: https://developer.github.com/v3/git/blobs/#create-a-blob 59 | func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) { 60 | u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo) 61 | req, err := s.client.NewRequest("POST", u, blob) 62 | if err != nil { 63 | return nil, nil, err 64 | } 65 | 66 | t := new(Blob) 67 | resp, err := s.client.Do(ctx, req, t) 68 | return t, resp, err 69 | } 70 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/packet/reader.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "golang.org/x/crypto/openpgp/errors" 9 | "io" 10 | ) 11 | 12 | // Reader reads packets from an io.Reader and allows packets to be 'unread' so 13 | // that they result from the next call to Next. 14 | type Reader struct { 15 | q []Packet 16 | readers []io.Reader 17 | } 18 | 19 | // New io.Readers are pushed when a compressed or encrypted packet is processed 20 | // and recursively treated as a new source of packets. However, a carefully 21 | // crafted packet can trigger an infinite recursive sequence of packets. See 22 | // http://mumble.net/~campbell/misc/pgp-quine 23 | // https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-4402 24 | // This constant limits the number of recursive packets that may be pushed. 25 | const maxReaders = 32 26 | 27 | // Next returns the most recently unread Packet, or reads another packet from 28 | // the top-most io.Reader. Unknown packet types are skipped. 29 | func (r *Reader) Next() (p Packet, err error) { 30 | if len(r.q) > 0 { 31 | p = r.q[len(r.q)-1] 32 | r.q = r.q[:len(r.q)-1] 33 | return 34 | } 35 | 36 | for len(r.readers) > 0 { 37 | p, err = Read(r.readers[len(r.readers)-1]) 38 | if err == nil { 39 | return 40 | } 41 | if err == io.EOF { 42 | r.readers = r.readers[:len(r.readers)-1] 43 | continue 44 | } 45 | if _, ok := err.(errors.UnknownPacketTypeError); !ok { 46 | return nil, err 47 | } 48 | } 49 | 50 | return nil, io.EOF 51 | } 52 | 53 | // Push causes the Reader to start reading from a new io.Reader. When an EOF 54 | // error is seen from the new io.Reader, it is popped and the Reader continues 55 | // to read from the next most recent io.Reader. Push returns a StructuralError 56 | // if pushing the reader would exceed the maximum recursion level, otherwise it 57 | // returns nil. 58 | func (r *Reader) Push(reader io.Reader) (err error) { 59 | if len(r.readers) >= maxReaders { 60 | return errors.StructuralError("too many layers of packets") 61 | } 62 | r.readers = append(r.readers, reader) 63 | return nil 64 | } 65 | 66 | // Unread causes the given Packet to be returned from the next call to Next. 67 | func (r *Reader) Unread(p Packet) { 68 | r.q = append(r.q, p) 69 | } 70 | 71 | func NewReader(r io.Reader) *Reader { 72 | return &Reader{ 73 | q: nil, 74 | readers: []io.Reader{r}, 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/users_administration.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // PromoteSiteAdmin promotes a user to a site administrator of a GitHub Enterprise instance. 14 | // 15 | // GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#promote-an-ordinary-user-to-a-site-administrator 16 | func (s *UsersService) PromoteSiteAdmin(ctx context.Context, user string) (*Response, error) { 17 | u := fmt.Sprintf("users/%v/site_admin", user) 18 | 19 | req, err := s.client.NewRequest("PUT", u, nil) 20 | if err != nil { 21 | return nil, err 22 | } 23 | 24 | return s.client.Do(ctx, req, nil) 25 | } 26 | 27 | // DemoteSiteAdmin demotes a user from site administrator of a GitHub Enterprise instance. 28 | // 29 | // GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#demote-a-site-administrator-to-an-ordinary-user 30 | func (s *UsersService) DemoteSiteAdmin(ctx context.Context, user string) (*Response, error) { 31 | u := fmt.Sprintf("users/%v/site_admin", user) 32 | 33 | req, err := s.client.NewRequest("DELETE", u, nil) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return s.client.Do(ctx, req, nil) 39 | } 40 | 41 | // UserSuspendOptions represents the reason a user is being suspended. 42 | type UserSuspendOptions struct { 43 | Reason *string `json:"reason,omitempty"` 44 | } 45 | 46 | // Suspend a user on a GitHub Enterprise instance. 47 | // 48 | // GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#suspend-a-user 49 | func (s *UsersService) Suspend(ctx context.Context, user string, opts *UserSuspendOptions) (*Response, error) { 50 | u := fmt.Sprintf("users/%v/suspended", user) 51 | 52 | req, err := s.client.NewRequest("PUT", u, opts) 53 | if err != nil { 54 | return nil, err 55 | } 56 | 57 | return s.client.Do(ctx, req, nil) 58 | } 59 | 60 | // Unsuspend a user on a GitHub Enterprise instance. 61 | // 62 | // GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#unsuspend-a-user 63 | func (s *UsersService) Unsuspend(ctx context.Context, user string) (*Response, error) { 64 | u := fmt.Sprintf("users/%v/suspended", user) 65 | 66 | req, err := s.client.NewRequest("DELETE", u, nil) 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | return s.client.Do(ctx, req, nil) 72 | } 73 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/.travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | client_configure() { 6 | sudo chmod 600 $PQSSLCERTTEST_PATH/postgresql.key 7 | } 8 | 9 | pgdg_repository() { 10 | local sourcelist='sources.list.d/postgresql.list' 11 | 12 | curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | sudo apt-key add - 13 | echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION | sudo tee "/etc/apt/$sourcelist" 14 | sudo apt-get -o Dir::Etc::sourcelist="$sourcelist" -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' update 15 | } 16 | 17 | postgresql_configure() { 18 | sudo tee /etc/postgresql/$PGVERSION/main/pg_hba.conf > /dev/null <<-config 19 | local all all trust 20 | hostnossl all pqgossltest 127.0.0.1/32 reject 21 | hostnossl all pqgosslcert 127.0.0.1/32 reject 22 | hostssl all pqgossltest 127.0.0.1/32 trust 23 | hostssl all pqgosslcert 127.0.0.1/32 cert 24 | host all all 127.0.0.1/32 trust 25 | hostnossl all pqgossltest ::1/128 reject 26 | hostnossl all pqgosslcert ::1/128 reject 27 | hostssl all pqgossltest ::1/128 trust 28 | hostssl all pqgosslcert ::1/128 cert 29 | host all all ::1/128 trust 30 | config 31 | 32 | xargs sudo install -o postgres -g postgres -m 600 -t /var/lib/postgresql/$PGVERSION/main/ <<-certificates 33 | certs/root.crt 34 | certs/server.crt 35 | certs/server.key 36 | certificates 37 | 38 | sort -VCu <<-versions || 39 | $PGVERSION 40 | 9.2 41 | versions 42 | sudo tee -a /etc/postgresql/$PGVERSION/main/postgresql.conf > /dev/null <<-config 43 | ssl_ca_file = 'root.crt' 44 | ssl_cert_file = 'server.crt' 45 | ssl_key_file = 'server.key' 46 | config 47 | 48 | echo 127.0.0.1 postgres | sudo tee -a /etc/hosts > /dev/null 49 | 50 | sudo service postgresql restart 51 | } 52 | 53 | postgresql_install() { 54 | xargs sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew' install <<-packages 55 | postgresql-$PGVERSION 56 | postgresql-server-dev-$PGVERSION 57 | postgresql-contrib-$PGVERSION 58 | packages 59 | } 60 | 61 | postgresql_uninstall() { 62 | sudo service postgresql stop 63 | xargs sudo apt-get -y --purge remove <<-packages 64 | libpq-dev 65 | libpq5 66 | postgresql 67 | postgresql-client-common 68 | postgresql-common 69 | packages 70 | sudo rm -rf /var/lib/postgresql 71 | } 72 | 73 | $1 74 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/.travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | client_configure() { 6 | sudo chmod 600 $PQSSLCERTTEST_PATH/postgresql.key 7 | } 8 | 9 | pgdg_repository() { 10 | local sourcelist='sources.list.d/postgresql.list' 11 | 12 | curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | sudo apt-key add - 13 | echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION | sudo tee "/etc/apt/$sourcelist" 14 | sudo apt-get -o Dir::Etc::sourcelist="$sourcelist" -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' update 15 | } 16 | 17 | postgresql_configure() { 18 | sudo tee /etc/postgresql/$PGVERSION/main/pg_hba.conf > /dev/null <<-config 19 | local all all trust 20 | hostnossl all pqgossltest 127.0.0.1/32 reject 21 | hostnossl all pqgosslcert 127.0.0.1/32 reject 22 | hostssl all pqgossltest 127.0.0.1/32 trust 23 | hostssl all pqgosslcert 127.0.0.1/32 cert 24 | host all all 127.0.0.1/32 trust 25 | hostnossl all pqgossltest ::1/128 reject 26 | hostnossl all pqgosslcert ::1/128 reject 27 | hostssl all pqgossltest ::1/128 trust 28 | hostssl all pqgosslcert ::1/128 cert 29 | host all all ::1/128 trust 30 | config 31 | 32 | xargs sudo install -o postgres -g postgres -m 600 -t /var/lib/postgresql/$PGVERSION/main/ <<-certificates 33 | certs/root.crt 34 | certs/server.crt 35 | certs/server.key 36 | certificates 37 | 38 | sort -VCu <<-versions || 39 | $PGVERSION 40 | 9.2 41 | versions 42 | sudo tee -a /etc/postgresql/$PGVERSION/main/postgresql.conf > /dev/null <<-config 43 | ssl_ca_file = 'root.crt' 44 | ssl_cert_file = 'server.crt' 45 | ssl_key_file = 'server.key' 46 | config 47 | 48 | echo 127.0.0.1 postgres | sudo tee -a /etc/hosts > /dev/null 49 | 50 | sudo service postgresql restart 51 | } 52 | 53 | postgresql_install() { 54 | xargs sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew' install <<-packages 55 | postgresql-$PGVERSION 56 | postgresql-server-dev-$PGVERSION 57 | postgresql-contrib-$PGVERSION 58 | packages 59 | } 60 | 61 | postgresql_uninstall() { 62 | sudo service postgresql stop 63 | xargs sudo apt-get -y --purge remove <<-packages 64 | libpq-dev 65 | libpq5 66 | postgresql 67 | postgresql-client-common 68 | postgresql-common 69 | packages 70 | sudo rm -rf /var/lib/postgresql 71 | } 72 | 73 | $1 74 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/events_scm.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // PushEventRepository represents the repository from a push event 4 | type PushEventRepository struct { 5 | Name string `json:"name"` 6 | FullName string `json:"full_name"` 7 | CloneURL string `json:"clone_url"` 8 | Private bool `json:"private"` 9 | ID int64 `json:"id"` 10 | RepositoryURL string `json:"url"` 11 | 12 | Owner Owner `json:"owner"` 13 | } 14 | 15 | // PushEvent is received from GitHub's push event subscription 16 | type PushEvent struct { 17 | Ref string `json:"ref"` 18 | Repository PushEventRepository 19 | AfterCommitID string `json:"after"` 20 | Installation PushEventInstallation 21 | SCM string // SCM field is for internal use and not provided by GitHub 22 | } 23 | 24 | // Owner is the owner of a GitHub repo 25 | type Owner struct { 26 | Login string `json:"login"` 27 | Email string `json:"email"` 28 | ID int64 `json:"id"` 29 | } 30 | 31 | type PushEventInstallation struct { 32 | ID int `json:"id"` 33 | } 34 | 35 | // GitLabPushEvent as received from GitLab's system hook event 36 | type GitLabPushEvent struct { 37 | Ref string `json:"ref"` 38 | UserUsername string `json:"user_username"` 39 | UserEmail string `json:"user_email"` 40 | GitLabProject GitLabProject `json:"project"` 41 | GitLabRepository GitLabRepository `json:"repository"` 42 | AfterCommitID string `json:"after"` 43 | } 44 | 45 | type GitLabProject struct { 46 | ID int `json:"id"` 47 | Namespace string `json:"namespace"` 48 | Name string `json:"name"` 49 | PathWithNamespace string `json:"path_with_namespace"` //would be repo full name 50 | WebURL string `json:"web_url"` 51 | VisibilityLevel int `json:"visibility_level"` 52 | } 53 | 54 | type GitLabRepository struct { 55 | CloneURL string `json:"git_http_url"` 56 | } 57 | 58 | type Customer struct { 59 | Sender Sender `json:"sender"` 60 | } 61 | 62 | type Sender struct { 63 | Login string `json:"login"` 64 | } 65 | 66 | type InstallationRepositoriesEvent struct { 67 | Action string `json:"action"` 68 | Installation struct { 69 | Account struct { 70 | Login string 71 | } 72 | } `json:"installation"` 73 | RepositoriesRemoved []Installation `json:"repositories_removed"` 74 | RepositoriesAdded []Installation `json:"repositories_added"` 75 | Repositories []Installation `json:"repositories"` 76 | } 77 | 78 | type Installation struct { 79 | Name string `json:"name"` 80 | FullName string `json:"full_name"` 81 | } 82 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/events_scm.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | // PushEventRepository represents the repository from a push event 4 | type PushEventRepository struct { 5 | Name string `json:"name"` 6 | FullName string `json:"full_name"` 7 | CloneURL string `json:"clone_url"` 8 | Private bool `json:"private"` 9 | ID int64 `json:"id"` 10 | RepositoryURL string `json:"url"` 11 | 12 | Owner Owner `json:"owner"` 13 | } 14 | 15 | // PushEvent is received from GitHub's push event subscription 16 | type PushEvent struct { 17 | Ref string `json:"ref"` 18 | Repository PushEventRepository 19 | AfterCommitID string `json:"after"` 20 | Installation PushEventInstallation 21 | SCM string // SCM field is for internal use and not provided by GitHub 22 | } 23 | 24 | // Owner is the owner of a GitHub repo 25 | type Owner struct { 26 | Login string `json:"login"` 27 | Email string `json:"email"` 28 | ID int64 `json:"id"` 29 | } 30 | 31 | type PushEventInstallation struct { 32 | ID int `json:"id"` 33 | } 34 | 35 | // GitLabPushEvent as received from GitLab's system hook event 36 | type GitLabPushEvent struct { 37 | Ref string `json:"ref"` 38 | UserUsername string `json:"user_username"` 39 | UserEmail string `json:"user_email"` 40 | GitLabProject GitLabProject `json:"project"` 41 | GitLabRepository GitLabRepository `json:"repository"` 42 | AfterCommitID string `json:"after"` 43 | } 44 | 45 | type GitLabProject struct { 46 | ID int `json:"id"` 47 | Namespace string `json:"namespace"` 48 | Name string `json:"name"` 49 | PathWithNamespace string `json:"path_with_namespace"` //would be repo full name 50 | WebURL string `json:"web_url"` 51 | VisibilityLevel int `json:"visibility_level"` 52 | } 53 | 54 | type GitLabRepository struct { 55 | CloneURL string `json:"git_http_url"` 56 | } 57 | 58 | type Customer struct { 59 | Sender Sender `json:"sender"` 60 | } 61 | 62 | type Sender struct { 63 | Login string `json:"login"` 64 | } 65 | 66 | type InstallationRepositoriesEvent struct { 67 | Action string `json:"action"` 68 | Installation struct { 69 | Account struct { 70 | Login string 71 | } 72 | } `json:"installation"` 73 | RepositoriesRemoved []Installation `json:"repositories_removed"` 74 | RepositoriesAdded []Installation `json:"repositories_added"` 75 | Repositories []Installation `json:"repositories"` 76 | } 77 | 78 | type Installation struct { 79 | Name string `json:"name"` 80 | FullName string `json:"full_name"` 81 | } 82 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/git_tags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Tag represents a tag object. 14 | type Tag struct { 15 | Tag *string `json:"tag,omitempty"` 16 | SHA *string `json:"sha,omitempty"` 17 | URL *string `json:"url,omitempty"` 18 | Message *string `json:"message,omitempty"` 19 | Tagger *CommitAuthor `json:"tagger,omitempty"` 20 | Object *GitObject `json:"object,omitempty"` 21 | Verification *SignatureVerification `json:"verification,omitempty"` 22 | NodeID *string `json:"node_id,omitempty"` 23 | } 24 | 25 | // createTagRequest represents the body of a CreateTag request. This is mostly 26 | // identical to Tag with the exception that the object SHA and Type are 27 | // top-level fields, rather than being nested inside a JSON object. 28 | type createTagRequest struct { 29 | Tag *string `json:"tag,omitempty"` 30 | Message *string `json:"message,omitempty"` 31 | Object *string `json:"object,omitempty"` 32 | Type *string `json:"type,omitempty"` 33 | Tagger *CommitAuthor `json:"tagger,omitempty"` 34 | } 35 | 36 | // GetTag fetches a tag from a repo given a SHA. 37 | // 38 | // GitHub API docs: https://developer.github.com/v3/git/tags/#get-a-tag 39 | func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) { 40 | u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha) 41 | req, err := s.client.NewRequest("GET", u, nil) 42 | if err != nil { 43 | return nil, nil, err 44 | } 45 | 46 | tag := new(Tag) 47 | resp, err := s.client.Do(ctx, req, tag) 48 | return tag, resp, err 49 | } 50 | 51 | // CreateTag creates a tag object. 52 | // 53 | // GitHub API docs: https://developer.github.com/v3/git/tags/#create-a-tag-object 54 | func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) { 55 | u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo) 56 | 57 | // convert Tag into a createTagRequest 58 | tagRequest := &createTagRequest{ 59 | Tag: tag.Tag, 60 | Message: tag.Message, 61 | Tagger: tag.Tagger, 62 | } 63 | if tag.Object != nil { 64 | tagRequest.Object = tag.Object.SHA 65 | tagRequest.Type = tag.Object.Type 66 | } 67 | 68 | req, err := s.client.NewRequest("POST", u, tagRequest) 69 | if err != nil { 70 | return nil, nil, err 71 | } 72 | 73 | t := new(Tag) 74 | resp, err := s.client.Do(ctx, req, t) 75 | return t, resp, err 76 | } 77 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/rows.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "math" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/lib/pq/oid" 9 | ) 10 | 11 | const headerSize = 4 12 | 13 | type fieldDesc struct { 14 | // The object ID of the data type. 15 | OID oid.Oid 16 | // The data type size (see pg_type.typlen). 17 | // Note that negative values denote variable-width types. 18 | Len int 19 | // The type modifier (see pg_attribute.atttypmod). 20 | // The meaning of the modifier is type-specific. 21 | Mod int 22 | } 23 | 24 | func (fd fieldDesc) Type() reflect.Type { 25 | switch fd.OID { 26 | case oid.T_int8: 27 | return reflect.TypeOf(int64(0)) 28 | case oid.T_int4: 29 | return reflect.TypeOf(int32(0)) 30 | case oid.T_int2: 31 | return reflect.TypeOf(int16(0)) 32 | case oid.T_varchar, oid.T_text: 33 | return reflect.TypeOf("") 34 | case oid.T_bool: 35 | return reflect.TypeOf(false) 36 | case oid.T_date, oid.T_time, oid.T_timetz, oid.T_timestamp, oid.T_timestamptz: 37 | return reflect.TypeOf(time.Time{}) 38 | case oid.T_bytea: 39 | return reflect.TypeOf([]byte(nil)) 40 | default: 41 | return reflect.TypeOf(new(interface{})).Elem() 42 | } 43 | } 44 | 45 | func (fd fieldDesc) Name() string { 46 | return oid.TypeName[fd.OID] 47 | } 48 | 49 | func (fd fieldDesc) Length() (length int64, ok bool) { 50 | switch fd.OID { 51 | case oid.T_text, oid.T_bytea: 52 | return math.MaxInt64, true 53 | case oid.T_varchar, oid.T_bpchar: 54 | return int64(fd.Mod - headerSize), true 55 | default: 56 | return 0, false 57 | } 58 | } 59 | 60 | func (fd fieldDesc) PrecisionScale() (precision, scale int64, ok bool) { 61 | switch fd.OID { 62 | case oid.T_numeric, oid.T__numeric: 63 | mod := fd.Mod - headerSize 64 | precision = int64((mod >> 16) & 0xffff) 65 | scale = int64(mod & 0xffff) 66 | return precision, scale, true 67 | default: 68 | return 0, 0, false 69 | } 70 | } 71 | 72 | // ColumnTypeScanType returns the value type that can be used to scan types into. 73 | func (rs *rows) ColumnTypeScanType(index int) reflect.Type { 74 | return rs.colTyps[index].Type() 75 | } 76 | 77 | // ColumnTypeDatabaseTypeName return the database system type name. 78 | func (rs *rows) ColumnTypeDatabaseTypeName(index int) string { 79 | return rs.colTyps[index].Name() 80 | } 81 | 82 | // ColumnTypeLength returns the length of the column type if the column is a 83 | // variable length type. If the column is not a variable length type ok 84 | // should return false. 85 | func (rs *rows) ColumnTypeLength(index int) (length int64, ok bool) { 86 | return rs.colTyps[index].Length() 87 | } 88 | 89 | // ColumnTypePrecisionScale should return the precision and scale for decimal 90 | // types. If not applicable, ok should be false. 91 | func (rs *rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { 92 | return rs.colTyps[index].PrecisionScale() 93 | } 94 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/rows.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "math" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/lib/pq/oid" 9 | ) 10 | 11 | const headerSize = 4 12 | 13 | type fieldDesc struct { 14 | // The object ID of the data type. 15 | OID oid.Oid 16 | // The data type size (see pg_type.typlen). 17 | // Note that negative values denote variable-width types. 18 | Len int 19 | // The type modifier (see pg_attribute.atttypmod). 20 | // The meaning of the modifier is type-specific. 21 | Mod int 22 | } 23 | 24 | func (fd fieldDesc) Type() reflect.Type { 25 | switch fd.OID { 26 | case oid.T_int8: 27 | return reflect.TypeOf(int64(0)) 28 | case oid.T_int4: 29 | return reflect.TypeOf(int32(0)) 30 | case oid.T_int2: 31 | return reflect.TypeOf(int16(0)) 32 | case oid.T_varchar, oid.T_text: 33 | return reflect.TypeOf("") 34 | case oid.T_bool: 35 | return reflect.TypeOf(false) 36 | case oid.T_date, oid.T_time, oid.T_timetz, oid.T_timestamp, oid.T_timestamptz: 37 | return reflect.TypeOf(time.Time{}) 38 | case oid.T_bytea: 39 | return reflect.TypeOf([]byte(nil)) 40 | default: 41 | return reflect.TypeOf(new(interface{})).Elem() 42 | } 43 | } 44 | 45 | func (fd fieldDesc) Name() string { 46 | return oid.TypeName[fd.OID] 47 | } 48 | 49 | func (fd fieldDesc) Length() (length int64, ok bool) { 50 | switch fd.OID { 51 | case oid.T_text, oid.T_bytea: 52 | return math.MaxInt64, true 53 | case oid.T_varchar, oid.T_bpchar: 54 | return int64(fd.Mod - headerSize), true 55 | default: 56 | return 0, false 57 | } 58 | } 59 | 60 | func (fd fieldDesc) PrecisionScale() (precision, scale int64, ok bool) { 61 | switch fd.OID { 62 | case oid.T_numeric, oid.T__numeric: 63 | mod := fd.Mod - headerSize 64 | precision = int64((mod >> 16) & 0xffff) 65 | scale = int64(mod & 0xffff) 66 | return precision, scale, true 67 | default: 68 | return 0, 0, false 69 | } 70 | } 71 | 72 | // ColumnTypeScanType returns the value type that can be used to scan types into. 73 | func (rs *rows) ColumnTypeScanType(index int) reflect.Type { 74 | return rs.colTyps[index].Type() 75 | } 76 | 77 | // ColumnTypeDatabaseTypeName return the database system type name. 78 | func (rs *rows) ColumnTypeDatabaseTypeName(index int) string { 79 | return rs.colTyps[index].Name() 80 | } 81 | 82 | // ColumnTypeLength returns the length of the column type if the column is a 83 | // variable length type. If the column is not a variable length type ok 84 | // should return false. 85 | func (rs *rows) ColumnTypeLength(index int) (length int64, ok bool) { 86 | return rs.colTyps[index].Length() 87 | } 88 | 89 | // ColumnTypePrecisionScale should return the precision and scale for decimal 90 | // types. If not applicable, ok should be false. 91 | func (rs *rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { 92 | return rs.colTyps[index].PrecisionScale() 93 | } 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## comment-vibes 2 | 3 | This is a serverless CRUD sample project with Postgres and GitHub emoji integration. You can use it to tally up the emojis used in various comments across your GitHub projects. 4 | 5 | ## Kubernetes / Serverless example project 6 | 7 | This sample uses the OpenFaaS [golang-middleware](https://github.com/openfaas-incubator/golang-http-template/) template and three endpoints: 8 | 9 | * view - to render a HTML template (server-side) 10 | * import-comment - to receive and validate the webhook, then update postgres 11 | * comments - to render JSON from a postgres function 12 | 13 | You can see the results in the demo below. Feel free to try it out, if the endpoint is still up. 14 | 15 | The code is adapted from the [Serverless Single Page App - aka Open Source leaderboard](https://github.com/alexellis/leaderboard-app/) 16 | 17 | ## Demo 18 | 19 | Example output view the `/view` function: 20 | 21 | ![Example screenshot](docs/example.png) 22 | 23 | Example input from a GitHub issue and webhook: 24 | 25 | ![Example comments](docs/comments.png) 26 | 27 | [Tester issue](https://github.com/teamserverless/proposals/issues/1) 28 | 29 | ## Create a postgres DB 30 | 31 | You can use [DigitalOcean](https://digitalocean.com) managed Postgres for example. 32 | 33 | ## Populate it with the schema 34 | 35 | ``` 36 | psql postgresql://connection-string here 37 | ``` 38 | 39 | Paste in [schema.sql](schema.sql) 40 | 41 | ## Create your secrets: 42 | 43 | ```bash 44 | export USERNAME="" 45 | export PASSWORD="" 46 | export HOST="" 47 | export WEBHOOK_SECRET="" 48 | 49 | faas-cli secret create username --from-literal $USERNAME 50 | faas-cli secret create password --from-literal $PASSWORD 51 | faas-cli secret create host --from-literal $HOST 52 | faas-cli secret create webhook-secret --from-literal $WEBHOOK_SECRET 53 | ``` 54 | 55 | ## Deploy to OpenFaaS (Intel) 56 | 57 | ``` 58 | # Get the additional template 59 | faas-cli template store pull golang-middleware 60 | 61 | # Deploy 62 | 63 | faas-cli deploy 64 | ``` 65 | 66 | ## Rebuild and deploy (Intel and ARM) 67 | 68 | ``` 69 | sed -i stack.yml s/alexellis2/your-docker-hub/g 70 | export DOCKER_BUILDKIT=1 71 | 72 | faas-cli up --tag=sha 73 | ``` 74 | 75 | ## Setup GitHub webhooks 76 | 77 | Go to Settings for your repo and click "Webhooks" 78 | 79 | Add a webhook 80 | 81 | ![webhook](docs/webhook.png) 82 | 83 | Pick only the issue comments event, there is no issue for reactions at this time. 84 | 85 | ![tick](docs/tick.png) 86 | 87 | Now have someone send a comment to one of the issues in your repo with an emoji i.e. 👍 88 | 89 | If you need to create a HTTP tunnel to your local computer, try [inlets and inletsctl](https://docs.inlets.dev/) 90 | 91 | View the result on the `/view` function. 92 | 93 | ## Crossplane instructions 94 | 95 | If you are using [Crossplane](https://crossplane.io/) to get yourself a Postgresql DB: [start here](crossplane.md) 96 | -------------------------------------------------------------------------------- /comments/vendor/github.com/openfaas/openfaas-cloud/sdk/url_builders.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "strings" 7 | ) 8 | 9 | const ( 10 | SystemSubdomain = "system" 11 | ) 12 | 13 | // FormatEndpointURL takes the gateway_public_url environmental 14 | // variable along with event object to format URL which points to 15 | // the function endpoint 16 | func FormatEndpointURL(gatewayURL string, event *Event) (string, error) { 17 | systemURL, formatErr := FormatSystemURL(gatewayURL) 18 | if formatErr != nil { 19 | return "", fmt.Errorf("error while formattig endpoint URL: %s", formatErr.Error()) 20 | } 21 | personalURL := strings.Replace(systemURL, SystemSubdomain, event.Owner, -1) 22 | 23 | return fmt.Sprintf("%s/%s", personalURL, event.Service), nil 24 | } 25 | 26 | // FormatDashboardURL takes the environmental variable 27 | // gateway_public_url and event object and formats 28 | // the URL to point to the dashboard 29 | func FormatDashboardURL(gatewayURL string, event *Event) (string, error) { 30 | systemURL, formatErr := FormatSystemURL(gatewayURL) 31 | if formatErr != nil { 32 | return "", fmt.Errorf("error while formatting dashboard URL: %s", formatErr.Error()) 33 | } 34 | 35 | return fmt.Sprintf("%s/dashboard/%s", systemURL, event.Owner), nil 36 | } 37 | 38 | // GetSubdomain gets the subdomain of the URL 39 | // for example the subdomain of www.o6s.io 40 | // would be www 41 | func GetSubdomain(URL string) (string, error) { 42 | parsedURL, parseErr := url.Parse(URL) 43 | if parseErr != nil { 44 | return "", fmt.Errorf("Unable to parse URL: %s", parseErr.Error()) 45 | } 46 | subdomain := strings.Split(parsedURL.Host, ".") 47 | 48 | //Host is www.world.org and subdomain would be www aka. 0th element of the slice 49 | return subdomain[0], nil 50 | } 51 | 52 | // FormatSystemURL formats the system URL which points to the 53 | // edge-router with the gateway_public_url environmental variable 54 | func FormatSystemURL(gatewayURL string) (string, error) { 55 | if strings.HasSuffix(gatewayURL, "/") { 56 | gatewayURL = strings.TrimSuffix(gatewayURL, "/") 57 | } 58 | subdomain, err := GetSubdomain(gatewayURL) 59 | if err != nil { 60 | return "", fmt.Errorf("error while geting subdomain for system URL: %s", err) 61 | } 62 | systemURL := strings.Replace(gatewayURL, subdomain, SystemSubdomain, -1) 63 | return systemURL, nil 64 | } 65 | 66 | // FormatLogsURL formats the URL where function logs are stored with 67 | // the gateway_public_url environmental variable and event object 68 | func FormatLogsURL(gatewayURL string, event *Event) (string, error) { 69 | systemURL, formatErr := FormatSystemURL(gatewayURL) 70 | if formatErr != nil { 71 | return "", fmt.Errorf("error while formatting logs URL: %s", formatErr.Error()) 72 | } 73 | 74 | return fmt.Sprintf("%s/dashboard/%s/%s/log?repoPath=%s/%s&commitSHA=%s", 75 | systemURL, event.Owner, event.Service, event.Owner, event.Repository, event.SHA), nil 76 | } 77 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/openfaas/openfaas-cloud/sdk/url_builders.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "strings" 7 | ) 8 | 9 | const ( 10 | SystemSubdomain = "system" 11 | ) 12 | 13 | // FormatEndpointURL takes the gateway_public_url environmental 14 | // variable along with event object to format URL which points to 15 | // the function endpoint 16 | func FormatEndpointURL(gatewayURL string, event *Event) (string, error) { 17 | systemURL, formatErr := FormatSystemURL(gatewayURL) 18 | if formatErr != nil { 19 | return "", fmt.Errorf("error while formattig endpoint URL: %s", formatErr.Error()) 20 | } 21 | personalURL := strings.Replace(systemURL, SystemSubdomain, event.Owner, -1) 22 | 23 | return fmt.Sprintf("%s/%s", personalURL, event.Service), nil 24 | } 25 | 26 | // FormatDashboardURL takes the environmental variable 27 | // gateway_public_url and event object and formats 28 | // the URL to point to the dashboard 29 | func FormatDashboardURL(gatewayURL string, event *Event) (string, error) { 30 | systemURL, formatErr := FormatSystemURL(gatewayURL) 31 | if formatErr != nil { 32 | return "", fmt.Errorf("error while formatting dashboard URL: %s", formatErr.Error()) 33 | } 34 | 35 | return fmt.Sprintf("%s/dashboard/%s", systemURL, event.Owner), nil 36 | } 37 | 38 | // GetSubdomain gets the subdomain of the URL 39 | // for example the subdomain of www.o6s.io 40 | // would be www 41 | func GetSubdomain(URL string) (string, error) { 42 | parsedURL, parseErr := url.Parse(URL) 43 | if parseErr != nil { 44 | return "", fmt.Errorf("Unable to parse URL: %s", parseErr.Error()) 45 | } 46 | subdomain := strings.Split(parsedURL.Host, ".") 47 | 48 | //Host is www.world.org and subdomain would be www aka. 0th element of the slice 49 | return subdomain[0], nil 50 | } 51 | 52 | // FormatSystemURL formats the system URL which points to the 53 | // edge-router with the gateway_public_url environmental variable 54 | func FormatSystemURL(gatewayURL string) (string, error) { 55 | if strings.HasSuffix(gatewayURL, "/") { 56 | gatewayURL = strings.TrimSuffix(gatewayURL, "/") 57 | } 58 | subdomain, err := GetSubdomain(gatewayURL) 59 | if err != nil { 60 | return "", fmt.Errorf("error while geting subdomain for system URL: %s", err) 61 | } 62 | systemURL := strings.Replace(gatewayURL, subdomain, SystemSubdomain, -1) 63 | return systemURL, nil 64 | } 65 | 66 | // FormatLogsURL formats the URL where function logs are stored with 67 | // the gateway_public_url environmental variable and event object 68 | func FormatLogsURL(gatewayURL string, event *Event) (string, error) { 69 | systemURL, formatErr := FormatSystemURL(gatewayURL) 70 | if formatErr != nil { 71 | return "", fmt.Errorf("error while formatting logs URL: %s", formatErr.Error()) 72 | } 73 | 74 | return fmt.Sprintf("%s/dashboard/%s/%s/log?repoPath=%s/%s&commitSHA=%s", 75 | systemURL, event.Owner, event.Service, event.Owner, event.Repository, event.SHA), nil 76 | } 77 | -------------------------------------------------------------------------------- /comments/vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Roadmap 45 | 46 | With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: 47 | 48 | - 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) 49 | - 1.0. Final release. 50 | 51 | ## Contributing 52 | 53 | Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. 54 | 55 | Before sending a PR, please discuss your change by raising an issue. 56 | 57 | ## License 58 | 59 | BSD-2-Clause 60 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/packet/userattribute.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "bytes" 9 | "image" 10 | "image/jpeg" 11 | "io" 12 | "io/ioutil" 13 | ) 14 | 15 | const UserAttrImageSubpacket = 1 16 | 17 | // UserAttribute is capable of storing other types of data about a user 18 | // beyond name, email and a text comment. In practice, user attributes are typically used 19 | // to store a signed thumbnail photo JPEG image of the user. 20 | // See RFC 4880, section 5.12. 21 | type UserAttribute struct { 22 | Contents []*OpaqueSubpacket 23 | } 24 | 25 | // NewUserAttributePhoto creates a user attribute packet 26 | // containing the given images. 27 | func NewUserAttributePhoto(photos ...image.Image) (uat *UserAttribute, err error) { 28 | uat = new(UserAttribute) 29 | for _, photo := range photos { 30 | var buf bytes.Buffer 31 | // RFC 4880, Section 5.12.1. 32 | data := []byte{ 33 | 0x10, 0x00, // Little-endian image header length (16 bytes) 34 | 0x01, // Image header version 1 35 | 0x01, // JPEG 36 | 0, 0, 0, 0, // 12 reserved octets, must be all zero. 37 | 0, 0, 0, 0, 38 | 0, 0, 0, 0} 39 | if _, err = buf.Write(data); err != nil { 40 | return 41 | } 42 | if err = jpeg.Encode(&buf, photo, nil); err != nil { 43 | return 44 | } 45 | uat.Contents = append(uat.Contents, &OpaqueSubpacket{ 46 | SubType: UserAttrImageSubpacket, 47 | Contents: buf.Bytes()}) 48 | } 49 | return 50 | } 51 | 52 | // NewUserAttribute creates a new user attribute packet containing the given subpackets. 53 | func NewUserAttribute(contents ...*OpaqueSubpacket) *UserAttribute { 54 | return &UserAttribute{Contents: contents} 55 | } 56 | 57 | func (uat *UserAttribute) parse(r io.Reader) (err error) { 58 | // RFC 4880, section 5.13 59 | b, err := ioutil.ReadAll(r) 60 | if err != nil { 61 | return 62 | } 63 | uat.Contents, err = OpaqueSubpackets(b) 64 | return 65 | } 66 | 67 | // Serialize marshals the user attribute to w in the form of an OpenPGP packet, including 68 | // header. 69 | func (uat *UserAttribute) Serialize(w io.Writer) (err error) { 70 | var buf bytes.Buffer 71 | for _, sp := range uat.Contents { 72 | sp.Serialize(&buf) 73 | } 74 | if err = serializeHeader(w, packetTypeUserAttribute, buf.Len()); err != nil { 75 | return err 76 | } 77 | _, err = w.Write(buf.Bytes()) 78 | return 79 | } 80 | 81 | // ImageData returns zero or more byte slices, each containing 82 | // JPEG File Interchange Format (JFIF), for each photo in the 83 | // user attribute packet. 84 | func (uat *UserAttribute) ImageData() (imageData [][]byte) { 85 | for _, sp := range uat.Contents { 86 | if sp.SubType == UserAttrImageSubpacket && len(sp.Contents) > 16 { 87 | imageData = append(imageData, sp.Contents[16:]) 88 | } 89 | } 90 | return 91 | } 92 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/pkg/errors/README.md: -------------------------------------------------------------------------------- 1 | # errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) 2 | 3 | Package errors provides simple error handling primitives. 4 | 5 | `go get github.com/pkg/errors` 6 | 7 | The traditional error handling idiom in Go is roughly akin to 8 | ```go 9 | if err != nil { 10 | return err 11 | } 12 | ``` 13 | which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. 14 | 15 | ## Adding context to an error 16 | 17 | The errors.Wrap function returns a new error that adds context to the original error. For example 18 | ```go 19 | _, err := ioutil.ReadAll(r) 20 | if err != nil { 21 | return errors.Wrap(err, "read failed") 22 | } 23 | ``` 24 | ## Retrieving the cause of an error 25 | 26 | Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. 27 | ```go 28 | type causer interface { 29 | Cause() error 30 | } 31 | ``` 32 | `errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: 33 | ```go 34 | switch err := errors.Cause(err).(type) { 35 | case *MyError: 36 | // handle specifically 37 | default: 38 | // unknown error 39 | } 40 | ``` 41 | 42 | [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). 43 | 44 | ## Roadmap 45 | 46 | With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: 47 | 48 | - 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) 49 | - 1.0. Final release. 50 | 51 | ## Contributing 52 | 53 | Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. 54 | 55 | Before sending a PR, please discuss your change by raising an issue. 56 | 57 | ## License 58 | 59 | BSD-2-Clause 60 | -------------------------------------------------------------------------------- /crossplane.md: -------------------------------------------------------------------------------- 1 | ## Crossplane instructions 2 | 3 | > Instructions contributed by [Daniel Mangum](https://github.com/hasheddan). For any issues please contact Daniel or Crossplane. 4 | 5 | 1. Install Crossplane 6 | 7 | ``` 8 | arkade install crossplane --helm3 9 | ``` 10 | 11 | 2. Install GCP Provider 12 | 13 | ``` 14 | kubectl apply -f gcp.yaml 15 | ``` 16 | 17 | 3. Set up Credentials 18 | 19 | This guide assumes you have set up a service account with Admin permissions and have included the credentials in a JSON file named `service-account.json` in the `crossplane/` directory. 20 | 21 | ``` 22 | cd crossplane 23 | 24 | ./credentials.sh 25 | ``` 26 | 27 | 4. Create CloudSQL Class 28 | 29 | ``` 30 | kubectl apply -f crossplane/cloudsql.yaml 31 | ``` 32 | 33 | 5. Create Postgres Claim 34 | 35 | ``` 36 | kubectl apply -f crossplane/postgres.yaml 37 | ``` 38 | 39 | 6. Install and Configure OpenFaaS 40 | 41 | ``` 42 | arkade install openfaas 43 | 44 | kubectl port-forward -n openfaas svc/gateway 8080:8080 & 45 | 46 | PASSWORD=$(kubectl get secret -n openfaas basic-auth -o jsonpath="{.data.basic-auth-password}" | base64 --decode; echo) 47 | echo -n $PASSWORD | faas-cli login --username admin --password-stdin 48 | ``` 49 | 50 | 7. Set up Secrets 51 | 52 | ``` 53 | export USERNAME=$(kubectl -n openfaas-fn get secret pgconn -o=jsonpath={.data.username} | base64 --decode -) 54 | export PASSWORD=$(kubectl -n openfaas-fn get secret pgconn -o=jsonpath={.data.password} | base64 --decode -) 55 | export HOST=$(kubectl -n openfaas-fn get secret pgconn -o=jsonpath={.data.endpoint} | base64 --decode -) 56 | export WEBHOOK_SECRET="mysupersecretvalue" 57 | 58 | faas-cli secret create username --from-literal=$USERNAME 59 | faas-cli secret create password --from-literal=$PASSWORD 60 | faas-cli secret create host --from-literal=$HOST 61 | faas-cli secret create webhook-secret --from-literal=$WEBHOOK_SECRET 62 | ``` 63 | 64 | 8. Configure Database 65 | 66 | ``` 67 | PGPASSWORD=$(echo $PASSWORD) psql -h $HOST -p 5432 -U $USERNAME -c 'CREATE DATABASE defaultdb;' 68 | PGPASSWORD=$(echo $PASSWORD) psql -h $HOST -p 5432 -U $USERNAME defaultdb < schema.sql 69 | ``` 70 | 71 | 9. Set up an Exit Node with [Inlets](https://github.com/inlets/inlets) on GCP 72 | 73 | ``` 74 | curl -sLSf https://inletsctl.inlets.dev | sudo sh 75 | curl -sLS https://get.inlets.dev | sudo sh 76 | 77 | export PROJECTID= 78 | 79 | inletsctl create -p gce --project-id=$PROJECTID -f=crossplane/service-account.json 80 | ``` 81 | 82 | Make sure to execute the commands returned to start the inlets client. 83 | 84 | 9. Deploy Functions 85 | 86 | ``` 87 | faas-cli template store pull golang-middleware 88 | 89 | sed -i 's/postgres_port: 25060/postgres_port: 5432/g' stack.yml 90 | 91 | faas-cli deploy 92 | ``` 93 | 94 | 10. Set up Github Webhook 95 | 96 | See directions above. 97 | 98 | 11. Comment with emoji! 99 | -------------------------------------------------------------------------------- /import-comment/vendor/golang.org/x/crypto/openpgp/packet/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package packet 6 | 7 | import ( 8 | "crypto" 9 | "crypto/rand" 10 | "io" 11 | "time" 12 | ) 13 | 14 | // Config collects a number of parameters along with sensible defaults. 15 | // A nil *Config is valid and results in all default values. 16 | type Config struct { 17 | // Rand provides the source of entropy. 18 | // If nil, the crypto/rand Reader is used. 19 | Rand io.Reader 20 | // DefaultHash is the default hash function to be used. 21 | // If zero, SHA-256 is used. 22 | DefaultHash crypto.Hash 23 | // DefaultCipher is the cipher to be used. 24 | // If zero, AES-128 is used. 25 | DefaultCipher CipherFunction 26 | // Time returns the current time as the number of seconds since the 27 | // epoch. If Time is nil, time.Now is used. 28 | Time func() time.Time 29 | // DefaultCompressionAlgo is the compression algorithm to be 30 | // applied to the plaintext before encryption. If zero, no 31 | // compression is done. 32 | DefaultCompressionAlgo CompressionAlgo 33 | // CompressionConfig configures the compression settings. 34 | CompressionConfig *CompressionConfig 35 | // S2KCount is only used for symmetric encryption. It 36 | // determines the strength of the passphrase stretching when 37 | // the said passphrase is hashed to produce a key. S2KCount 38 | // should be between 1024 and 65011712, inclusive. If Config 39 | // is nil or S2KCount is 0, the value 65536 used. Not all 40 | // values in the above range can be represented. S2KCount will 41 | // be rounded up to the next representable value if it cannot 42 | // be encoded exactly. When set, it is strongly encrouraged to 43 | // use a value that is at least 65536. See RFC 4880 Section 44 | // 3.7.1.3. 45 | S2KCount int 46 | // RSABits is the number of bits in new RSA keys made with NewEntity. 47 | // If zero, then 2048 bit keys are created. 48 | RSABits int 49 | } 50 | 51 | func (c *Config) Random() io.Reader { 52 | if c == nil || c.Rand == nil { 53 | return rand.Reader 54 | } 55 | return c.Rand 56 | } 57 | 58 | func (c *Config) Hash() crypto.Hash { 59 | if c == nil || uint(c.DefaultHash) == 0 { 60 | return crypto.SHA256 61 | } 62 | return c.DefaultHash 63 | } 64 | 65 | func (c *Config) Cipher() CipherFunction { 66 | if c == nil || uint8(c.DefaultCipher) == 0 { 67 | return CipherAES128 68 | } 69 | return c.DefaultCipher 70 | } 71 | 72 | func (c *Config) Now() time.Time { 73 | if c == nil || c.Time == nil { 74 | return time.Now() 75 | } 76 | return c.Time() 77 | } 78 | 79 | func (c *Config) Compression() CompressionAlgo { 80 | if c == nil { 81 | return CompressionNone 82 | } 83 | return c.DefaultCompressionAlgo 84 | } 85 | 86 | func (c *Config) PasswordHashIterations() int { 87 | if c == nil || c.S2KCount == 0 { 88 | return 0 89 | } 90 | return c.S2KCount 91 | } 92 | -------------------------------------------------------------------------------- /comments/vendor/github.com/lib/pq/README.md: -------------------------------------------------------------------------------- 1 | # pq - A pure Go postgres driver for Go's database/sql package 2 | 3 | [![GoDoc](https://godoc.org/github.com/lib/pq?status.svg)](https://godoc.org/github.com/lib/pq) 4 | [![Build Status](https://travis-ci.org/lib/pq.svg?branch=master)](https://travis-ci.org/lib/pq) 5 | 6 | ## Install 7 | 8 | go get github.com/lib/pq 9 | 10 | ## Docs 11 | 12 | For detailed documentation and basic usage examples, please see the package 13 | documentation at . 14 | 15 | ## Tests 16 | 17 | `go test` is used for testing. See [TESTS.md](TESTS.md) for more details. 18 | 19 | ## Features 20 | 21 | * SSL 22 | * Handles bad connections for `database/sql` 23 | * Scan `time.Time` correctly (i.e. `timestamp[tz]`, `time[tz]`, `date`) 24 | * Scan binary blobs correctly (i.e. `bytea`) 25 | * Package for `hstore` support 26 | * COPY FROM support 27 | * pq.ParseURL for converting urls to connection strings for sql.Open. 28 | * Many libpq compatible environment variables 29 | * Unix socket support 30 | * Notifications: `LISTEN`/`NOTIFY` 31 | * pgpass support 32 | 33 | ## Future / Things you can help with 34 | 35 | * Better COPY FROM / COPY TO (see discussion in #181) 36 | 37 | ## Thank you (alphabetical) 38 | 39 | Some of these contributors are from the original library `bmizerany/pq.go` whose 40 | code still exists in here. 41 | 42 | * Andy Balholm (andybalholm) 43 | * Ben Berkert (benburkert) 44 | * Benjamin Heatwole (bheatwole) 45 | * Bill Mill (llimllib) 46 | * Bjørn Madsen (aeons) 47 | * Blake Gentry (bgentry) 48 | * Brad Fitzpatrick (bradfitz) 49 | * Charlie Melbye (cmelbye) 50 | * Chris Bandy (cbandy) 51 | * Chris Gilling (cgilling) 52 | * Chris Walsh (cwds) 53 | * Dan Sosedoff (sosedoff) 54 | * Daniel Farina (fdr) 55 | * Eric Chlebek (echlebek) 56 | * Eric Garrido (minusnine) 57 | * Eric Urban (hydrogen18) 58 | * Everyone at The Go Team 59 | * Evan Shaw (edsrzf) 60 | * Ewan Chou (coocood) 61 | * Fazal Majid (fazalmajid) 62 | * Federico Romero (federomero) 63 | * Fumin (fumin) 64 | * Gary Burd (garyburd) 65 | * Heroku (heroku) 66 | * James Pozdena (jpoz) 67 | * Jason McVetta (jmcvetta) 68 | * Jeremy Jay (pbnjay) 69 | * Joakim Sernbrant (serbaut) 70 | * John Gallagher (jgallagher) 71 | * Jonathan Rudenberg (titanous) 72 | * Joël Stemmer (jstemmer) 73 | * Kamil Kisiel (kisielk) 74 | * Kelly Dunn (kellydunn) 75 | * Keith Rarick (kr) 76 | * Kir Shatrov (kirs) 77 | * Lann Martin (lann) 78 | * Maciek Sakrejda (uhoh-itsmaciek) 79 | * Marc Brinkmann (mbr) 80 | * Marko Tiikkaja (johto) 81 | * Matt Newberry (MattNewberry) 82 | * Matt Robenolt (mattrobenolt) 83 | * Martin Olsen (martinolsen) 84 | * Mike Lewis (mikelikespie) 85 | * Nicolas Patry (Narsil) 86 | * Oliver Tonnhofer (olt) 87 | * Patrick Hayes (phayes) 88 | * Paul Hammond (paulhammond) 89 | * Ryan Smith (ryandotsmith) 90 | * Samuel Stauffer (samuel) 91 | * Timothée Peignier (cyberdelia) 92 | * Travis Cline (tmc) 93 | * TruongSinh Tran-Nguyen (truongsinh) 94 | * Yaismel Miranda (ympons) 95 | * notedit (notedit) 96 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/lib/pq/README.md: -------------------------------------------------------------------------------- 1 | # pq - A pure Go postgres driver for Go's database/sql package 2 | 3 | [![GoDoc](https://godoc.org/github.com/lib/pq?status.svg)](https://godoc.org/github.com/lib/pq) 4 | [![Build Status](https://travis-ci.org/lib/pq.svg?branch=master)](https://travis-ci.org/lib/pq) 5 | 6 | ## Install 7 | 8 | go get github.com/lib/pq 9 | 10 | ## Docs 11 | 12 | For detailed documentation and basic usage examples, please see the package 13 | documentation at . 14 | 15 | ## Tests 16 | 17 | `go test` is used for testing. See [TESTS.md](TESTS.md) for more details. 18 | 19 | ## Features 20 | 21 | * SSL 22 | * Handles bad connections for `database/sql` 23 | * Scan `time.Time` correctly (i.e. `timestamp[tz]`, `time[tz]`, `date`) 24 | * Scan binary blobs correctly (i.e. `bytea`) 25 | * Package for `hstore` support 26 | * COPY FROM support 27 | * pq.ParseURL for converting urls to connection strings for sql.Open. 28 | * Many libpq compatible environment variables 29 | * Unix socket support 30 | * Notifications: `LISTEN`/`NOTIFY` 31 | * pgpass support 32 | 33 | ## Future / Things you can help with 34 | 35 | * Better COPY FROM / COPY TO (see discussion in #181) 36 | 37 | ## Thank you (alphabetical) 38 | 39 | Some of these contributors are from the original library `bmizerany/pq.go` whose 40 | code still exists in here. 41 | 42 | * Andy Balholm (andybalholm) 43 | * Ben Berkert (benburkert) 44 | * Benjamin Heatwole (bheatwole) 45 | * Bill Mill (llimllib) 46 | * Bjørn Madsen (aeons) 47 | * Blake Gentry (bgentry) 48 | * Brad Fitzpatrick (bradfitz) 49 | * Charlie Melbye (cmelbye) 50 | * Chris Bandy (cbandy) 51 | * Chris Gilling (cgilling) 52 | * Chris Walsh (cwds) 53 | * Dan Sosedoff (sosedoff) 54 | * Daniel Farina (fdr) 55 | * Eric Chlebek (echlebek) 56 | * Eric Garrido (minusnine) 57 | * Eric Urban (hydrogen18) 58 | * Everyone at The Go Team 59 | * Evan Shaw (edsrzf) 60 | * Ewan Chou (coocood) 61 | * Fazal Majid (fazalmajid) 62 | * Federico Romero (federomero) 63 | * Fumin (fumin) 64 | * Gary Burd (garyburd) 65 | * Heroku (heroku) 66 | * James Pozdena (jpoz) 67 | * Jason McVetta (jmcvetta) 68 | * Jeremy Jay (pbnjay) 69 | * Joakim Sernbrant (serbaut) 70 | * John Gallagher (jgallagher) 71 | * Jonathan Rudenberg (titanous) 72 | * Joël Stemmer (jstemmer) 73 | * Kamil Kisiel (kisielk) 74 | * Kelly Dunn (kellydunn) 75 | * Keith Rarick (kr) 76 | * Kir Shatrov (kirs) 77 | * Lann Martin (lann) 78 | * Maciek Sakrejda (uhoh-itsmaciek) 79 | * Marc Brinkmann (mbr) 80 | * Marko Tiikkaja (johto) 81 | * Matt Newberry (MattNewberry) 82 | * Matt Robenolt (mattrobenolt) 83 | * Martin Olsen (martinolsen) 84 | * Mike Lewis (mikelikespie) 85 | * Nicolas Patry (Narsil) 86 | * Oliver Tonnhofer (olt) 87 | * Patrick Hayes (phayes) 88 | * Paul Hammond (paulhammond) 89 | * Ryan Smith (ryandotsmith) 90 | * Samuel Stauffer (samuel) 91 | * Timothée Peignier (cyberdelia) 92 | * Travis Cline (tmc) 93 | * TruongSinh Tran-Nguyen (truongsinh) 94 | * Yaismel Miranda (ympons) 95 | * notedit (notedit) 96 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/pulls_reviewers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ReviewersRequest specifies users and teams for a pull request review request. 14 | type ReviewersRequest struct { 15 | NodeID *string `json:"node_id,omitempty"` 16 | Reviewers []string `json:"reviewers,omitempty"` 17 | TeamReviewers []string `json:"team_reviewers,omitempty"` 18 | } 19 | 20 | // Reviewers represents reviewers of a pull request. 21 | type Reviewers struct { 22 | Users []*User `json:"users,omitempty"` 23 | Teams []*Team `json:"teams,omitempty"` 24 | } 25 | 26 | // RequestReviewers creates a review request for the provided reviewers for the specified pull request. 27 | // 28 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#create-a-review-request 29 | func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) { 30 | u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) 31 | req, err := s.client.NewRequest("POST", u, &reviewers) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | 36 | r := new(PullRequest) 37 | resp, err := s.client.Do(ctx, req, r) 38 | if err != nil { 39 | return nil, resp, err 40 | } 41 | 42 | return r, resp, nil 43 | } 44 | 45 | // ListReviewers lists reviewers whose reviews have been requested on the specified pull request. 46 | // 47 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#list-review-requests 48 | func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) { 49 | u := fmt.Sprintf("repos/%v/%v/pulls/%d/requested_reviewers", owner, repo, number) 50 | u, err := addOptions(u, opts) 51 | if err != nil { 52 | return nil, nil, err 53 | } 54 | 55 | req, err := s.client.NewRequest("GET", u, nil) 56 | if err != nil { 57 | return nil, nil, err 58 | } 59 | 60 | reviewers := new(Reviewers) 61 | resp, err := s.client.Do(ctx, req, reviewers) 62 | if err != nil { 63 | return nil, resp, err 64 | } 65 | 66 | return reviewers, resp, nil 67 | } 68 | 69 | // RemoveReviewers removes the review request for the provided reviewers for the specified pull request. 70 | // 71 | // GitHub API docs: https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request 72 | func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) { 73 | u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) 74 | req, err := s.client.NewRequest("DELETE", u, &reviewers) 75 | if err != nil { 76 | return nil, err 77 | } 78 | 79 | return s.client.Do(ctx, req, nil) 80 | } 81 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/actions_workflows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // Workflow represents a repository action workflow. 14 | type Workflow struct { 15 | ID int64 `json:"id"` 16 | NodeID string `json:"node_id"` 17 | Name string `json:"name"` 18 | Path string `json:"path"` 19 | State string `json:"state"` 20 | CreatedAt Timestamp `json:"created_at"` 21 | UpdatedAt Timestamp `json:"updated_at"` 22 | URL string `json:"url"` 23 | HTMLURL string `json:"html_url"` 24 | BadgeURL string `json:"badge_url"` 25 | } 26 | 27 | // Workflows represents a slice of repository action workflows. 28 | type Workflows struct { 29 | TotalCount int `json:"total_count"` 30 | Workflows []*Workflow `json:"workflows"` 31 | } 32 | 33 | // ListWorkflows lists all workflows in a repository. 34 | // 35 | // GitHub API docs: https://developer.github.com/v3/actions/workflows/#list-repository-workflows 36 | func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) { 37 | u := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo) 38 | u, err := addOptions(u, opts) 39 | if err != nil { 40 | return nil, nil, err 41 | } 42 | 43 | req, err := s.client.NewRequest("GET", u, nil) 44 | if err != nil { 45 | return nil, nil, err 46 | } 47 | 48 | workflows := new(Workflows) 49 | resp, err := s.client.Do(ctx, req, &workflows) 50 | if err != nil { 51 | return nil, resp, err 52 | } 53 | 54 | return workflows, resp, nil 55 | } 56 | 57 | // GetWorkflowByID gets a specific workflow by ID. 58 | // 59 | // GitHub API docs: https://developer.github.com/v3/actions/workflows/#get-a-workflow 60 | func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) { 61 | u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowID) 62 | 63 | return s.getWorkflow(ctx, u) 64 | } 65 | 66 | // GetWorkflowByFileName gets a specific workflow by file name. 67 | // 68 | // GitHub API docs: https://developer.github.com/v3/actions/workflows/#get-a-workflow 69 | func (s *ActionsService) GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) { 70 | u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowFileName) 71 | 72 | return s.getWorkflow(ctx, u) 73 | } 74 | 75 | func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow, *Response, error) { 76 | req, err := s.client.NewRequest("GET", url, nil) 77 | if err != nil { 78 | return nil, nil, err 79 | } 80 | 81 | workflow := new(Workflow) 82 | resp, err := s.client.Do(ctx, req, workflow) 83 | if err != nil { 84 | return nil, resp, err 85 | } 86 | 87 | return workflow, resp, nil 88 | } 89 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/users_blocking.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListBlockedUsers lists all the blocked users by the authenticated user. 14 | // 15 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#list-blocked-users 16 | func (s *UsersService) ListBlockedUsers(ctx context.Context, opts *ListOptions) ([]*User, *Response, error) { 17 | u := "user/blocks" 18 | u, err := addOptions(u, opts) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | 23 | req, err := s.client.NewRequest("GET", u, nil) 24 | if err != nil { 25 | return nil, nil, err 26 | } 27 | 28 | // TODO: remove custom Accept header when this API fully launches. 29 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 30 | 31 | var blockedUsers []*User 32 | resp, err := s.client.Do(ctx, req, &blockedUsers) 33 | if err != nil { 34 | return nil, resp, err 35 | } 36 | 37 | return blockedUsers, resp, nil 38 | } 39 | 40 | // IsBlocked reports whether specified user is blocked by the authenticated user. 41 | // 42 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#check-whether-youve-blocked-a-user 43 | func (s *UsersService) IsBlocked(ctx context.Context, user string) (bool, *Response, error) { 44 | u := fmt.Sprintf("user/blocks/%v", user) 45 | 46 | req, err := s.client.NewRequest("GET", u, nil) 47 | if err != nil { 48 | return false, nil, err 49 | } 50 | 51 | // TODO: remove custom Accept header when this API fully launches. 52 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 53 | 54 | resp, err := s.client.Do(ctx, req, nil) 55 | isBlocked, err := parseBoolResponse(err) 56 | return isBlocked, resp, err 57 | } 58 | 59 | // BlockUser blocks specified user for the authenticated user. 60 | // 61 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#block-a-user 62 | func (s *UsersService) BlockUser(ctx context.Context, user string) (*Response, error) { 63 | u := fmt.Sprintf("user/blocks/%v", user) 64 | 65 | req, err := s.client.NewRequest("PUT", u, nil) 66 | if err != nil { 67 | return nil, err 68 | } 69 | 70 | // TODO: remove custom Accept header when this API fully launches. 71 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 72 | 73 | return s.client.Do(ctx, req, nil) 74 | } 75 | 76 | // UnblockUser unblocks specified user for the authenticated user. 77 | // 78 | // GitHub API docs: https://developer.github.com/v3/users/blocking/#unblock-a-user 79 | func (s *UsersService) UnblockUser(ctx context.Context, user string) (*Response, error) { 80 | u := fmt.Sprintf("user/blocks/%v", user) 81 | 82 | req, err := s.client.NewRequest("DELETE", u, nil) 83 | if err != nil { 84 | return nil, err 85 | } 86 | 87 | // TODO: remove custom Accept header when this API fully launches. 88 | req.Header.Set("Accept", mediaTypeBlockUsersPreview) 89 | 90 | return s.client.Do(ctx, req, nil) 91 | } 92 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/activity.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import "context" 9 | 10 | // ActivityService handles communication with the activity related 11 | // methods of the GitHub API. 12 | // 13 | // GitHub API docs: https://developer.github.com/v3/activity/ 14 | type ActivityService service 15 | 16 | // FeedLink represents a link to a related resource. 17 | type FeedLink struct { 18 | HRef *string `json:"href,omitempty"` 19 | Type *string `json:"type,omitempty"` 20 | } 21 | 22 | // Feeds represents timeline resources in Atom format. 23 | type Feeds struct { 24 | TimelineURL *string `json:"timeline_url,omitempty"` 25 | UserURL *string `json:"user_url,omitempty"` 26 | CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"` 27 | CurrentUserURL *string `json:"current_user_url,omitempty"` 28 | CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"` 29 | CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"` 30 | CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"` 31 | Links *struct { 32 | Timeline *FeedLink `json:"timeline,omitempty"` 33 | User *FeedLink `json:"user,omitempty"` 34 | CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"` 35 | CurrentUser *FeedLink `json:"current_user,omitempty"` 36 | CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"` 37 | CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"` 38 | CurrentUserOrganizations []FeedLink `json:"current_user_organizations,omitempty"` 39 | } `json:"_links,omitempty"` 40 | } 41 | 42 | // ListFeeds lists all the feeds available to the authenticated user. 43 | // 44 | // GitHub provides several timeline resources in Atom format: 45 | // Timeline: The GitHub global public timeline 46 | // User: The public timeline for any user, using URI template 47 | // Current user public: The public timeline for the authenticated user 48 | // Current user: The private timeline for the authenticated user 49 | // Current user actor: The private timeline for activity created by the 50 | // authenticated user 51 | // Current user organizations: The private timeline for the organizations 52 | // the authenticated user is a member of. 53 | // 54 | // Note: Private feeds are only returned when authenticating via Basic Auth 55 | // since current feed URIs use the older, non revocable auth tokens. 56 | func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) { 57 | req, err := s.client.NewRequest("GET", "feeds", nil) 58 | if err != nil { 59 | return nil, nil, err 60 | } 61 | 62 | f := &Feeds{} 63 | resp, err := s.client.Do(ctx, req, f) 64 | if err != nil { 65 | return nil, resp, err 66 | } 67 | 68 | return f, resp, nil 69 | } 70 | -------------------------------------------------------------------------------- /import-comment/vendor/github.com/google/go-github/github/issues_assignees.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The go-github AUTHORS. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package github 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | ) 12 | 13 | // ListAssignees fetches all available assignees (owners and collaborators) to 14 | // which issues may be assigned. 15 | // 16 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#list-assignees 17 | func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { 18 | u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) 19 | u, err := addOptions(u, opts) 20 | if err != nil { 21 | return nil, nil, err 22 | } 23 | 24 | req, err := s.client.NewRequest("GET", u, nil) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | var assignees []*User 29 | resp, err := s.client.Do(ctx, req, &assignees) 30 | if err != nil { 31 | return nil, resp, err 32 | } 33 | 34 | return assignees, resp, nil 35 | } 36 | 37 | // IsAssignee checks if a user is an assignee for the specified repository. 38 | // 39 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#check-assignee 40 | func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) { 41 | u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) 42 | req, err := s.client.NewRequest("GET", u, nil) 43 | if err != nil { 44 | return false, nil, err 45 | } 46 | resp, err := s.client.Do(ctx, req, nil) 47 | assignee, err := parseBoolResponse(err) 48 | return assignee, resp, err 49 | } 50 | 51 | // AddAssignees adds the provided GitHub users as assignees to the issue. 52 | // 53 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue 54 | func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { 55 | users := &struct { 56 | Assignees []string `json:"assignees,omitempty"` 57 | }{Assignees: assignees} 58 | u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) 59 | req, err := s.client.NewRequest("POST", u, users) 60 | if err != nil { 61 | return nil, nil, err 62 | } 63 | 64 | issue := &Issue{} 65 | resp, err := s.client.Do(ctx, req, issue) 66 | return issue, resp, err 67 | } 68 | 69 | // RemoveAssignees removes the provided GitHub users as assignees from the issue. 70 | // 71 | // GitHub API docs: https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue 72 | func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { 73 | users := &struct { 74 | Assignees []string `json:"assignees,omitempty"` 75 | }{Assignees: assignees} 76 | u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) 77 | req, err := s.client.NewRequest("DELETE", u, users) 78 | if err != nil { 79 | return nil, nil, err 80 | } 81 | 82 | issue := &Issue{} 83 | resp, err := s.client.Do(ctx, req, issue) 84 | return issue, resp, err 85 | } 86 | --------------------------------------------------------------------------------