// UnmarshalGithubConnector unmarshals Github connector from JSON
487636
func (*TeleportGithubConnectorMarshaler) Unmarshal(bytes []byte) (GithubConnector, error) {
	var h ResourceHeader
	if err := json.Unmarshal(bytes, &h); err != nil {
		return nil, trace.Wrap(err)
	}
	switch h.Version {
	case V3:
		var c GithubConnectorV3
		if err := utils.UnmarshalWithSchema(GetGithubConnectorSchema(), &c, bytes); err != nil {
			return nil, trace.Wrap(err)
		}
		if err := c.CheckAndSetDefaults(); err != nil {
			return nil, trace.Wrap(err)
		}
		return &c, nil
	}
	return nil, trace.BadParameter(
		"Github connector resource version %q is not supported", h.Version)
}
531023
func NewGitHub(ctx *context.Context) (Client, error) {
	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: ctx.Token},
	)
	httpClient := oauth2.NewClient(ctx, ts)
	base := httpClient.Transport.(*oauth2.Transport).Base
	// nolint: govet
	if &base != nil {
		base = http.DefaultTransport
	}
	// nolint: gosec
	base.(*http.Transport).TLSClientConfig = &tls.Config{
		InsecureSkipVerify: ctx.Config.GitHubURLs.SkipTLSVerify,
	}
	httpClient.Transport.(*oauth2.Transport).Base = base
	client := github.NewClient(httpClient)
	if ctx.Config.GitHubURLs.API != "" {
		api, err := url.Parse(ctx.Config.GitHubURLs.API)
		if err != nil {
			return &githubClient{}, err
		}
		upload, err := url.Parse(ctx.Config.GitHubURLs.Upload)
		if err != nil {
			return &githubClient{}, err
		}
		client.BaseURL = api
		client.UploadURL = upload
	}

	return &githubClient{client: client}, nil
}
1183285
func NewGithubProvider(clientId, clientSecret, scope string) *GithubProvider {
	github := GithubProvider{}
	github.AuthorizationURL = "https://github.com/login/oauth/authorize"
	github.AccessTokenURL   = "https://github.com/login/oauth/access_token"
	github.ClientId         = clientId
	github.ClientSecret     = clientSecret
	github.Scope            = scope

	// default the Scope if not provided
	if len(github.Scope) == 0 {
		github.Scope = "user:email"
	}
	return &github
}
1268355
func (s *IdentityService) CreateGithubAuthRequest(req services.GithubAuthRequest) error {
	err := req.Check()
	if err != nil {
		return trace.Wrap(err)
	}
	value, err := json.Marshal(req)
	if err != nil {
		return trace.Wrap(err)
	}
	item := backend.Item{
		Key:     backend.Key(webPrefix, connectorsPrefix, githubPrefix, requestsPrefix, req.StateToken),
		Value:   value,
		Expires: req.Expiry(),
	}
	_, err = s.Create(context.TODO(), item)
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
459311
func (bt *BitcoinTransaction) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		bt.ID = id
		return nil
	}

	type bitcoinTransaction BitcoinTransaction
	var v bitcoinTransaction
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*bt = BitcoinTransaction(v)
	return nil
}
762776
func (pTypeDef *UUIDTest) UnmarshalJSON(b []byte) error {
	var r rawUUIDTest
	err := json.Unmarshal(b, &r)
	if err == nil {
		o := UUIDTest(r)
		*pTypeDef = o
		err = pTypeDef.Validate()
	}
	return err
}
128301
func (n *Node) UnmarshalJSON(raw []byte) error {
	// TODO: How should we turn back NodeInfo into n.Node?
	// Ticket: https://github.com/ethersphere/go-ethereum/issues/1177
	node := struct {
		Config *adapters.NodeConfig `json:"config,omitempty"`
		Up     bool                 `json:"up"`
	}{}
	if err := json.Unmarshal(raw, &node); err != nil {
		return err
	}

	n.SetUp(node.Up)
	n.Config = node.Config
	return nil
}
963008
func AddGithubBuild(projectId int64, data githubutil.GithubPushHook) error {
	o := orm.NewOrm()

	// TODO(tobe): could not get commit id, commit time and committer

	build := Build{
		UserName:    data.Repository.Owner.Login,
		ProjectId:   projectId,
		ProjectName: data.Repository.Name,
		RepoUrl:     data.Repository.URL,
		Branch:      data.Repository.DefaultBranch,
		Commit:      "ffffffffff",
		CommitTime:  time.Now(),
		Committer:   "unknown",
		BuildTime:   time.Now(),
		FinishTime:  time.Now(),
		Status:      BUILD_STATUS_NOT_START}

	_, err := o.Insert(&build)
	fmt.Println("ERR: %v\n", err)
	return err
}
1000170
func (s *Server) UseGithub() bool {
	return s.TokenSecret != "" && s.GithubClientID != "" && s.GithubClientSecret != ""
}
711096
func NewGithubIssuesLogger(name string, opts *GithubOptions) (Sender, error) {
	s := &githubLogger{
		Base: NewBase(name),
		opts: opts,
		gh:   &githubClientImpl{},
	}

	ctx := context.TODO()
	s.gh.Init(ctx, opts.Token)

	fallback := log.New(os.Stdout, "", log.LstdFlags)
	if err := s.SetErrorHandler(ErrorHandlerFromLogger(fallback)); err != nil {
		return nil, err
	}

	if err := s.SetFormatter(MakeDefaultFormatter()); err != nil {
		return nil, err
	}

	s.reset = func() {
		fallback.SetPrefix(fmt.Sprintf("[%s] [%s/%s] ", s.Name(), opts.Account, opts.Repo))
	}

	return s, nil
}
1189454
func (step *CallFlowHangupStep) UnmarshalJSON(data []byte) error {
	var raw jsonCallFlowHangupStep
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	*step = CallFlowHangupStep{
		CallFlowStepBase: raw.CallFlowStepBase,
	}
	return nil
}
381290
func HasHubConnectivity(t *testing.T) bool {
	t.Helper()
	// Set a timeout on the GET at 15s
	var timeout = 15 * time.Second
	var url = "https://hub.docker.com"

	client := http.Client{Timeout: timeout}
	resp, err := client.Get(url)
	if err != nil && strings.Contains(err.Error(), "use of closed network connection") {
		t.Fatalf("Timeout for GET request on %s", url)
	}
	if resp != nil {
		resp.Body.Close()
	}
	return err == nil
}
364368
func (o *DHCPOptions) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realDHCPOptions
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = DHCPOptions(r)
	return nil
}
270447
func (*TeleportGithubConnectorMarshaler) Marshal(c GithubConnector, opts ...MarshalOption) ([]byte, error) {
	cfg, err := collectOptions(opts)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	switch resource := c.(type) {
	case *GithubConnectorV3:
		if !cfg.PreserveResourceID {
			// avoid modifying the original object
			// to prevent unexpected data races
			copy := *resource
			copy.SetResourceID(0)
			resource = &copy
		}
		return utils.FastMarshal(resource)
	default:
		return nil, trace.BadParameter("unrecognized resource version %T", c)
	}
}
283012
func (v *CBGithub) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonB0500db0DecodeGithubComFrancoispqtGojayBenchmarks4(&r, v)
	return r.Error()
}
1163172
func MakeGithubStatusMessage(context string, state GithubState, URL, description string) Composer {
	return &githubStatusMessage{
		raw: GithubStatus{
			Context:     context,
			State:       state,
			URL:         URL,
			Description: description,
		},
	}
}
1369600
func (t *TimeSinceEpoch) UnmarshalJSON(data []byte) error {
	*t = 0
	if len(data) == 0 {
		return nil
	}
	var f float64
	if err := json.Unmarshal(data, &f); err != nil {
		return errors.New("network.TimeSinceEpoch: " + err.Error())
	}
	*t = TimeSinceEpoch(f)
	return nil
}