mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-06 18:28:43 +00:00
Vendor using dep
This commit is contained in:
48
vendor/github.com/google/go-github/example/appengine/app.go
generated
vendored
Normal file
48
vendor/github.com/google/go-github/example/appengine/app.go
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// The demo app shows how to use the github package on Google App Engine.
|
||||
package demo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
"golang.org/x/oauth2"
|
||||
"google.golang.org/appengine"
|
||||
"google.golang.org/appengine/log"
|
||||
)
|
||||
|
||||
func init() {
|
||||
http.HandleFunc("/", handler)
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := appengine.NewContext(r)
|
||||
ts := oauth2.StaticTokenSource(
|
||||
&oauth2.Token{AccessToken: os.Getenv("GITHUB_AUTH_TOKEN")},
|
||||
)
|
||||
tc := oauth2.NewClient(ctx, ts)
|
||||
client := github.NewClient(tc)
|
||||
|
||||
commits, _, err := client.Repositories.ListCommits(ctx, "google", "go-github", nil)
|
||||
if err != nil {
|
||||
log.Errorf(ctx, "ListCommits: %v", err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
for _, commit := range commits {
|
||||
fmt.Fprintln(w, commit.GetHTMLURL())
|
||||
}
|
||||
}
|
||||
14
vendor/github.com/google/go-github/example/appengine/app.yaml
generated
vendored
Normal file
14
vendor/github.com/google/go-github/example/appengine/app.yaml
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
runtime: go
|
||||
api_version: go1
|
||||
|
||||
handlers:
|
||||
- url: /.*
|
||||
script: _go_app
|
||||
|
||||
env_variables:
|
||||
GITHUB_AUTH_TOKEN: "-your-auth-token-here-"
|
||||
55
vendor/github.com/google/go-github/example/basicauth/main.go
generated
vendored
Normal file
55
vendor/github.com/google/go-github/example/basicauth/main.go
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2015 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// The basicauth command demonstrates using the github.BasicAuthTransport,
|
||||
// including handling two-factor authentication. This won't currently work for
|
||||
// accounts that use SMS to receive one-time passwords.
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/google/go-github/github"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := bufio.NewReader(os.Stdin)
|
||||
fmt.Print("GitHub Username: ")
|
||||
username, _ := r.ReadString('\n')
|
||||
|
||||
fmt.Print("GitHub Password: ")
|
||||
bytePassword, _ := terminal.ReadPassword(int(syscall.Stdin))
|
||||
password := string(bytePassword)
|
||||
|
||||
tp := github.BasicAuthTransport{
|
||||
Username: strings.TrimSpace(username),
|
||||
Password: strings.TrimSpace(password),
|
||||
}
|
||||
|
||||
client := github.NewClient(tp.Client())
|
||||
ctx := context.Background()
|
||||
user, _, err := client.Users.Get(ctx, "")
|
||||
|
||||
// Is this a two-factor auth error? If so, prompt for OTP and try again.
|
||||
if _, ok := err.(*github.TwoFactorAuthError); ok {
|
||||
fmt.Print("\nGitHub OTP: ")
|
||||
otp, _ := r.ReadString('\n')
|
||||
tp.OTP = strings.TrimSpace(otp)
|
||||
user, _, err = client.Users.Get(ctx, "")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("\nerror: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n%v\n", github.Stringify(user))
|
||||
}
|
||||
Reference in New Issue
Block a user