Move code to external package
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
14586f0154
commit
da13cec2de
195 changed files with 56394 additions and 364 deletions
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type contextFlags string
|
type contextFlags string
|
||||||
|
|
@ -65,16 +64,16 @@ func InstanceTokenFetched(ctx context.Context) bool {
|
||||||
return elem.(bool)
|
return elem.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetInstanceRunnerStatus(ctx context.Context, val common.RunnerStatus) context.Context {
|
func SetInstanceRunnerStatus(ctx context.Context, val params.RunnerStatus) context.Context {
|
||||||
return context.WithValue(ctx, instanceRunnerStatus, val)
|
return context.WithValue(ctx, instanceRunnerStatus, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func InstanceRunnerStatus(ctx context.Context) common.RunnerStatus {
|
func InstanceRunnerStatus(ctx context.Context) params.RunnerStatus {
|
||||||
elem := ctx.Value(instanceRunnerStatus)
|
elem := ctx.Value(instanceRunnerStatus)
|
||||||
if elem == nil {
|
if elem == nil {
|
||||||
return common.RunnerPending
|
return params.RunnerPending
|
||||||
}
|
}
|
||||||
return elem.(common.RunnerStatus)
|
return elem.(params.RunnerStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetInstanceName(ctx context.Context, val string) context.Context {
|
func SetInstanceName(ctx context.Context, val string) context.Context {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ import (
|
||||||
runnerErrors "github.com/cloudbase/garm/errors"
|
runnerErrors "github.com/cloudbase/garm/errors"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/common"
|
"github.com/cloudbase/garm/runner/common"
|
||||||
providerCommon "github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt"
|
"github.com/golang-jwt/jwt"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -149,7 +148,7 @@ func (amw *instanceMiddleware) Middleware(next http.Handler) http.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
runnerStatus := InstanceRunnerStatus(ctx)
|
runnerStatus := InstanceRunnerStatus(ctx)
|
||||||
if runnerStatus != providerCommon.RunnerInstalling && runnerStatus != providerCommon.RunnerPending {
|
if runnerStatus != params.RunnerInstalling && runnerStatus != params.RunnerPending {
|
||||||
// Instances that have finished installing can no longer authenticate to the API
|
// Instances that have finished installing can no longer authenticate to the API
|
||||||
invalidAuthResponse(w)
|
invalidAuthResponse(w)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ import (
|
||||||
"github.com/jedib0t/go-pretty/v6/table"
|
"github.com/jedib0t/go-pretty/v6/table"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -192,8 +194,8 @@ var poolAddCmd = &cobra.Command{
|
||||||
MinIdleRunners: poolMinIdleRunners,
|
MinIdleRunners: poolMinIdleRunners,
|
||||||
Image: poolImage,
|
Image: poolImage,
|
||||||
Flavor: poolFlavor,
|
Flavor: poolFlavor,
|
||||||
OSType: params.OSType(poolOSType),
|
OSType: commonParams.OSType(poolOSType),
|
||||||
OSArch: params.OSArch(poolOSArch),
|
OSArch: commonParams.OSArch(poolOSArch),
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Enabled: poolEnabled,
|
Enabled: poolEnabled,
|
||||||
RunnerBootstrapTimeout: poolRunnerBootstrapTimeout,
|
RunnerBootstrapTimeout: poolRunnerBootstrapTimeout,
|
||||||
|
|
@ -280,11 +282,11 @@ explicitly remove them using the runner delete command.
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flags().Changed("os-type") {
|
if cmd.Flags().Changed("os-type") {
|
||||||
poolUpdateParams.OSType = params.OSType(poolOSType)
|
poolUpdateParams.OSType = commonParams.OSType(poolOSType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flags().Changed("os-arch") {
|
if cmd.Flags().Changed("os-arch") {
|
||||||
poolUpdateParams.OSArch = params.OSArch(poolOSArch)
|
poolUpdateParams.OSArch = commonParams.OSArch(poolOSArch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Flags().Changed("max-runners") {
|
if cmd.Flags().Changed("max-runners") {
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ var (
|
||||||
|
|
||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
|
var signals = []os.Signal{
|
||||||
|
os.Interrupt,
|
||||||
|
syscall.SIGTERM,
|
||||||
|
}
|
||||||
|
|
||||||
func maybeInitController(db common.Store) error {
|
func maybeInitController(db common.Store) error {
|
||||||
if _, err := db.ControllerInfo(); err == nil {
|
if _, err := db.ControllerInfo(); err == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
//go:build !windows
|
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
var signals = []os.Signal{
|
|
||||||
os.Interrupt,
|
|
||||||
syscall.SIGTERM,
|
|
||||||
}
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
//go:build windows && !linux
|
|
||||||
// +build windows,!linux
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
var signals = []os.Signal{
|
|
||||||
os.Interrupt,
|
|
||||||
}
|
|
||||||
|
|
@ -22,10 +22,11 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
dbCommon "github.com/cloudbase/garm/database/common"
|
dbCommon "github.com/cloudbase/garm/database/common"
|
||||||
garmTesting "github.com/cloudbase/garm/internal/testing"
|
garmTesting "github.com/cloudbase/garm/internal/testing"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
|
|
||||||
"gopkg.in/DATA-DOG/go-sqlmock.v1"
|
"gopkg.in/DATA-DOG/go-sqlmock.v1"
|
||||||
|
|
||||||
|
|
@ -109,8 +110,8 @@ func (s *InstancesTestSuite) SetupTest() {
|
||||||
OSType: "linux",
|
OSType: "linux",
|
||||||
OSArch: "amd64",
|
OSArch: "amd64",
|
||||||
CallbackURL: "https://garm.example.com/",
|
CallbackURL: "https://garm.example.com/",
|
||||||
Status: common.InstanceRunning,
|
Status: commonParams.InstanceRunning,
|
||||||
RunnerStatus: common.RunnerIdle,
|
RunnerStatus: params.RunnerIdle,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -156,18 +157,18 @@ func (s *InstancesTestSuite) SetupTest() {
|
||||||
ProviderID: "update-provider-test",
|
ProviderID: "update-provider-test",
|
||||||
OSName: "ubuntu",
|
OSName: "ubuntu",
|
||||||
OSVersion: "focal",
|
OSVersion: "focal",
|
||||||
Status: common.InstancePendingDelete,
|
Status: commonParams.InstancePendingDelete,
|
||||||
RunnerStatus: common.RunnerActive,
|
RunnerStatus: params.RunnerActive,
|
||||||
AgentID: 4,
|
AgentID: 4,
|
||||||
CreateAttempt: 3,
|
CreateAttempt: 3,
|
||||||
Addresses: []params.Address{
|
Addresses: []commonParams.Address{
|
||||||
{
|
{
|
||||||
Address: "12.10.12.10",
|
Address: "12.10.12.10",
|
||||||
Type: params.PublicAddress,
|
Type: commonParams.PublicAddress,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Address: "10.1.1.2",
|
Address: "10.1.1.2",
|
||||||
Type: params.PrivateAddress,
|
Type: commonParams.PrivateAddress,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ package sql
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -63,8 +63,8 @@ type Pool struct {
|
||||||
RunnerBootstrapTimeout uint
|
RunnerBootstrapTimeout uint
|
||||||
Image string `gorm:"index:idx_pool_type"`
|
Image string `gorm:"index:idx_pool_type"`
|
||||||
Flavor string `gorm:"index:idx_pool_type"`
|
Flavor string `gorm:"index:idx_pool_type"`
|
||||||
OSType params.OSType
|
OSType commonParams.OSType
|
||||||
OSArch params.OSArch
|
OSArch commonParams.OSArch
|
||||||
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
||||||
Enabled bool
|
Enabled bool
|
||||||
// ExtraSpecs is an opaque json that gets sent to the provider
|
// ExtraSpecs is an opaque json that gets sent to the provider
|
||||||
|
|
@ -143,13 +143,13 @@ type Instance struct {
|
||||||
ProviderID *string `gorm:"uniqueIndex"`
|
ProviderID *string `gorm:"uniqueIndex"`
|
||||||
Name string `gorm:"uniqueIndex"`
|
Name string `gorm:"uniqueIndex"`
|
||||||
AgentID int64
|
AgentID int64
|
||||||
OSType params.OSType
|
OSType commonParams.OSType
|
||||||
OSArch params.OSArch
|
OSArch commonParams.OSArch
|
||||||
OSName string
|
OSName string
|
||||||
OSVersion string
|
OSVersion string
|
||||||
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
||||||
Status common.InstanceStatus
|
Status commonParams.InstanceStatus
|
||||||
RunnerStatus common.RunnerStatus
|
RunnerStatus params.RunnerStatus
|
||||||
CallbackURL string
|
CallbackURL string
|
||||||
MetadataURL string
|
MetadataURL string
|
||||||
ProviderFault []byte `gorm:"type:longblob"`
|
ProviderFault []byte `gorm:"type:longblob"`
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
|
func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
|
||||||
|
|
@ -75,10 +77,10 @@ func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sqlDatabase) sqlAddressToParamsAddress(addr Address) params.Address {
|
func (s *sqlDatabase) sqlAddressToParamsAddress(addr Address) commonParams.Address {
|
||||||
return params.Address{
|
return commonParams.Address{
|
||||||
Address: addr.Address,
|
Address: addr.Address,
|
||||||
Type: params.AddressType(addr.Type),
|
Type: commonParams.AddressType(addr.Type),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
go.mod
6
go.mod
|
|
@ -4,6 +4,7 @@ go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.2.1
|
github.com/BurntSushi/toml v1.2.1
|
||||||
|
github.com/cloudbase/garm-provider-common v0.0.0-20230721124716-d56f689733ea
|
||||||
github.com/go-openapi/errors v0.20.4
|
github.com/go-openapi/errors v0.20.4
|
||||||
github.com/go-openapi/runtime v0.26.0
|
github.com/go-openapi/runtime v0.26.0
|
||||||
github.com/go-openapi/strfmt v0.21.7
|
github.com/go-openapi/strfmt v0.21.7
|
||||||
|
|
@ -19,7 +20,6 @@ require (
|
||||||
github.com/juju/retry v1.0.0
|
github.com/juju/retry v1.0.0
|
||||||
github.com/lxc/lxd v0.0.0-20230325180147-8d608287b0ce
|
github.com/lxc/lxd v0.0.0-20230325180147-8d608287b0ce
|
||||||
github.com/manifoldco/promptui v0.9.0
|
github.com/manifoldco/promptui v0.9.0
|
||||||
github.com/mattn/go-isatty v0.0.18
|
|
||||||
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354
|
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/prometheus/client_golang v1.14.0
|
github.com/prometheus/client_golang v1.14.0
|
||||||
|
|
@ -32,7 +32,6 @@ require (
|
||||||
golang.org/x/sys v0.8.0
|
golang.org/x/sys v0.8.0
|
||||||
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
|
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
|
||||||
gorm.io/datatypes v1.1.1
|
gorm.io/datatypes v1.1.1
|
||||||
gorm.io/driver/mysql v1.4.7
|
gorm.io/driver/mysql v1.4.7
|
||||||
gorm.io/driver/sqlite v1.4.4
|
gorm.io/driver/sqlite v1.4.4
|
||||||
|
|
@ -63,6 +62,7 @@ require (
|
||||||
github.com/go-openapi/validate v0.22.1 // indirect
|
github.com/go-openapi/validate v0.22.1 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
|
github.com/google/go-github/v48 v48.2.0 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
|
@ -76,6 +76,7 @@ require (
|
||||||
github.com/kr/fs v0.1.0 // indirect
|
github.com/kr/fs v0.1.0 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.16 // indirect
|
github.com/mattn/go-sqlite3 v1.14.16 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
|
|
@ -106,4 +107,5 @@ require (
|
||||||
gopkg.in/httprequest.v1 v1.2.1 // indirect
|
gopkg.in/httprequest.v1 v1.2.1 // indirect
|
||||||
gopkg.in/macaroon.v2 v2.1.0 // indirect
|
gopkg.in/macaroon.v2 v2.1.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
go.sum
8
go.sum
|
|
@ -25,6 +25,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
|
||||||
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
|
github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
|
||||||
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cloudbase/garm-provider-common v0.0.0-20230721124716-d56f689733ea h1:spORgLQ74kfpzqx1Qkv36mlzHDWhQt367iYXH2hrRMk=
|
||||||
|
github.com/cloudbase/garm-provider-common v0.0.0-20230721124716-d56f689733ea/go.mod h1:7PvnanuVjnA132EYND9I7r9FtdnztMgMhrqZUdJ1jHo=
|
||||||
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
|
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
|
||||||
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
|
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
|
||||||
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
|
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
|
||||||
|
|
@ -150,6 +152,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE=
|
||||||
|
github.com/google/go-github/v48 v48.2.0/go.mod h1:dDlehKBDo850ZPvCTK0sEqTCVWcrGl2LcDiajkYi89Y=
|
||||||
github.com/google/go-github/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI=
|
github.com/google/go-github/v53 v53.2.0 h1:wvz3FyF53v4BK+AsnvCmeNhf8AkTaeh2SoYu/XUvTtI=
|
||||||
github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
|
github.com/google/go-github/v53 v53.2.0/go.mod h1:XhFRObz+m/l+UCm9b7KSIC3lT3NWSXGt7mOsAWEloao=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
|
|
@ -231,8 +235,8 @@ github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYt
|
||||||
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
|
github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg=
|
||||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
||||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||||
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||||
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
|
||||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/util/appdefaults"
|
"github.com/cloudbase/garm/util/appdefaults"
|
||||||
|
|
||||||
"github.com/google/go-github/v53/github"
|
"github.com/google/go-github/v53/github"
|
||||||
|
|
@ -27,13 +28,11 @@ import (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
PoolType string
|
PoolType string
|
||||||
AddressType string
|
|
||||||
EventType string
|
EventType string
|
||||||
EventLevel string
|
EventLevel string
|
||||||
OSType string
|
|
||||||
OSArch string
|
|
||||||
ProviderType string
|
ProviderType string
|
||||||
JobStatus string
|
JobStatus string
|
||||||
|
RunnerStatus string
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -55,11 +54,6 @@ const (
|
||||||
EnterprisePool PoolType = "enterprise"
|
EnterprisePool PoolType = "enterprise"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
PublicAddress AddressType = "public"
|
|
||||||
PrivateAddress AddressType = "private"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StatusEvent EventType = "status"
|
StatusEvent EventType = "status"
|
||||||
FetchTokenEvent EventType = "fetchToken"
|
FetchTokenEvent EventType = "fetchToken"
|
||||||
|
|
@ -72,23 +66,14 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Windows OSType = "windows"
|
RunnerIdle RunnerStatus = "idle"
|
||||||
Linux OSType = "linux"
|
RunnerPending RunnerStatus = "pending"
|
||||||
Unknown OSType = "unknown"
|
RunnerTerminated RunnerStatus = "terminated"
|
||||||
|
RunnerInstalling RunnerStatus = "installing"
|
||||||
|
RunnerFailed RunnerStatus = "failed"
|
||||||
|
RunnerActive RunnerStatus = "active"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
Amd64 OSArch = "amd64"
|
|
||||||
I386 OSArch = "i386"
|
|
||||||
Arm64 OSArch = "arm64"
|
|
||||||
Arm OSArch = "arm"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Address struct {
|
|
||||||
Address string `json:"address"`
|
|
||||||
Type AddressType `json:"type"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StatusMessage struct {
|
type StatusMessage struct {
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
@ -116,7 +101,7 @@ type Instance struct {
|
||||||
|
|
||||||
// OSType is the operating system type. For now, only Linux and
|
// OSType is the operating system type. For now, only Linux and
|
||||||
// Windows are supported.
|
// Windows are supported.
|
||||||
OSType OSType `json:"os_type,omitempty"`
|
OSType commonParams.OSType `json:"os_type,omitempty"`
|
||||||
|
|
||||||
// OSName is the name of the OS. Eg: ubuntu, centos, etc.
|
// OSName is the name of the OS. Eg: ubuntu, centos, etc.
|
||||||
OSName string `json:"os_name,omitempty"`
|
OSName string `json:"os_name,omitempty"`
|
||||||
|
|
@ -125,17 +110,17 @@ type Instance struct {
|
||||||
OSVersion string `json:"os_version,omitempty"`
|
OSVersion string `json:"os_version,omitempty"`
|
||||||
|
|
||||||
// OSArch is the operating system architecture.
|
// OSArch is the operating system architecture.
|
||||||
OSArch OSArch `json:"os_arch,omitempty"`
|
OSArch commonParams.OSArch `json:"os_arch,omitempty"`
|
||||||
|
|
||||||
// Addresses is a list of IP addresses the provider reports
|
// Addresses is a list of IP addresses the provider reports
|
||||||
// for this instance.
|
// for this instance.
|
||||||
Addresses []Address `json:"addresses,omitempty"`
|
Addresses []commonParams.Address `json:"addresses,omitempty"`
|
||||||
|
|
||||||
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
||||||
Status common.InstanceStatus `json:"status,omitempty"`
|
Status commonParams.InstanceStatus `json:"status,omitempty"`
|
||||||
|
|
||||||
// RunnerStatus is the github runner status as it appears on GitHub.
|
// RunnerStatus is the github runner status as it appears on GitHub.
|
||||||
RunnerStatus common.RunnerStatus `json:"runner_status,omitempty"`
|
RunnerStatus RunnerStatus `json:"runner_status,omitempty"`
|
||||||
|
|
||||||
// PoolID is the ID of the garm pool to which a runner belongs.
|
// PoolID is the ID of the garm pool to which a runner belongs.
|
||||||
PoolID string `json:"pool_id,omitempty"`
|
PoolID string `json:"pool_id,omitempty"`
|
||||||
|
|
@ -208,10 +193,10 @@ type BootstrapInstance struct {
|
||||||
CACertBundle []byte `json:"ca-cert-bundle"`
|
CACertBundle []byte `json:"ca-cert-bundle"`
|
||||||
|
|
||||||
// OSArch is the target OS CPU architecture of the runner.
|
// OSArch is the target OS CPU architecture of the runner.
|
||||||
OSArch OSArch `json:"arch"`
|
OSArch commonParams.OSArch `json:"arch"`
|
||||||
|
|
||||||
// OSType is the target OS platform of the runner (windows, linux).
|
// OSType is the target OS platform of the runner (windows, linux).
|
||||||
OSType OSType `json:"os_type"`
|
OSType commonParams.OSType `json:"os_type"`
|
||||||
|
|
||||||
// Flavor is the platform specific abstraction that defines what resources will be allocated
|
// Flavor is the platform specific abstraction that defines what resources will be allocated
|
||||||
// to the runner (CPU, RAM, disk space, etc). This field is meaningful to the provider which
|
// to the runner (CPU, RAM, disk space, etc). This field is meaningful to the provider which
|
||||||
|
|
@ -251,8 +236,8 @@ type Pool struct {
|
||||||
MinIdleRunners uint `json:"min_idle_runners"`
|
MinIdleRunners uint `json:"min_idle_runners"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Flavor string `json:"flavor"`
|
Flavor string `json:"flavor"`
|
||||||
OSType OSType `json:"os_type"`
|
OSType commonParams.OSType `json:"os_type"`
|
||||||
OSArch OSArch `json:"os_arch"`
|
OSArch commonParams.OSArch `json:"os_arch"`
|
||||||
Tags []Tag `json:"tags"`
|
Tags []Tag `json:"tags"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
Instances []Instance `json:"instances"`
|
Instances []Instance `json:"instances"`
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,16 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/errors"
|
"github.com/cloudbase/garm/errors"
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const DefaultRunnerPrefix = "garm"
|
const DefaultRunnerPrefix = "garm"
|
||||||
|
|
||||||
type InstanceRequest struct {
|
type InstanceRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
OSType OSType `json:"os_type"`
|
OSType commonParams.OSType `json:"os_type"`
|
||||||
OSVersion string `json:"os_version"`
|
OSVersion string `json:"os_version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,8 +116,8 @@ type UpdatePoolParams struct {
|
||||||
RunnerBootstrapTimeout *uint `json:"runner_bootstrap_timeout,omitempty"`
|
RunnerBootstrapTimeout *uint `json:"runner_bootstrap_timeout,omitempty"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Flavor string `json:"flavor"`
|
Flavor string `json:"flavor"`
|
||||||
OSType OSType `json:"os_type"`
|
OSType commonParams.OSType `json:"os_type"`
|
||||||
OSArch OSArch `json:"os_arch"`
|
OSArch commonParams.OSArch `json:"os_arch"`
|
||||||
ExtraSpecs json.RawMessage `json:"extra_specs,omitempty"`
|
ExtraSpecs json.RawMessage `json:"extra_specs,omitempty"`
|
||||||
// GithubRunnerGroup is the github runner group in which the runners of this
|
// GithubRunnerGroup is the github runner group in which the runners of this
|
||||||
// pool will be added to.
|
// pool will be added to.
|
||||||
|
|
@ -126,10 +127,10 @@ type UpdatePoolParams struct {
|
||||||
|
|
||||||
type CreateInstanceParams struct {
|
type CreateInstanceParams struct {
|
||||||
Name string
|
Name string
|
||||||
OSType OSType
|
OSType commonParams.OSType
|
||||||
OSArch OSArch
|
OSArch commonParams.OSArch
|
||||||
Status common.InstanceStatus
|
Status commonParams.InstanceStatus
|
||||||
RunnerStatus common.RunnerStatus
|
RunnerStatus RunnerStatus
|
||||||
CallbackURL string
|
CallbackURL string
|
||||||
MetadataURL string
|
MetadataURL string
|
||||||
// GithubRunnerGroup is the github runner group to which the runner belongs.
|
// GithubRunnerGroup is the github runner group to which the runner belongs.
|
||||||
|
|
@ -147,8 +148,8 @@ type CreatePoolParams struct {
|
||||||
MinIdleRunners uint `json:"min_idle_runners"`
|
MinIdleRunners uint `json:"min_idle_runners"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
Flavor string `json:"flavor"`
|
Flavor string `json:"flavor"`
|
||||||
OSType OSType `json:"os_type"`
|
OSType commonParams.OSType `json:"os_type"`
|
||||||
OSArch OSArch `json:"os_arch"`
|
OSArch commonParams.OSArch `json:"os_arch"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
RunnerBootstrapTimeout uint `json:"runner_bootstrap_timeout"`
|
RunnerBootstrapTimeout uint `json:"runner_bootstrap_timeout"`
|
||||||
|
|
@ -195,10 +196,10 @@ type UpdateInstanceParams struct {
|
||||||
OSVersion string `json:"os_version,omitempty"`
|
OSVersion string `json:"os_version,omitempty"`
|
||||||
// Addresses is a list of IP addresses the provider reports
|
// Addresses is a list of IP addresses the provider reports
|
||||||
// for this instance.
|
// for this instance.
|
||||||
Addresses []Address `json:"addresses,omitempty"`
|
Addresses []commonParams.Address `json:"addresses,omitempty"`
|
||||||
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
||||||
Status common.InstanceStatus `json:"status,omitempty"`
|
Status commonParams.InstanceStatus `json:"status,omitempty"`
|
||||||
RunnerStatus common.RunnerStatus `json:"runner_status,omitempty"`
|
RunnerStatus RunnerStatus `json:"runner_status,omitempty"`
|
||||||
ProviderFault []byte `json:"provider_fault,omitempty"`
|
ProviderFault []byte `json:"provider_fault,omitempty"`
|
||||||
AgentID int64 `json:"-"`
|
AgentID int64 `json:"-"`
|
||||||
CreateAttempt int `json:"-"`
|
CreateAttempt int `json:"-"`
|
||||||
|
|
@ -233,7 +234,7 @@ type UpdateEntityParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstanceUpdateMessage struct {
|
type InstanceUpdateMessage struct {
|
||||||
Status common.RunnerStatus `json:"status"`
|
Status RunnerStatus `json:"status"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
AgentID *int64 `json:"agent_id"`
|
AgentID *int64 `json:"agent_id"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,13 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/auth"
|
"github.com/cloudbase/garm/auth"
|
||||||
dbCommon "github.com/cloudbase/garm/database/common"
|
dbCommon "github.com/cloudbase/garm/database/common"
|
||||||
runnerErrors "github.com/cloudbase/garm/errors"
|
runnerErrors "github.com/cloudbase/garm/errors"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/common"
|
"github.com/cloudbase/garm/runner/common"
|
||||||
providerCommon "github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
"github.com/cloudbase/garm/util"
|
"github.com/cloudbase/garm/util"
|
||||||
|
|
||||||
"github.com/google/go-github/v53/github"
|
"github.com/google/go-github/v53/github"
|
||||||
|
|
@ -176,7 +177,7 @@ func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update instance workload state.
|
// update instance workload state.
|
||||||
if _, err := r.setInstanceRunnerStatus(jobParams.RunnerName, providerCommon.RunnerTerminated); err != nil {
|
if _, err := r.setInstanceRunnerStatus(jobParams.RunnerName, params.RunnerTerminated); err != nil {
|
||||||
if errors.Is(err, runnerErrors.ErrNotFound) {
|
if errors.Is(err, runnerErrors.ErrNotFound) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +185,7 @@ func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
|
||||||
return errors.Wrap(err, "updating runner")
|
return errors.Wrap(err, "updating runner")
|
||||||
}
|
}
|
||||||
r.log("marking instance %s as pending_delete", util.SanitizeLogEntry(jobParams.RunnerName))
|
r.log("marking instance %s as pending_delete", util.SanitizeLogEntry(jobParams.RunnerName))
|
||||||
if _, err := r.setInstanceStatus(jobParams.RunnerName, providerCommon.InstancePendingDelete, nil); err != nil {
|
if _, err := r.setInstanceStatus(jobParams.RunnerName, commonParams.InstancePendingDelete, nil); err != nil {
|
||||||
if errors.Is(err, runnerErrors.ErrNotFound) {
|
if errors.Is(err, runnerErrors.ErrNotFound) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +207,7 @@ func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update instance workload state.
|
// update instance workload state.
|
||||||
instance, err := r.setInstanceRunnerStatus(jobParams.RunnerName, providerCommon.RunnerActive)
|
instance, err := r.setInstanceRunnerStatus(jobParams.RunnerName, params.RunnerActive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, runnerErrors.ErrNotFound) {
|
if errors.Is(err, runnerErrors.ErrNotFound) {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -370,9 +371,9 @@ func (r *basePoolManager) cleanupOrphanedProviderRunners(runners []*github.Runne
|
||||||
}
|
}
|
||||||
defer r.keyMux.Unlock(instance.Name, false)
|
defer r.keyMux.Unlock(instance.Name, false)
|
||||||
|
|
||||||
switch providerCommon.InstanceStatus(instance.Status) {
|
switch commonParams.InstanceStatus(instance.Status) {
|
||||||
case providerCommon.InstancePendingCreate,
|
case commonParams.InstancePendingCreate,
|
||||||
providerCommon.InstancePendingDelete:
|
commonParams.InstancePendingDelete:
|
||||||
// this instance is in the process of being created or is awaiting deletion.
|
// this instance is in the process of being created or is awaiting deletion.
|
||||||
// Instances in pending_create did not get a chance to register themselves in,
|
// Instances in pending_create did not get a chance to register themselves in,
|
||||||
// github so we let them be for now.
|
// github so we let them be for now.
|
||||||
|
|
@ -380,7 +381,7 @@ func (r *basePoolManager) cleanupOrphanedProviderRunners(runners []*github.Runne
|
||||||
}
|
}
|
||||||
|
|
||||||
switch instance.RunnerStatus {
|
switch instance.RunnerStatus {
|
||||||
case providerCommon.RunnerPending, providerCommon.RunnerInstalling:
|
case params.RunnerPending, params.RunnerInstalling:
|
||||||
// runner is still installing. We give it a chance to finish.
|
// runner is still installing. We give it a chance to finish.
|
||||||
r.log("runner %s is still installing, give it a chance to finish", instance.Name)
|
r.log("runner %s is still installing, give it a chance to finish", instance.Name)
|
||||||
continue
|
continue
|
||||||
|
|
@ -394,7 +395,7 @@ func (r *basePoolManager) cleanupOrphanedProviderRunners(runners []*github.Runne
|
||||||
|
|
||||||
if ok := runnerNames[instance.Name]; !ok {
|
if ok := runnerNames[instance.Name]; !ok {
|
||||||
// Set pending_delete on DB field. Allow consolidate() to remove it.
|
// Set pending_delete on DB field. Allow consolidate() to remove it.
|
||||||
if _, err := r.setInstanceStatus(instance.Name, providerCommon.InstancePendingDelete, nil); err != nil {
|
if _, err := r.setInstanceStatus(instance.Name, commonParams.InstancePendingDelete, nil); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", instance.Name, err)
|
r.log("failed to update runner %s status: %s", instance.Name, err)
|
||||||
return errors.Wrap(err, "updating runner")
|
return errors.Wrap(err, "updating runner")
|
||||||
}
|
}
|
||||||
|
|
@ -455,7 +456,7 @@ func (r *basePoolManager) reapTimedOutRunners(runners []*github.Runner) error {
|
||||||
// even though, technically the runner is online and fully functional. This is why we check here for
|
// even though, technically the runner is online and fully functional. This is why we check here for
|
||||||
// both the runner status as reported by GitHub and the runner status as reported by the provider.
|
// both the runner status as reported by GitHub and the runner status as reported by the provider.
|
||||||
// If the runner is "offline" and marked as "failed", it should be safe to reap it.
|
// If the runner is "offline" and marked as "failed", it should be safe to reap it.
|
||||||
if runner, ok := runnersByName[instance.Name]; !ok || (runner.GetStatus() == "offline" && instance.RunnerStatus == providerCommon.RunnerFailed) {
|
if runner, ok := runnersByName[instance.Name]; !ok || (runner.GetStatus() == "offline" && instance.RunnerStatus == params.RunnerFailed) {
|
||||||
r.log("reaping timed-out/failed runner %s", instance.Name)
|
r.log("reaping timed-out/failed runner %s", instance.Name)
|
||||||
if err := r.ForceDeleteRunner(instance); err != nil {
|
if err := r.ForceDeleteRunner(instance); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", instance.Name, err)
|
r.log("failed to update runner %s status: %s", instance.Name, err)
|
||||||
|
|
@ -513,8 +514,8 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
switch providerCommon.InstanceStatus(dbInstance.Status) {
|
switch commonParams.InstanceStatus(dbInstance.Status) {
|
||||||
case providerCommon.InstancePendingDelete, providerCommon.InstanceDeleting:
|
case commonParams.InstancePendingDelete, commonParams.InstanceDeleting:
|
||||||
// already marked for deletion or is in the process of being deleted.
|
// already marked for deletion or is in the process of being deleted.
|
||||||
// Let consolidate take care of it.
|
// Let consolidate take care of it.
|
||||||
continue
|
continue
|
||||||
|
|
@ -578,7 +579,7 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if providerInstance.Status == providerCommon.InstanceRunning {
|
if providerInstance.Status == commonParams.InstanceRunning {
|
||||||
// instance is running, but github reports runner as offline. Log the event.
|
// instance is running, but github reports runner as offline. Log the event.
|
||||||
// This scenario may require manual intervention.
|
// This scenario may require manual intervention.
|
||||||
// Perhaps it just came online and github did not yet change it's status?
|
// Perhaps it just came online and github did not yet change it's status?
|
||||||
|
|
@ -633,7 +634,7 @@ func (r *basePoolManager) fetchInstance(runnerName string) (params.Instance, err
|
||||||
return runner, nil
|
return runner, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *basePoolManager) setInstanceRunnerStatus(runnerName string, status providerCommon.RunnerStatus) (params.Instance, error) {
|
func (r *basePoolManager) setInstanceRunnerStatus(runnerName string, status params.RunnerStatus) (params.Instance, error) {
|
||||||
updateParams := params.UpdateInstanceParams{
|
updateParams := params.UpdateInstanceParams{
|
||||||
RunnerStatus: status,
|
RunnerStatus: status,
|
||||||
}
|
}
|
||||||
|
|
@ -658,7 +659,7 @@ func (r *basePoolManager) updateInstance(runnerName string, update params.Update
|
||||||
return instance, nil
|
return instance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *basePoolManager) setInstanceStatus(runnerName string, status providerCommon.InstanceStatus, providerFault []byte) (params.Instance, error) {
|
func (r *basePoolManager) setInstanceStatus(runnerName string, status commonParams.InstanceStatus, providerFault []byte) (params.Instance, error) {
|
||||||
updateParams := params.UpdateInstanceParams{
|
updateParams := params.UpdateInstanceParams{
|
||||||
Status: status,
|
Status: status,
|
||||||
ProviderFault: providerFault,
|
ProviderFault: providerFault,
|
||||||
|
|
@ -681,8 +682,8 @@ func (r *basePoolManager) AddRunner(ctx context.Context, poolID string, aditiona
|
||||||
|
|
||||||
createParams := params.CreateInstanceParams{
|
createParams := params.CreateInstanceParams{
|
||||||
Name: name,
|
Name: name,
|
||||||
Status: providerCommon.InstancePendingCreate,
|
Status: commonParams.InstancePendingCreate,
|
||||||
RunnerStatus: providerCommon.RunnerPending,
|
RunnerStatus: params.RunnerPending,
|
||||||
OSArch: pool.OSArch,
|
OSArch: pool.OSArch,
|
||||||
OSType: pool.OSType,
|
OSType: pool.OSType,
|
||||||
CallbackURL: r.helper.GetCallbackURL(),
|
CallbackURL: r.helper.GetCallbackURL(),
|
||||||
|
|
@ -787,7 +788,7 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error
|
||||||
return errors.Wrap(err, "creating instance")
|
return errors.Wrap(err, "creating instance")
|
||||||
}
|
}
|
||||||
|
|
||||||
if providerInstance.Status == providerCommon.InstanceError {
|
if providerInstance.Status == commonParams.InstanceError {
|
||||||
instanceIDToDelete = instance.ProviderID
|
instanceIDToDelete = instance.ProviderID
|
||||||
if instanceIDToDelete == "" {
|
if instanceIDToDelete == "" {
|
||||||
instanceIDToDelete = instance.Name
|
instanceIDToDelete = instance.Name
|
||||||
|
|
@ -939,7 +940,7 @@ func (r *basePoolManager) scaleDownOnePool(ctx context.Context, pool params.Pool
|
||||||
// consideration for scale-down. The 5 minute grace period prevents a situation where a
|
// consideration for scale-down. The 5 minute grace period prevents a situation where a
|
||||||
// "queued" workflow triggers the creation of a new idle runner, and this routine reaps
|
// "queued" workflow triggers the creation of a new idle runner, and this routine reaps
|
||||||
// an idle runner before they have a chance to pick up a job.
|
// an idle runner before they have a chance to pick up a job.
|
||||||
if inst.RunnerStatus == providerCommon.RunnerIdle && inst.Status == providerCommon.InstanceRunning && time.Since(inst.UpdatedAt).Minutes() > 2 {
|
if inst.RunnerStatus == params.RunnerIdle && inst.Status == commonParams.InstanceRunning && time.Since(inst.UpdatedAt).Minutes() > 2 {
|
||||||
idleWorkers = append(idleWorkers, inst)
|
idleWorkers = append(idleWorkers, inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1026,7 +1027,7 @@ func (r *basePoolManager) ensureIdleRunnersForOnePool(pool params.Pool) error {
|
||||||
|
|
||||||
idleOrPendingWorkers := []params.Instance{}
|
idleOrPendingWorkers := []params.Instance{}
|
||||||
for _, inst := range existingInstances {
|
for _, inst := range existingInstances {
|
||||||
if inst.RunnerStatus != providerCommon.RunnerActive && inst.RunnerStatus != providerCommon.RunnerTerminated {
|
if inst.RunnerStatus != params.RunnerActive && inst.RunnerStatus != params.RunnerTerminated {
|
||||||
idleOrPendingWorkers = append(idleOrPendingWorkers, inst)
|
idleOrPendingWorkers = append(idleOrPendingWorkers, inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1066,7 +1067,7 @@ func (r *basePoolManager) retryFailedInstancesForOnePool(ctx context.Context, po
|
||||||
|
|
||||||
g, errCtx := errgroup.WithContext(ctx)
|
g, errCtx := errgroup.WithContext(ctx)
|
||||||
for _, instance := range existingInstances {
|
for _, instance := range existingInstances {
|
||||||
if instance.Status != providerCommon.InstanceError {
|
if instance.Status != commonParams.InstanceError {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if instance.CreateAttempt >= maxCreateAttempts {
|
if instance.CreateAttempt >= maxCreateAttempts {
|
||||||
|
|
@ -1105,7 +1106,7 @@ func (r *basePoolManager) retryFailedInstancesForOnePool(ctx context.Context, po
|
||||||
updateParams := params.UpdateInstanceParams{
|
updateParams := params.UpdateInstanceParams{
|
||||||
CreateAttempt: instance.CreateAttempt + 1,
|
CreateAttempt: instance.CreateAttempt + 1,
|
||||||
TokenFetched: &tokenFetched,
|
TokenFetched: &tokenFetched,
|
||||||
Status: providerCommon.InstancePendingCreate,
|
Status: commonParams.InstancePendingCreate,
|
||||||
}
|
}
|
||||||
r.log("queueing previously failed instance %s for retry", instance.Name)
|
r.log("queueing previously failed instance %s for retry", instance.Name)
|
||||||
// Set instance to pending create and wait for retry.
|
// Set instance to pending create and wait for retry.
|
||||||
|
|
@ -1216,7 +1217,7 @@ func (r *basePoolManager) deletePendingInstances() error {
|
||||||
|
|
||||||
r.log("removing instances in pending_delete")
|
r.log("removing instances in pending_delete")
|
||||||
for _, instance := range instances {
|
for _, instance := range instances {
|
||||||
if instance.Status != providerCommon.InstancePendingDelete {
|
if instance.Status != commonParams.InstancePendingDelete {
|
||||||
// not in pending_delete status. Skip.
|
// not in pending_delete status. Skip.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -1230,7 +1231,7 @@ func (r *basePoolManager) deletePendingInstances() error {
|
||||||
|
|
||||||
// Set the status to deleting before launching the goroutine that removes
|
// Set the status to deleting before launching the goroutine that removes
|
||||||
// the runner from the provider (which can take a long time).
|
// the runner from the provider (which can take a long time).
|
||||||
if _, err := r.setInstanceStatus(instance.Name, providerCommon.InstanceDeleting, nil); err != nil {
|
if _, err := r.setInstanceStatus(instance.Name, commonParams.InstanceDeleting, nil); err != nil {
|
||||||
r.log("failed to update runner %s status: %q", instance.Name, err)
|
r.log("failed to update runner %s status: %q", instance.Name, err)
|
||||||
r.keyMux.Unlock(instance.Name, false)
|
r.keyMux.Unlock(instance.Name, false)
|
||||||
continue
|
continue
|
||||||
|
|
@ -1246,7 +1247,7 @@ func (r *basePoolManager) deletePendingInstances() error {
|
||||||
r.log("failed to remove instance %s: %s", instance.Name, err)
|
r.log("failed to remove instance %s: %s", instance.Name, err)
|
||||||
// failed to remove from provider. Set the status back to pending_delete, which
|
// failed to remove from provider. Set the status back to pending_delete, which
|
||||||
// will retry the operation.
|
// will retry the operation.
|
||||||
if _, err := r.setInstanceStatus(instance.Name, providerCommon.InstancePendingDelete, nil); err != nil {
|
if _, err := r.setInstanceStatus(instance.Name, commonParams.InstancePendingDelete, nil); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", instance.Name, err)
|
r.log("failed to update runner %s status: %s", instance.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1277,7 +1278,7 @@ func (r *basePoolManager) addPendingInstances() error {
|
||||||
return fmt.Errorf("failed to fetch instances from store: %w", err)
|
return fmt.Errorf("failed to fetch instances from store: %w", err)
|
||||||
}
|
}
|
||||||
for _, instance := range instances {
|
for _, instance := range instances {
|
||||||
if instance.Status != providerCommon.InstancePendingCreate {
|
if instance.Status != commonParams.InstancePendingCreate {
|
||||||
// not in pending_create status. Skip.
|
// not in pending_create status. Skip.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -1291,7 +1292,7 @@ func (r *basePoolManager) addPendingInstances() error {
|
||||||
|
|
||||||
// Set the instance to "creating" before launching the goroutine. This will ensure that addPendingInstances()
|
// Set the instance to "creating" before launching the goroutine. This will ensure that addPendingInstances()
|
||||||
// won't attempt to create the runner a second time.
|
// won't attempt to create the runner a second time.
|
||||||
if _, err := r.setInstanceStatus(instance.Name, providerCommon.InstanceCreating, nil); err != nil {
|
if _, err := r.setInstanceStatus(instance.Name, commonParams.InstanceCreating, nil); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", instance.Name, err)
|
r.log("failed to update runner %s status: %s", instance.Name, err)
|
||||||
r.keyMux.Unlock(instance.Name, false)
|
r.keyMux.Unlock(instance.Name, false)
|
||||||
// We failed to transition the instance to Creating. This means that garm will retry to create this instance
|
// We failed to transition the instance to Creating. This means that garm will retry to create this instance
|
||||||
|
|
@ -1305,7 +1306,7 @@ func (r *basePoolManager) addPendingInstances() error {
|
||||||
if err := r.addInstanceToProvider(instance); err != nil {
|
if err := r.addInstanceToProvider(instance); err != nil {
|
||||||
r.log("failed to add instance to provider: %s", err)
|
r.log("failed to add instance to provider: %s", err)
|
||||||
errAsBytes := []byte(err.Error())
|
errAsBytes := []byte(err.Error())
|
||||||
if _, err := r.setInstanceStatus(instance.Name, providerCommon.InstanceError, errAsBytes); err != nil {
|
if _, err := r.setInstanceStatus(instance.Name, commonParams.InstanceError, errAsBytes); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", instance.Name, err)
|
r.log("failed to update runner %s status: %s", instance.Name, err)
|
||||||
}
|
}
|
||||||
r.log("failed to create instance in provider: %s", err)
|
r.log("failed to create instance in provider: %s", err)
|
||||||
|
|
@ -1431,7 +1432,7 @@ func (r *basePoolManager) ForceDeleteRunner(runner params.Instance) error {
|
||||||
}
|
}
|
||||||
r.log("setting instance status for: %v", runner.Name)
|
r.log("setting instance status for: %v", runner.Name)
|
||||||
|
|
||||||
if _, err := r.setInstanceStatus(runner.Name, providerCommon.InstancePendingDelete, nil); err != nil {
|
if _, err := r.setInstanceStatus(runner.Name, commonParams.InstancePendingDelete, nil); err != nil {
|
||||||
r.log("failed to update runner %s status: %s", runner.Name, err)
|
r.log("failed to update runner %s status: %s", runner.Name, err)
|
||||||
return errors.Wrap(err, "updating runner")
|
return errors.Wrap(err, "updating runner")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
// Copyright 2022 Cloudbase Solutions SRL
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
// not use this file except in compliance with the License. You may obtain
|
|
||||||
// a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
// License for the specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
|
|
||||||
package common
|
|
||||||
|
|
||||||
type InstanceStatus string
|
|
||||||
type RunnerStatus string
|
|
||||||
|
|
||||||
const (
|
|
||||||
InstanceRunning InstanceStatus = "running"
|
|
||||||
InstanceStopped InstanceStatus = "stopped"
|
|
||||||
InstanceError InstanceStatus = "error"
|
|
||||||
InstancePendingDelete InstanceStatus = "pending_delete"
|
|
||||||
InstanceDeleting InstanceStatus = "deleting"
|
|
||||||
InstancePendingCreate InstanceStatus = "pending_create"
|
|
||||||
InstanceCreating InstanceStatus = "creating"
|
|
||||||
InstanceStatusUnknown InstanceStatus = "unknown"
|
|
||||||
|
|
||||||
RunnerIdle RunnerStatus = "idle"
|
|
||||||
RunnerPending RunnerStatus = "pending"
|
|
||||||
RunnerTerminated RunnerStatus = "terminated"
|
|
||||||
RunnerInstalling RunnerStatus = "installing"
|
|
||||||
RunnerFailed RunnerStatus = "failed"
|
|
||||||
RunnerActive RunnerStatus = "active"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsValidStatus checks if the given status is valid.
|
|
||||||
func IsValidStatus(status InstanceStatus) bool {
|
|
||||||
switch status {
|
|
||||||
case InstanceRunning, InstanceError, InstancePendingCreate,
|
|
||||||
InstancePendingDelete, InstanceStatusUnknown, InstanceStopped,
|
|
||||||
InstanceCreating, InstanceDeleting:
|
|
||||||
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsProviderValidStatus checks if the given status is valid for the provider.
|
|
||||||
// A provider should only return a status indicating that the instance is in a
|
|
||||||
// lifecycle state that it can influence. The sole purpose of a provider is to
|
|
||||||
// manage the lifecycle of an instance. Statuses that indicate an instance should
|
|
||||||
// be created or removed, will be set by the controller.
|
|
||||||
func IsValidProviderStatus(status InstanceStatus) bool {
|
|
||||||
switch status {
|
|
||||||
case InstanceRunning, InstanceError, InstanceStopped:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package execution
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
gErrors "github.com/cloudbase/garm/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// ExitCodeNotFound is an exit code that indicates a Not Found error
|
|
||||||
ExitCodeNotFound int = 30
|
|
||||||
// ExitCodeDuplicate is an exit code that indicates a duplicate error
|
|
||||||
ExitCodeDuplicate int = 31
|
|
||||||
)
|
|
||||||
|
|
||||||
func ResolveErrorToExitCode(err error) int {
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gErrors.ErrNotFound) {
|
|
||||||
return ExitCodeNotFound
|
|
||||||
} else if errors.Is(err, gErrors.ErrDuplicateEntity) {
|
|
||||||
return ExitCodeDuplicate
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
26
runner/providers/external/external.go
vendored
26
runner/providers/external/external.go
vendored
|
|
@ -7,12 +7,14 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/cloudbase/garm-provider-common/execution"
|
||||||
|
|
||||||
|
providerParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/config"
|
"github.com/cloudbase/garm/config"
|
||||||
garmErrors "github.com/cloudbase/garm/errors"
|
garmErrors "github.com/cloudbase/garm/errors"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/common"
|
"github.com/cloudbase/garm/runner/common"
|
||||||
providerCommon "github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
"github.com/cloudbase/garm/runner/providers/external/execution"
|
|
||||||
garmExec "github.com/cloudbase/garm/util/exec"
|
garmExec "github.com/cloudbase/garm/util/exec"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -44,7 +46,7 @@ type external struct {
|
||||||
execPath string
|
execPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *external) validateResult(inst params.Instance) error {
|
func (e *external) validateResult(inst providerParams.ProviderInstance) error {
|
||||||
if inst.ProviderID == "" {
|
if inst.ProviderID == "" {
|
||||||
return garmErrors.NewProviderError("missing provider ID")
|
return garmErrors.NewProviderError("missing provider ID")
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +59,7 @@ func (e *external) validateResult(inst params.Instance) error {
|
||||||
// we can still function without this info (I think)
|
// we can still function without this info (I think)
|
||||||
log.Printf("WARNING: missing OS information")
|
log.Printf("WARNING: missing OS information")
|
||||||
}
|
}
|
||||||
if !providerCommon.IsValidProviderStatus(inst.Status) {
|
if !IsValidProviderStatus(inst.Status) {
|
||||||
return garmErrors.NewProviderError("invalid status returned (%s)", inst.Status)
|
return garmErrors.NewProviderError("invalid status returned (%s)", inst.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,7 +85,7 @@ func (e *external) CreateInstance(ctx context.Context, bootstrapParams params.Bo
|
||||||
return params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
return params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var param params.Instance
|
var param providerParams.ProviderInstance
|
||||||
if err := json.Unmarshal(out, ¶m); err != nil {
|
if err := json.Unmarshal(out, ¶m); err != nil {
|
||||||
return params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
return params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +96,7 @@ func (e *external) CreateInstance(ctx context.Context, bootstrapParams params.Bo
|
||||||
|
|
||||||
retAsJs, _ := json.MarshalIndent(param, "", " ")
|
retAsJs, _ := json.MarshalIndent(param, "", " ")
|
||||||
log.Printf("provider returned: %s", string(retAsJs))
|
log.Printf("provider returned: %s", string(retAsJs))
|
||||||
return param, nil
|
return providerInstanceToParamsInstance(param), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete instance will delete the instance in a provider.
|
// Delete instance will delete the instance in a provider.
|
||||||
|
|
@ -133,7 +135,7 @@ func (e *external) GetInstance(ctx context.Context, instance string) (params.Ins
|
||||||
return params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
return params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var param params.Instance
|
var param providerParams.ProviderInstance
|
||||||
if err := json.Unmarshal(out, ¶m); err != nil {
|
if err := json.Unmarshal(out, ¶m); err != nil {
|
||||||
return params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
return params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +144,7 @@ func (e *external) GetInstance(ctx context.Context, instance string) (params.Ins
|
||||||
return params.Instance{}, garmErrors.NewProviderError("failed to validate result: %s", err)
|
return params.Instance{}, garmErrors.NewProviderError("failed to validate result: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return param, nil
|
return providerInstanceToParamsInstance(param), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListInstances will list all instances for a provider.
|
// ListInstances will list all instances for a provider.
|
||||||
|
|
@ -159,17 +161,19 @@ func (e *external) ListInstances(ctx context.Context, poolID string) ([]params.I
|
||||||
return []params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
return []params.Instance{}, garmErrors.NewProviderError("provider binary %s returned error: %s", e.execPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var param []params.Instance
|
var param []providerParams.ProviderInstance
|
||||||
if err := json.Unmarshal(out, ¶m); err != nil {
|
if err := json.Unmarshal(out, ¶m); err != nil {
|
||||||
return []params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
return []params.Instance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, inst := range param {
|
ret := make([]params.Instance, len(param))
|
||||||
|
for idx, inst := range param {
|
||||||
if err := e.validateResult(inst); err != nil {
|
if err := e.validateResult(inst); err != nil {
|
||||||
return []params.Instance{}, garmErrors.NewProviderError("failed to validate result: %s", err)
|
return []params.Instance{}, garmErrors.NewProviderError("failed to validate result: %s", err)
|
||||||
}
|
}
|
||||||
|
ret[idx] = providerInstanceToParamsInstance(inst)
|
||||||
}
|
}
|
||||||
return param, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveAllInstances will remove all instances created by this provider.
|
// RemoveAllInstances will remove all instances created by this provider.
|
||||||
|
|
|
||||||
33
runner/providers/external/util.go
vendored
Normal file
33
runner/providers/external/util.go
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package external
|
||||||
|
|
||||||
|
import (
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
"github.com/cloudbase/garm/params"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsProviderValidStatus checks if the given status is valid for the provider.
|
||||||
|
// A provider should only return a status indicating that the instance is in a
|
||||||
|
// lifecycle state that it can influence. The sole purpose of a provider is to
|
||||||
|
// manage the lifecycle of an instance. Statuses that indicate an instance should
|
||||||
|
// be created or removed, will be set by the controller.
|
||||||
|
func IsValidProviderStatus(status commonParams.InstanceStatus) bool {
|
||||||
|
switch status {
|
||||||
|
case commonParams.InstanceRunning, commonParams.InstanceError,
|
||||||
|
commonParams.InstanceStopped, commonParams.InstanceStatusUnknown:
|
||||||
|
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func providerInstanceToParamsInstance(inst commonParams.ProviderInstance) params.Instance {
|
||||||
|
return params.Instance{
|
||||||
|
ProviderID: inst.ProviderID,
|
||||||
|
Name: inst.Name,
|
||||||
|
OSName: inst.OSName,
|
||||||
|
OSArch: inst.OSArch,
|
||||||
|
OSType: inst.OSType,
|
||||||
|
Status: inst.Status,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -31,6 +31,8 @@ import (
|
||||||
lxd "github.com/lxc/lxd/client"
|
lxd "github.com/lxc/lxd/client"
|
||||||
"github.com/lxc/lxd/shared/api"
|
"github.com/lxc/lxd/shared/api"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ common.Provider = &LXD{}
|
var _ common.Provider = &LXD{}
|
||||||
|
|
@ -66,16 +68,16 @@ var (
|
||||||
"arm64": "arm64",
|
"arm64": "arm64",
|
||||||
}
|
}
|
||||||
|
|
||||||
configToLXDArchMap map[params.OSArch]string = map[params.OSArch]string{
|
configToLXDArchMap map[commonParams.OSArch]string = map[commonParams.OSArch]string{
|
||||||
params.Amd64: "x86_64",
|
commonParams.Amd64: "x86_64",
|
||||||
params.Arm64: "aarch64",
|
commonParams.Arm64: "aarch64",
|
||||||
params.Arm: "armv7l",
|
commonParams.Arm: "armv7l",
|
||||||
}
|
}
|
||||||
|
|
||||||
lxdToConfigArch map[string]params.OSArch = map[string]params.OSArch{
|
lxdToConfigArch map[string]commonParams.OSArch = map[string]commonParams.OSArch{
|
||||||
"x86_64": params.Amd64,
|
"x86_64": commonParams.Amd64,
|
||||||
"aarch64": params.Arm64,
|
"aarch64": commonParams.Arm64,
|
||||||
"armv7l": params.Arm,
|
"armv7l": commonParams.Arm,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -171,10 +173,10 @@ func (l *LXD) getProfiles(flavor string) ([]string, error) {
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *LXD) getTools(tools []*github.RunnerApplicationDownload, osType params.OSType, architecture string) (github.RunnerApplicationDownload, error) {
|
func (l *LXD) getTools(tools []*github.RunnerApplicationDownload, osType commonParams.OSType, architecture string) (github.RunnerApplicationDownload, error) {
|
||||||
// Validate image OS. Linux only for now.
|
// Validate image OS. Linux only for now.
|
||||||
switch osType {
|
switch osType {
|
||||||
case params.Linux:
|
case commonParams.Linux:
|
||||||
default:
|
default:
|
||||||
return github.RunnerApplicationDownload{}, fmt.Errorf("this provider does not support OS type: %s", osType)
|
return github.RunnerApplicationDownload{}, fmt.Errorf("this provider does not support OS type: %s", osType)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/config"
|
"github.com/cloudbase/garm/config"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
"github.com/cloudbase/garm/util"
|
"github.com/cloudbase/garm/util"
|
||||||
|
|
||||||
"github.com/juju/clock"
|
"github.com/juju/clock"
|
||||||
|
|
@ -77,7 +78,7 @@ func lxdInstanceToAPIInstance(instance *api.InstanceFull) params.Instance {
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("failed to find OS type in fallback location")
|
log.Printf("failed to find OS type in fallback location")
|
||||||
}
|
}
|
||||||
osType = params.OSType(osTypeFromTag)
|
osType = commonParams.OSType(osTypeFromTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
osRelease, ok := instance.ExpandedConfig["image.release"]
|
osRelease, ok := instance.ExpandedConfig["image.release"]
|
||||||
|
|
@ -86,16 +87,16 @@ func lxdInstanceToAPIInstance(instance *api.InstanceFull) params.Instance {
|
||||||
}
|
}
|
||||||
|
|
||||||
state := instance.State
|
state := instance.State
|
||||||
addresses := []params.Address{}
|
addresses := []commonParams.Address{}
|
||||||
if state.Network != nil {
|
if state.Network != nil {
|
||||||
for _, details := range state.Network {
|
for _, details := range state.Network {
|
||||||
for _, addr := range details.Addresses {
|
for _, addr := range details.Addresses {
|
||||||
if addr.Scope != "global" {
|
if addr.Scope != "global" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
addresses = append(addresses, params.Address{
|
addresses = append(addresses, commonParams.Address{
|
||||||
Address: addr.Address,
|
Address: addr.Address,
|
||||||
Type: params.PublicAddress,
|
Type: commonParams.PublicAddress,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,14 +119,14 @@ func lxdInstanceToAPIInstance(instance *api.InstanceFull) params.Instance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func lxdStatusToProviderStatus(status string) common.InstanceStatus {
|
func lxdStatusToProviderStatus(status string) commonParams.InstanceStatus {
|
||||||
switch status {
|
switch status {
|
||||||
case "Running":
|
case "Running":
|
||||||
return common.InstanceRunning
|
return commonParams.InstanceRunning
|
||||||
case "Stopped":
|
case "Stopped":
|
||||||
return common.InstanceStopped
|
return commonParams.InstanceStopped
|
||||||
default:
|
default:
|
||||||
return common.InstanceStatusUnknown
|
return commonParams.InstanceStatusUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,9 +187,9 @@ func projectName(cfg config.LXD) string {
|
||||||
return DefaultProjectName
|
return DefaultProjectName
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveArchitecture(osArch params.OSArch) (string, error) {
|
func resolveArchitecture(osArch commonParams.OSArch) (string, error) {
|
||||||
if string(osArch) == "" {
|
if string(osArch) == "" {
|
||||||
return configToLXDArchMap[params.Amd64], nil
|
return configToLXDArchMap[commonParams.Amd64], nil
|
||||||
}
|
}
|
||||||
arch, ok := configToLXDArchMap[osArch]
|
arch, ok := configToLXDArchMap[osArch]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/auth"
|
"github.com/cloudbase/garm/auth"
|
||||||
"github.com/cloudbase/garm/config"
|
"github.com/cloudbase/garm/config"
|
||||||
dbCommon "github.com/cloudbase/garm/database/common"
|
dbCommon "github.com/cloudbase/garm/database/common"
|
||||||
|
|
@ -37,7 +39,6 @@ import (
|
||||||
"github.com/cloudbase/garm/runner/common"
|
"github.com/cloudbase/garm/runner/common"
|
||||||
"github.com/cloudbase/garm/runner/pool"
|
"github.com/cloudbase/garm/runner/pool"
|
||||||
"github.com/cloudbase/garm/runner/providers"
|
"github.com/cloudbase/garm/runner/providers"
|
||||||
providerCommon "github.com/cloudbase/garm/runner/providers/common"
|
|
||||||
"github.com/cloudbase/garm/util"
|
"github.com/cloudbase/garm/util"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
|
|
@ -761,7 +762,7 @@ func (r *Runner) appendTagsToCreatePoolParams(param params.CreatePoolParams) (pa
|
||||||
return param, nil
|
return param, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runner) processTags(osArch string, osType params.OSType, tags []string) ([]string, error) {
|
func (r *Runner) processTags(osArch string, osType commonParams.OSType, tags []string) ([]string, error) {
|
||||||
// github automatically adds the "self-hosted" tag as well as the OS type (linux, windows, etc)
|
// github automatically adds the "self-hosted" tag as well as the OS type (linux, windows, etc)
|
||||||
// and architecture (arm, x64, etc) to all self hosted runners. When a workflow job comes in, we try
|
// and architecture (arm, x64, etc) to all self hosted runners. When a workflow job comes in, we try
|
||||||
// to find a pool based on the labels that are set in the workflow. If we don't explicitly define these
|
// to find a pool based on the labels that are set in the workflow. If we don't explicitly define these
|
||||||
|
|
@ -857,7 +858,7 @@ func (r *Runner) GetInstanceGithubRegistrationToken(ctx context.Context) (string
|
||||||
}
|
}
|
||||||
|
|
||||||
status := auth.InstanceRunnerStatus(ctx)
|
status := auth.InstanceRunnerStatus(ctx)
|
||||||
if status != providerCommon.RunnerPending && status != providerCommon.RunnerInstalling {
|
if status != params.RunnerPending && status != params.RunnerInstalling {
|
||||||
return "", runnerErrors.ErrUnauthorized
|
return "", runnerErrors.ErrUnauthorized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -943,9 +944,9 @@ func (r *Runner) ForceDeleteRunner(ctx context.Context, instanceName string) err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch instance.Status {
|
switch instance.Status {
|
||||||
case providerCommon.InstanceRunning, providerCommon.InstanceError:
|
case commonParams.InstanceRunning, commonParams.InstanceError:
|
||||||
default:
|
default:
|
||||||
return runnerErrors.NewBadRequestError("runner must be in %q or %q state", providerCommon.InstanceRunning, providerCommon.InstanceError)
|
return runnerErrors.NewBadRequestError("runner must be in %q or %q state", commonParams.InstanceRunning, commonParams.InstanceError)
|
||||||
}
|
}
|
||||||
|
|
||||||
poolMgr, err := r.getPoolManagerFromInstance(ctx, instance)
|
poolMgr, err := r.getPoolManagerFromInstance(ctx, instance)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package runner
|
package runner
|
||||||
|
|
||||||
import "github.com/cloudbase/garm/params"
|
import "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
type HookTargetType string
|
type HookTargetType string
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,6 @@ const (
|
||||||
// configuration file.
|
// configuration file.
|
||||||
DefaultConfigFilePath = "/etc/garm/config.toml"
|
DefaultConfigFilePath = "/etc/garm/config.toml"
|
||||||
|
|
||||||
// DefaultUser is the default username that should exist on the instances.
|
|
||||||
DefaultUser = "runner"
|
|
||||||
// DefaultUserShell is the shell for the default user.
|
|
||||||
DefaultUserShell = "/bin/bash"
|
|
||||||
|
|
||||||
// DefaultPoolQueueSize is the default size for a pool queue.
|
// DefaultPoolQueueSize is the default size for a pool queue.
|
||||||
DefaultPoolQueueSize = 10
|
DefaultPoolQueueSize = 10
|
||||||
|
|
||||||
|
|
@ -33,12 +28,3 @@ const (
|
||||||
// uploadBaseURL is the default URL for guthub uploads.
|
// uploadBaseURL is the default URL for guthub uploads.
|
||||||
GithubDefaultUploadBaseURL = "https://uploads.github.com/"
|
GithubDefaultUploadBaseURL = "https://uploads.github.com/"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// DefaultUserGroups are the groups the default user will be part of.
|
|
||||||
DefaultUserGroups = []string{
|
|
||||||
"sudo", "adm", "cdrom", "dialout",
|
|
||||||
"dip", "video", "plugdev", "netdev",
|
|
||||||
"docker", "lxd",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
|
||||||
76
util/util.go
76
util/util.go
|
|
@ -36,12 +36,14 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/cloudconfig"
|
"github.com/cloudbase/garm-provider-common/cloudconfig"
|
||||||
"github.com/cloudbase/garm/config"
|
"github.com/cloudbase/garm/config"
|
||||||
runnerErrors "github.com/cloudbase/garm/errors"
|
runnerErrors "github.com/cloudbase/garm/errors"
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm/params"
|
||||||
"github.com/cloudbase/garm/runner/common"
|
"github.com/cloudbase/garm/runner/common"
|
||||||
"github.com/cloudbase/garm/util/appdefaults"
|
|
||||||
|
"github.com/cloudbase/garm-provider-common/defaults"
|
||||||
|
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/google/go-github/v53/github"
|
"github.com/google/go-github/v53/github"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
@ -59,24 +61,24 @@ const alphanumeric = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv
|
||||||
var rxEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
var rxEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
OSToOSTypeMap map[string]params.OSType = map[string]params.OSType{
|
OSToOSTypeMap map[string]commonParams.OSType = map[string]commonParams.OSType{
|
||||||
"almalinux": params.Linux,
|
"almalinux": commonParams.Linux,
|
||||||
"alma": params.Linux,
|
"alma": commonParams.Linux,
|
||||||
"alpine": params.Linux,
|
"alpine": commonParams.Linux,
|
||||||
"archlinux": params.Linux,
|
"archlinux": commonParams.Linux,
|
||||||
"arch": params.Linux,
|
"arch": commonParams.Linux,
|
||||||
"centos": params.Linux,
|
"centos": commonParams.Linux,
|
||||||
"ubuntu": params.Linux,
|
"ubuntu": commonParams.Linux,
|
||||||
"rhel": params.Linux,
|
"rhel": commonParams.Linux,
|
||||||
"suse": params.Linux,
|
"suse": commonParams.Linux,
|
||||||
"opensuse": params.Linux,
|
"opensuse": commonParams.Linux,
|
||||||
"fedora": params.Linux,
|
"fedora": commonParams.Linux,
|
||||||
"debian": params.Linux,
|
"debian": commonParams.Linux,
|
||||||
"flatcar": params.Linux,
|
"flatcar": commonParams.Linux,
|
||||||
"gentoo": params.Linux,
|
"gentoo": commonParams.Linux,
|
||||||
"rockylinux": params.Linux,
|
"rockylinux": commonParams.Linux,
|
||||||
"rocky": params.Linux,
|
"rocky": commonParams.Linux,
|
||||||
"windows": params.Windows,
|
"windows": commonParams.Windows,
|
||||||
}
|
}
|
||||||
|
|
||||||
githubArchMapping map[string]string = map[string]string{
|
githubArchMapping map[string]string = map[string]string{
|
||||||
|
|
@ -95,9 +97,9 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
githubOSTag = map[params.OSType]string{
|
githubOSTag = map[commonParams.OSType]string{
|
||||||
params.Linux: "Linux",
|
commonParams.Linux: "Linux",
|
||||||
params.Windows: "Windows",
|
commonParams.Windows: "Windows",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -128,7 +130,7 @@ func ResolveToGithubOSType(osType string) (string, error) {
|
||||||
// ResolveToGithubTag returns the default OS tag that self hosted runners automatically
|
// ResolveToGithubTag returns the default OS tag that self hosted runners automatically
|
||||||
// (and forcefully) adds to every runner that gets deployed. We need to keep track of those
|
// (and forcefully) adds to every runner that gets deployed. We need to keep track of those
|
||||||
// tags internally as well.
|
// tags internally as well.
|
||||||
func ResolveToGithubTag(os params.OSType) (string, error) {
|
func ResolveToGithubTag(os commonParams.OSType) (string, error) {
|
||||||
ghOS, ok := githubOSTag[os]
|
ghOS, ok := githubOSTag[os]
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", runnerErrors.NewNotFoundError("os %s is unknown", os)
|
return "", runnerErrors.NewNotFoundError("os %s is unknown", os)
|
||||||
|
|
@ -187,10 +189,10 @@ func ConvertFileToBase64(file string) (string, error) {
|
||||||
return base64.StdEncoding.EncodeToString(bytes), nil
|
return base64.StdEncoding.EncodeToString(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func OSToOSType(os string) (params.OSType, error) {
|
func OSToOSType(os string) (commonParams.OSType, error) {
|
||||||
osType, ok := OSToOSTypeMap[strings.ToLower(os)]
|
osType, ok := OSToOSTypeMap[strings.ToLower(os)]
|
||||||
if !ok {
|
if !ok {
|
||||||
return params.Unknown, fmt.Errorf("no OS to OS type mapping for %s", os)
|
return commonParams.Unknown, fmt.Errorf("no OS to OS type mapping for %s", os)
|
||||||
}
|
}
|
||||||
return osType, nil
|
return osType, nil
|
||||||
}
|
}
|
||||||
|
|
@ -244,8 +246,8 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne
|
||||||
DownloadURL: *tools.DownloadURL,
|
DownloadURL: *tools.DownloadURL,
|
||||||
TempDownloadToken: tempToken,
|
TempDownloadToken: tempToken,
|
||||||
MetadataURL: bootstrapParams.MetadataURL,
|
MetadataURL: bootstrapParams.MetadataURL,
|
||||||
RunnerUsername: appdefaults.DefaultUser,
|
RunnerUsername: defaults.DefaultUser,
|
||||||
RunnerGroup: appdefaults.DefaultUser,
|
RunnerGroup: defaults.DefaultUser,
|
||||||
RepoURL: bootstrapParams.RepoURL,
|
RepoURL: bootstrapParams.RepoURL,
|
||||||
RunnerName: runnerName,
|
RunnerName: runnerName,
|
||||||
RunnerLabels: strings.Join(bootstrapParams.Labels, ","),
|
RunnerLabels: strings.Join(bootstrapParams.Labels, ","),
|
||||||
|
|
@ -264,7 +266,7 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne
|
||||||
|
|
||||||
var asStr string
|
var asStr string
|
||||||
switch bootstrapParams.OSType {
|
switch bootstrapParams.OSType {
|
||||||
case params.Linux:
|
case commonParams.Linux:
|
||||||
cloudCfg := cloudconfig.NewDefaultCloudInitConfig()
|
cloudCfg := cloudconfig.NewDefaultCloudInitConfig()
|
||||||
|
|
||||||
if bootstrapParams.UserDataOptions.DisableUpdatesOnBoot {
|
if bootstrapParams.UserDataOptions.DisableUpdatesOnBoot {
|
||||||
|
|
@ -277,7 +279,7 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne
|
||||||
|
|
||||||
cloudCfg.AddSSHKey(bootstrapParams.SSHKeys...)
|
cloudCfg.AddSSHKey(bootstrapParams.SSHKeys...)
|
||||||
cloudCfg.AddFile(installScript, "/install_runner.sh", "root:root", "755")
|
cloudCfg.AddFile(installScript, "/install_runner.sh", "root:root", "755")
|
||||||
cloudCfg.AddRunCmd(fmt.Sprintf("su -l -c /install_runner.sh %s", appdefaults.DefaultUser))
|
cloudCfg.AddRunCmd(fmt.Sprintf("su -l -c /install_runner.sh %s", defaults.DefaultUser))
|
||||||
cloudCfg.AddRunCmd("rm -f /install_runner.sh")
|
cloudCfg.AddRunCmd("rm -f /install_runner.sh")
|
||||||
if bootstrapParams.CACertBundle != nil && len(bootstrapParams.CACertBundle) > 0 {
|
if bootstrapParams.CACertBundle != nil && len(bootstrapParams.CACertBundle) > 0 {
|
||||||
if err := cloudCfg.AddCACert(bootstrapParams.CACertBundle); err != nil {
|
if err := cloudCfg.AddCACert(bootstrapParams.CACertBundle); err != nil {
|
||||||
|
|
@ -289,7 +291,7 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "creating cloud config")
|
return "", errors.Wrap(err, "creating cloud config")
|
||||||
}
|
}
|
||||||
case params.Windows:
|
case commonParams.Windows:
|
||||||
asStr = string(installScript)
|
asStr = string(installScript)
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("unknown os type: %s", bootstrapParams.OSType)
|
return "", fmt.Errorf("unknown os type: %s", bootstrapParams.OSType)
|
||||||
|
|
@ -298,19 +300,19 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne
|
||||||
return asStr, nil
|
return asStr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTools(osType params.OSType, osArch params.OSArch, tools []*github.RunnerApplicationDownload) (github.RunnerApplicationDownload, error) {
|
func GetTools(osType commonParams.OSType, osArch commonParams.OSArch, tools []*github.RunnerApplicationDownload) (github.RunnerApplicationDownload, error) {
|
||||||
// Validate image OS. Linux only for now.
|
// Validate image OS. Linux only for now.
|
||||||
switch osType {
|
switch osType {
|
||||||
case params.Linux:
|
case commonParams.Linux:
|
||||||
case params.Windows:
|
case commonParams.Windows:
|
||||||
default:
|
default:
|
||||||
return github.RunnerApplicationDownload{}, fmt.Errorf("unsupported OS type: %s", osType)
|
return github.RunnerApplicationDownload{}, fmt.Errorf("unsupported OS type: %s", osType)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch osArch {
|
switch osArch {
|
||||||
case params.Amd64:
|
case commonParams.Amd64:
|
||||||
case params.Arm:
|
case commonParams.Arm:
|
||||||
case params.Arm64:
|
case commonParams.Arm64:
|
||||||
default:
|
default:
|
||||||
return github.RunnerApplicationDownload{}, fmt.Errorf("unsupported OS arch: %s", osArch)
|
return github.RunnerApplicationDownload{}, fmt.Errorf("unsupported OS arch: %s", osArch)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/util/appdefaults"
|
"github.com/cloudbase/garm-provider-common/defaults"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
@ -36,10 +36,10 @@ func NewDefaultCloudInitConfig() *CloudInit {
|
||||||
},
|
},
|
||||||
SystemInfo: &SystemInfo{
|
SystemInfo: &SystemInfo{
|
||||||
DefaultUser: DefaultUser{
|
DefaultUser: DefaultUser{
|
||||||
Name: appdefaults.DefaultUser,
|
Name: defaults.DefaultUser,
|
||||||
Home: fmt.Sprintf("/home/%s", appdefaults.DefaultUser),
|
Home: fmt.Sprintf("/home/%s", defaults.DefaultUser),
|
||||||
Shell: appdefaults.DefaultUserShell,
|
Shell: defaults.DefaultUserShell,
|
||||||
Groups: appdefaults.DefaultUserGroups,
|
Groups: defaults.DefaultUserGroups,
|
||||||
Sudo: "ALL=(ALL) NOPASSWD:ALL",
|
Sudo: "ALL=(ALL) NOPASSWD:ALL",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm-provider-common/params"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
17
vendor/github.com/cloudbase/garm-provider-common/defaults/defaults.go
generated
vendored
Normal file
17
vendor/github.com/cloudbase/garm-provider-common/defaults/defaults.go
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
package defaults
|
||||||
|
|
||||||
|
const (
|
||||||
|
// DefaultUser is the default username that should exist on the instances.
|
||||||
|
DefaultUser = "runner"
|
||||||
|
// DefaultUserShell is the shell for the default user.
|
||||||
|
DefaultUserShell = "/bin/bash"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultUserGroups are the groups the default user will be part of.
|
||||||
|
DefaultUserGroups = []string{
|
||||||
|
"sudo", "adm", "cdrom", "dialout",
|
||||||
|
"dip", "video", "plugdev", "netdev",
|
||||||
|
"docker", "lxd",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -8,11 +8,18 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm-provider-common/params"
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ExitCodeNotFound is an exit code that indicates a Not Found error
|
||||||
|
ExitCodeNotFound int = 30
|
||||||
|
// ExitCodeDuplicate is an exit code that indicates a duplicate error
|
||||||
|
ExitCodeDuplicate int = 31
|
||||||
|
)
|
||||||
|
|
||||||
func GetEnvironment() (Environment, error) {
|
func GetEnvironment() (Environment, error) {
|
||||||
env := Environment{
|
env := Environment{
|
||||||
Command: ExecutionCommand(os.Getenv("GARM_COMMAND")),
|
Command: ExecutionCommand(os.Getenv("GARM_COMMAND")),
|
||||||
|
|
@ -3,7 +3,7 @@ package execution
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/cloudbase/garm/params"
|
"github.com/cloudbase/garm-provider-common/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExternalProvider defines an interface that external providers need to implement.
|
// ExternalProvider defines an interface that external providers need to implement.
|
||||||
|
|
@ -11,13 +11,13 @@ import (
|
||||||
// decouple it, in case it may diverge from native providers.
|
// decouple it, in case it may diverge from native providers.
|
||||||
type ExternalProvider interface {
|
type ExternalProvider interface {
|
||||||
// CreateInstance creates a new compute instance in the provider.
|
// CreateInstance creates a new compute instance in the provider.
|
||||||
CreateInstance(ctx context.Context, bootstrapParams params.BootstrapInstance) (params.Instance, error)
|
CreateInstance(ctx context.Context, bootstrapParams params.BootstrapInstance) (params.ProviderInstance, error)
|
||||||
// Delete instance will delete the instance in a provider.
|
// Delete instance will delete the instance in a provider.
|
||||||
DeleteInstance(ctx context.Context, instance string) error
|
DeleteInstance(ctx context.Context, instance string) error
|
||||||
// GetInstance will return details about one instance.
|
// GetInstance will return details about one instance.
|
||||||
GetInstance(ctx context.Context, instance string) (params.Instance, error)
|
GetInstance(ctx context.Context, instance string) (params.ProviderInstance, error)
|
||||||
// ListInstances will list all instances for a provider.
|
// ListInstances will list all instances for a provider.
|
||||||
ListInstances(ctx context.Context, poolID string) ([]params.Instance, error)
|
ListInstances(ctx context.Context, poolID string) ([]params.ProviderInstance, error)
|
||||||
// RemoveAllInstances will remove all instances created by this provider.
|
// RemoveAllInstances will remove all instances created by this provider.
|
||||||
RemoveAllInstances(ctx context.Context) error
|
RemoveAllInstances(ctx context.Context) error
|
||||||
// Stop shuts down the instance.
|
// Stop shuts down the instance.
|
||||||
144
vendor/github.com/cloudbase/garm-provider-common/params/params.go
generated
vendored
Normal file
144
vendor/github.com/cloudbase/garm-provider-common/params/params.go
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
package params
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/google/go-github/v48/github"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
AddressType string
|
||||||
|
InstanceStatus string
|
||||||
|
OSType string
|
||||||
|
OSArch string
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Windows OSType = "windows"
|
||||||
|
Linux OSType = "linux"
|
||||||
|
Unknown OSType = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Amd64 OSArch = "amd64"
|
||||||
|
I386 OSArch = "i386"
|
||||||
|
Arm64 OSArch = "arm64"
|
||||||
|
Arm OSArch = "arm"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
InstanceRunning InstanceStatus = "running"
|
||||||
|
InstanceStopped InstanceStatus = "stopped"
|
||||||
|
InstanceError InstanceStatus = "error"
|
||||||
|
InstancePendingDelete InstanceStatus = "pending_delete"
|
||||||
|
InstanceDeleting InstanceStatus = "deleting"
|
||||||
|
InstancePendingCreate InstanceStatus = "pending_create"
|
||||||
|
InstanceCreating InstanceStatus = "creating"
|
||||||
|
InstanceStatusUnknown InstanceStatus = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PublicAddress AddressType = "public"
|
||||||
|
PrivateAddress AddressType = "private"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserDataOptions struct {
|
||||||
|
DisableUpdatesOnBoot bool `json:"disable_updates_on_boot"`
|
||||||
|
ExtraPackages []string `json:"extra_packages"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BootstrapInstance struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Tools []*github.RunnerApplicationDownload `json:"tools"`
|
||||||
|
// RepoURL is the URL the github runner agent needs to configure itself.
|
||||||
|
RepoURL string `json:"repo_url"`
|
||||||
|
// CallbackUrl is the URL where the instance can send a post, signaling
|
||||||
|
// progress or status.
|
||||||
|
CallbackURL string `json:"callback-url"`
|
||||||
|
// MetadataURL is the URL where instances can fetch information needed to set themselves up.
|
||||||
|
MetadataURL string `json:"metadata-url"`
|
||||||
|
// InstanceToken is the token that needs to be set by the instance in the headers
|
||||||
|
// in order to send updated back to the garm via CallbackURL.
|
||||||
|
InstanceToken string `json:"instance-token"`
|
||||||
|
// SSHKeys are the ssh public keys we may want to inject inside the runners, if the
|
||||||
|
// provider supports it.
|
||||||
|
SSHKeys []string `json:"ssh-keys"`
|
||||||
|
// ExtraSpecs is an opaque raw json that gets sent to the provider
|
||||||
|
// as part of the bootstrap params for instances. It can contain
|
||||||
|
// any kind of data needed by providers. The contents of this field means
|
||||||
|
// nothing to garm itself. We don't act on the information in this field at
|
||||||
|
// all. We only validate that it's a proper json.
|
||||||
|
ExtraSpecs json.RawMessage `json:"extra_specs,omitempty"`
|
||||||
|
|
||||||
|
// GitHubRunnerGroup is the github runner group in which the newly installed runner
|
||||||
|
// should be added to. The runner group must be created by someone with access to the
|
||||||
|
// enterprise.
|
||||||
|
GitHubRunnerGroup string `json:"github-runner-group"`
|
||||||
|
|
||||||
|
// CACertBundle is a CA certificate bundle which will be sent to instances and which
|
||||||
|
// will tipically be installed as a system wide trusted root CA. by either cloud-init
|
||||||
|
// or whatever mechanism the provider will use to set up the runner.
|
||||||
|
CACertBundle []byte `json:"ca-cert-bundle"`
|
||||||
|
|
||||||
|
// OSArch is the target OS CPU architecture of the runner.
|
||||||
|
OSArch OSArch `json:"arch"`
|
||||||
|
|
||||||
|
// OSType is the target OS platform of the runner (windows, linux).
|
||||||
|
OSType OSType `json:"os_type"`
|
||||||
|
|
||||||
|
// Flavor is the platform specific abstraction that defines what resources will be allocated
|
||||||
|
// to the runner (CPU, RAM, disk space, etc). This field is meaningful to the provider which
|
||||||
|
// handles the actual creation.
|
||||||
|
Flavor string `json:"flavor"`
|
||||||
|
|
||||||
|
// Image is the platform specific identifier of the operating system template that will be used
|
||||||
|
// to spin up a new machine.
|
||||||
|
Image string `json:"image"`
|
||||||
|
|
||||||
|
// Labels are a list of github runner labels that will be added to the runner.
|
||||||
|
Labels []string `json:"labels"`
|
||||||
|
|
||||||
|
// PoolID is the ID of the garm pool to which this runner belongs.
|
||||||
|
PoolID string `json:"pool_id"`
|
||||||
|
|
||||||
|
// UserDataOptions are the options for the user data generation.
|
||||||
|
UserDataOptions UserDataOptions `json:"user_data_options"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Address struct {
|
||||||
|
Address string `json:"address"`
|
||||||
|
Type AddressType `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProviderInstance struct {
|
||||||
|
// PeoviderID is the unique ID the provider associated
|
||||||
|
// with the compute instance. We use this to identify the
|
||||||
|
// instance in the provider.
|
||||||
|
ProviderID string `json:"provider_id,omitempty"`
|
||||||
|
|
||||||
|
// Name is the name associated with an instance. Depending on
|
||||||
|
// the provider, this may or may not be useful in the context of
|
||||||
|
// the provider, but we can use it internally to identify the
|
||||||
|
// instance.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
|
// OSType is the operating system type. For now, only Linux and
|
||||||
|
// Windows are supported.
|
||||||
|
OSType OSType `json:"os_type,omitempty"`
|
||||||
|
|
||||||
|
// OSName is the name of the OS. Eg: ubuntu, centos, etc.
|
||||||
|
OSName string `json:"os_name,omitempty"`
|
||||||
|
|
||||||
|
// OSVersion is the version of the operating system.
|
||||||
|
OSVersion string `json:"os_version,omitempty"`
|
||||||
|
|
||||||
|
// OSArch is the operating system architecture.
|
||||||
|
OSArch OSArch `json:"os_arch,omitempty"`
|
||||||
|
|
||||||
|
// Addresses is a list of IP addresses the provider reports
|
||||||
|
// for this instance.
|
||||||
|
Addresses []Address `json:"addresses,omitempty"`
|
||||||
|
|
||||||
|
// Status is the status of the instance inside the provider (eg: running, stopped, etc)
|
||||||
|
Status InstanceStatus `json:"status,omitempty"`
|
||||||
|
}
|
||||||
433
vendor/github.com/google/go-github/v48/AUTHORS
generated
vendored
Normal file
433
vendor/github.com/google/go-github/v48/AUTHORS
generated
vendored
Normal file
|
|
@ -0,0 +1,433 @@
|
||||||
|
# This is the official list of go-github authors for copyright purposes.
|
||||||
|
#
|
||||||
|
# This does not necessarily list everyone who has contributed code, since in
|
||||||
|
# some cases, their employer may be the copyright holder. To see the full list
|
||||||
|
# of contributors, see the revision history in source control or
|
||||||
|
# https://github.com/google/go-github/graphs/contributors.
|
||||||
|
#
|
||||||
|
# Authors who wish to be recognized in this file should add themselves (or
|
||||||
|
# their employer, as appropriate).
|
||||||
|
|
||||||
|
178inaba <masahiro.furudate@gmail.com>
|
||||||
|
2BFL <imqksl@gmail.com>
|
||||||
|
413x <dedifferentiator@gmail.com>
|
||||||
|
Abed Kibbe <abed.kibbe@gmail.com>
|
||||||
|
Abhinav Gupta <mail@abhinavg.net>
|
||||||
|
Abhishek Veeramalla <abhishek.veeramalla@gmail.com>
|
||||||
|
aboy <b1011211@gmail.com>
|
||||||
|
adrienzieba <adrien.zieba@appdirect.com>
|
||||||
|
afdesk <work@afdesk.com>
|
||||||
|
Ahmed Hagy <a.akram93@gmail.com>
|
||||||
|
Aidan Steele <aidan.steele@glassechidna.com.au>
|
||||||
|
Ainsley Chong <ainsley.chong@gmail.com>
|
||||||
|
ajz01 <azdenek@yahoo.com>
|
||||||
|
Akeda Bagus <akeda@x-team.com>
|
||||||
|
Akhil Mohan <akhilerm@gmail.com>
|
||||||
|
Alec Thomas <alec@swapoff.org>
|
||||||
|
Aleks Clark <aleks.clark@gmail.com>
|
||||||
|
Alex Bramley <a.bramley@gmail.com>
|
||||||
|
Alex Orr <Alexorr.CSE@gmail.com>
|
||||||
|
Alex Su <alexsu@17.media>
|
||||||
|
Alex Unger <zyxancf@gmail.com>
|
||||||
|
Alexander Harkness <me@bearbin.net>
|
||||||
|
Alexis Gauthiez <alexis.gauthiez@gmail.com>
|
||||||
|
Ali Farooq <ali.farooq0@pm.me>
|
||||||
|
Allan Guwatudde <guwats10@gmail.com>
|
||||||
|
Allen Sun <shlallen1990@gmail.com>
|
||||||
|
Amey Sakhadeo <me@ameyms.com>
|
||||||
|
Anders Janmyr <anders@janmyr.com>
|
||||||
|
Andreas Garnæs <https://github.com/andreas>
|
||||||
|
Andrew Ryabchun <aryabchun@mail.ua>
|
||||||
|
Andrew Svoboda <svoboda.andrew@gmail.com>
|
||||||
|
Andy Grunwald <andygrunwald@gmail.com>
|
||||||
|
Andy Hume <andyhume@gmail.com>
|
||||||
|
Andy Lindeman <andy@lindeman.io>
|
||||||
|
angie pinilla <angelinepinilla@gmail.com>
|
||||||
|
anjanashenoy <anjanashenoy1@gmail.com>
|
||||||
|
Anshuman Bhartiya <anshuman.bhartiya@gmail.com>
|
||||||
|
Antoine <antoine.tu@mail.mcgill.ca>
|
||||||
|
Antoine Pelisse <apelisse@gmail.com>
|
||||||
|
Anton Nguyen <afnguyen85@gmail.com>
|
||||||
|
Anubha Kushwaha <anubha_bt2k14@dtu.ac.in>
|
||||||
|
appilon <apilon@hashicorp.com>
|
||||||
|
aprp <doelaudi@gmail.com>
|
||||||
|
Aravind <aravindkp@outlook.in>
|
||||||
|
Arda Kuyumcu <kuyumcuarda@gmail.com>
|
||||||
|
Arıl Bozoluk <arilbozoluk@hotmail.com>
|
||||||
|
Asier Marruedo <asiermarruedo@gmail.com>
|
||||||
|
Austin Burdine <acburdine@gmail.com>
|
||||||
|
Austin Dizzy <dizzy@wow.com>
|
||||||
|
Azuka Okuleye <azuka@zatechcorp.com>
|
||||||
|
Ben Batha <bhbatha@gmail.com>
|
||||||
|
Benjamen Keroack <benjamen@dollarshaveclub.com>
|
||||||
|
Beshr Kayali <beshrkayali@gmail.com>
|
||||||
|
Beyang Liu <beyang.liu@gmail.com>
|
||||||
|
Billy Keyes <bluekeyes@gmail.com>
|
||||||
|
Billy Lynch <wlynch92@gmail.com>
|
||||||
|
Bjorn Neergaard <bjorn@neersighted.com>
|
||||||
|
Björn Häuser <b.haeuser@rebuy.de>
|
||||||
|
boljen <bol.christophe@gmail.com>
|
||||||
|
Bracken <abdawson@gmail.com>
|
||||||
|
Brad Harris <bmharris@gmail.com>
|
||||||
|
Brad Moylan <moylan.brad@gmail.com>
|
||||||
|
Bradley Falzon <brad@teambrad.net>
|
||||||
|
Bradley McAllister <brad.mcallister@hotmail.com>
|
||||||
|
Brandon Butler <b.butler@chia.net>
|
||||||
|
Brandon Cook <phylake@gmail.com>
|
||||||
|
Brett Kuhlman <kuhlman-labs@github.com>
|
||||||
|
Brett Logan <lindluni@github.com>
|
||||||
|
Brian Egizi <brian@mojotech.com>
|
||||||
|
Bryan Boreham <bryan@weave.works>
|
||||||
|
Bryan Peterson <Lazyshot@gmail.com>
|
||||||
|
Cami Diez <diezcami@gmail.com>
|
||||||
|
Carl Johnson <me@carlmjohnson.net>
|
||||||
|
Carlos Alexandro Becker <caarlos0@gmail.com>
|
||||||
|
Carlos Tadeu Panato Junior <ctadeu@gmail.com>
|
||||||
|
ChandanChainani <chainanichan@gmail.com>
|
||||||
|
chandresh-pancholi <chandreshpancholi007@gmail.com>
|
||||||
|
Charles Fenwick Elliott <Charles@FenwickElliott.io>
|
||||||
|
Charlie Yan <charlieyan08@gmail.com>
|
||||||
|
Chmouel Boudjnah <chmouel@chmouel.com>
|
||||||
|
Chris King <chriskingnet@gmail.com>
|
||||||
|
Chris Mc <prince.chrismc@gmail.com>
|
||||||
|
Chris Raborg <craborg57@gmail.com>
|
||||||
|
Chris Roche <chris@vsco.co>
|
||||||
|
Chris Schaefer <chris@dtzq.com>
|
||||||
|
chrisforrette <chris@chrisforrette.com>
|
||||||
|
Christian Bargmann <chris@cbrgm.net>
|
||||||
|
Christian Muehlhaeuser <muesli@gmail.com>
|
||||||
|
Christoph Sassenberg <defsprite@gmail.com>
|
||||||
|
CI Monk <ci-monk@protonmail.com>
|
||||||
|
Colin Misare <github.com/cmisare>
|
||||||
|
Craig Gumbley <craiggumbley@gmail.com>
|
||||||
|
Craig Peterson <cpeterson@stackoverflow.com>
|
||||||
|
Cristian Maglie <c.maglie@bug.st>
|
||||||
|
Cyb3r Jak3 <jake@jwhite.network>
|
||||||
|
Daehyeok Mun <daehyeok@gmail.com>
|
||||||
|
Dalton Hubble <dghubble@gmail.com>
|
||||||
|
Daniel Lanner <lanner.dan@gmail.com>
|
||||||
|
Daniel Leavitt <daniel.leavitt@gmail.com>
|
||||||
|
Daniel Nilsson <daniel.nilsson1989@gmail.com>
|
||||||
|
Daoq <masseto2002@gmail.com>
|
||||||
|
Dave Du Cros <davidducros@gmail.com>
|
||||||
|
Dave Henderson <dhenderson@gmail.com>
|
||||||
|
Dave Perrett <hello@daveperrett.com>
|
||||||
|
Dave Protasowski <dprotaso@gmail.com>
|
||||||
|
David Deng <daviddengcn@gmail.com>
|
||||||
|
David Gamba <davidgamba@gmail.com>
|
||||||
|
David J. M. Karlsen <david@davidkarlsen.com>
|
||||||
|
David Jannotta <djannotta@gmail.com>
|
||||||
|
David Ji <github.com/davidji99>
|
||||||
|
David Lopez Reyes <davidlopezre@gmail.com>
|
||||||
|
Davide Zipeto <dawez1@gmail.com>
|
||||||
|
Dennis Webb <dennis@bluesentryit.com>
|
||||||
|
Derek Jobst <derekjobst@gmail.com>
|
||||||
|
DeviousLab <deviouslab@gmail.com>
|
||||||
|
Dhi Aurrahman <diorahman@rockybars.com>
|
||||||
|
Diego Lapiduz <diego.lapiduz@cfpb.gov>
|
||||||
|
Dmitri Shuralyov <shurcooL@gmail.com>
|
||||||
|
dmnlk <seikima2demon@gmail.com>
|
||||||
|
Don Petersen <don@donpetersen.net>
|
||||||
|
Doug Turner <doug.turner@gmail.com>
|
||||||
|
Drew Fradette <drew.fradette@gmail.com>
|
||||||
|
Dustin Deus <deusdustin@gmail.com>
|
||||||
|
Eivind <eivindkn@gmail.com>
|
||||||
|
Eli Uriegas <seemethere101@gmail.com>
|
||||||
|
Elliott Beach <elliott2.71828@gmail.com>
|
||||||
|
Emerson Wood <emersonwood94@gmail.com>
|
||||||
|
Emil V <emil.vaagland@schibsted.com>
|
||||||
|
Eng Zer Jun <engzerjun@gmail.com>
|
||||||
|
eperm <staffordworrell@gmail.com>
|
||||||
|
Erick Fejta <erick@fejta.com>
|
||||||
|
Erik Nobel <hendrik.nobel@transferwise.com>
|
||||||
|
erwinvaneyk <erwinvaneyk@gmail.com>
|
||||||
|
Evan Elias <evanjelias@gmail.com>
|
||||||
|
Fabian Holler <fabian.holler@simplesurance.de>
|
||||||
|
Fabrice <fabrice.vaillant@student.ecp.fr>
|
||||||
|
Fatema-Moaiyadi <fatema.i.moaiyadi@gmail.com>
|
||||||
|
Felix Geisendörfer <felix@debuggable.com>
|
||||||
|
Filippo Valsorda <hi@filippo.io>
|
||||||
|
Florian Forster <ff@octo.it>
|
||||||
|
Florian Wagner <h2floh@github.com>
|
||||||
|
Francesc Gil <xescugil@gmail.com>
|
||||||
|
Francis <hello@francismakes.com>
|
||||||
|
Francisco Guimarães <francisco.cpg@gmail.com>
|
||||||
|
François de Metz <francois@2metz.fr>
|
||||||
|
Fredrik Jönsson <fredrik.jonsson@izettle.com>
|
||||||
|
Gabriel <samfiragabriel@gmail.com>
|
||||||
|
Garrett Squire <garrettsquire@gmail.com>
|
||||||
|
George Kontridze <george.kontridze@gmail.com>
|
||||||
|
Georgy Buranov <gburanov@gmail.com>
|
||||||
|
Glen Mailer <glenjamin@gmail.com>
|
||||||
|
Gnahz <p@oath.pl>
|
||||||
|
Google Inc.
|
||||||
|
Grachev Mikhail <work@mgrachev.com>
|
||||||
|
griffin_stewie <panterathefamilyguy@gmail.com>
|
||||||
|
Guillaume Jacquet <guillaume.jacquet@gmail.com>
|
||||||
|
Guz Alexander <kalimatas@gmail.com>
|
||||||
|
Guðmundur Bjarni Ólafsson <gudmundur@github.com>
|
||||||
|
Hanno Hecker <hanno.hecker@zalando.de>
|
||||||
|
Hari haran <hariharan.uno@gmail.com>
|
||||||
|
Harikesh00 <prajapatiharikesh16@gmail.com>
|
||||||
|
haya14busa <haya14busa@gmail.com>
|
||||||
|
haya14busa <hayabusa1419@gmail.com>
|
||||||
|
Hiroki Ito <hiroki.ito.dev@gmail.com>
|
||||||
|
Hubot Jr <rreichel3@github.com>
|
||||||
|
Huy Tr <kingbazoka@gmail.com>
|
||||||
|
huydx <doxuanhuy@gmail.com>
|
||||||
|
i2bskn <i2bskn@gmail.com>
|
||||||
|
Iain Steers <iainsteers@gmail.com>
|
||||||
|
Ikko Ashimine <eltociear@gmail.com>
|
||||||
|
Ioannis Georgoulas <igeorgoulas21@gmail.com>
|
||||||
|
Isao Jonas <isao.jonas@gmail.com>
|
||||||
|
ishan upadhyay <ishanupadhyay412@gmail.com>
|
||||||
|
isqua <isqua@isqua.ru>
|
||||||
|
Jacob Valdemar <jan@lunar.app>
|
||||||
|
Jake Krammer <jake.krammer1@gmail.com>
|
||||||
|
Jake White <jake@jwhite.network>
|
||||||
|
Jameel Haffejee <RC1140@republiccommandos.co.za>
|
||||||
|
James Bowes <jbowes@repl.ca>
|
||||||
|
James Cockbain <james.cockbain@ibm.com>
|
||||||
|
James Loh <github@jloh.co>
|
||||||
|
Jamie West <jamieianwest@hotmail.com>
|
||||||
|
Jan Kosecki <jan.kosecki91@gmail.com>
|
||||||
|
Jan Švábík <jansvabik@jansvabik.cz>
|
||||||
|
Javier Campanini <jcampanini@palantir.com>
|
||||||
|
Jef LeCompte <jeffreylec@gmail.com>
|
||||||
|
Jens Rantil <jens.rantil@gmail.com>
|
||||||
|
Jeremy Morris <jeremylevanmorris@gmail.com>
|
||||||
|
Jesse Haka <haka.jesse@gmail.com>
|
||||||
|
Jesse Newland <jesse@jnewland.com>
|
||||||
|
Jihoon Chung <j.c@navercorp.com>
|
||||||
|
Jille Timmermans <jille@quis.cx>
|
||||||
|
Jimmi Dyson <jimmidyson@gmail.com>
|
||||||
|
Joan Saum <joan.saum@epitech.eu>
|
||||||
|
Joe Tsai <joetsai@digital-static.net>
|
||||||
|
John Barton <jrbarton@gmail.com>
|
||||||
|
John Engelman <john.r.engelman@gmail.com>
|
||||||
|
John Jones <john@exthilion.org>
|
||||||
|
John Liu <john.liu@mongodb.com>
|
||||||
|
Jordan Brockopp <jdbro94@gmail.com>
|
||||||
|
Jordan Sussman <jordansail22@gmail.com>
|
||||||
|
Joshua Bezaleel Abednego <joshua.bezaleel@gmail.com>
|
||||||
|
João Cerqueira <joao@cerqueira.io>
|
||||||
|
JP Phillips <jonphill9@gmail.com>
|
||||||
|
jpbelanger-mtl <jp.belanger@gmail.com>
|
||||||
|
Juan <juan.rios.28@gmail.com>
|
||||||
|
Juan Basso <jrbasso@gmail.com>
|
||||||
|
Julien Garcia Gonzalez <garciagonzalez.julien@gmail.com>
|
||||||
|
Julien Rostand <jrostand@users.noreply.github.com>
|
||||||
|
Junya Kono <junya03dance@gmail.com>
|
||||||
|
Justin Abrahms <justin@abrah.ms>
|
||||||
|
Justin Toh <tohjustin@hotmail.com>
|
||||||
|
Jusung Lee <e.jusunglee@gmail.com>
|
||||||
|
jzhoucliqr <jzhou@cliqr.com>
|
||||||
|
k1rnt <eru08tera15mora@gmail.com>
|
||||||
|
kadern0 <kaderno@gmail.com>
|
||||||
|
Katrina Owen <kytrinyx@github.com>
|
||||||
|
Kautilya Tripathi <tripathi.kautilya@gmail.com>
|
||||||
|
Keita Urashima <ursm@ursm.jp>
|
||||||
|
Kevin Burke <kev@inburke.com>
|
||||||
|
Kevin Wang <kwangsan@gmail.com>
|
||||||
|
Kevin Zhao <kzhao@lyft.com>
|
||||||
|
Kirill <g4s8.public@gmail.com>
|
||||||
|
Konrad Malawski <konrad.malawski@project13.pl>
|
||||||
|
Kookheon Kwon <kucuny@gmail.com>
|
||||||
|
Krishna Indani <indanikrishna@gmail.com>
|
||||||
|
Krzysztof Kowalczyk <kkowalczyk@gmail.com>
|
||||||
|
Kshitij Saraogi <KshitijSaraogi@gmail.com>
|
||||||
|
Kumar Saurabh <itsksaurabh@gmail.com>
|
||||||
|
Kyle Kurz <kyle@doublekaudio.com>
|
||||||
|
kyokomi <kyoko1220adword@gmail.com>
|
||||||
|
Laurent Verdoïa <verdoialaurent@gmail.com>
|
||||||
|
leopoldwang <leopold.wang@gmail.com>
|
||||||
|
Liam Galvin <liam@liam-galvin.co.uk>
|
||||||
|
Lluis Campos <lluis.campos@northern.tech>
|
||||||
|
Lovro Mažgon <lovro.mazgon@gmail.com>
|
||||||
|
Luca Campese <me@campesel.net>
|
||||||
|
Lucas Alcantara <lucasalcantaraf@gmail.com>
|
||||||
|
Luis Davim <luis.davim@sendoso.com>
|
||||||
|
Luke Evers <me@lukevers.com>
|
||||||
|
Luke Kysow <lkysow@gmail.com>
|
||||||
|
Luke Roberts <email@luke-roberts.co.uk>
|
||||||
|
Luke Young <luke@hydrantlabs.org>
|
||||||
|
lynn [they] <lynncyrin@gmail.com>
|
||||||
|
Maksim Zhylinski <uzzable@gmail.com>
|
||||||
|
Marc Binder <marcandrebinder@gmail.com>
|
||||||
|
Marcelo Carlos <marcelo@permutive.com>
|
||||||
|
Mark Tareshawty <tarebyte@github.com>
|
||||||
|
Martin Holman <me@martinholman.co.nz>
|
||||||
|
Martin-Louis Bright <mlbright@gmail.com>
|
||||||
|
Martins Sipenko <martins.sipenko@gmail.com>
|
||||||
|
Marwan Sulaiman <marwan.sameer@gmail.com>
|
||||||
|
Masayuki Izumi <m@izum.in>
|
||||||
|
Mat Geist <matgeist@gmail.com>
|
||||||
|
Matija Horvat <horvat2112@gmail.com>
|
||||||
|
Matin Rahmanian <itsmatinx@gmail.com>
|
||||||
|
Matt <alpmatthew@gmail.com>
|
||||||
|
Matt Brender <mjbrender@gmail.com>
|
||||||
|
Matt Gaunt <matt@gauntface.co.uk>
|
||||||
|
Matt Landis <landis.matt@gmail.com>
|
||||||
|
Matt Moore <mattmoor@vmware.com>
|
||||||
|
Maxime Bury <maxime.bury@gmail.com>
|
||||||
|
Michael Meng <mmeng@lyft.com>
|
||||||
|
Michael Spiegel <michael.m.spiegel@gmail.com>
|
||||||
|
Michael Tiller <michael.tiller@gmail.com>
|
||||||
|
Michał Glapa <michal.glapa@gmail.com>
|
||||||
|
Michelangelo Morrillo <michelangelo@morrillo.it>
|
||||||
|
Miguel Elias dos Santos <migueleliasweb@gmail.com>
|
||||||
|
Mike Chen <mchen300@gmail.com>
|
||||||
|
Mohammed AlDujaili <avainer11@gmail.com>
|
||||||
|
Mukundan Senthil <mukundan314@gmail.com>
|
||||||
|
Munia Balayil <munia.247@gmail.com>
|
||||||
|
Mustafa Abban <mustafaabban@utexas.edu>
|
||||||
|
Nadav Kaner <nadavkaner1@gmail.com>
|
||||||
|
Nathan VanBenschoten <nvanbenschoten@gmail.com>
|
||||||
|
Navaneeth Suresh <navaneeths1998@gmail.com>
|
||||||
|
Neil O'Toole <neilotoole@apache.org>
|
||||||
|
Nick Miyake <nmiyake@palantir.com>
|
||||||
|
Nick Platt <hello@nickplatt.co.uk>
|
||||||
|
Nick Spragg <nick.spragg@bbc.co.uk>
|
||||||
|
Nikhita Raghunath <nikitaraghunath@gmail.com>
|
||||||
|
Nilesh Singh <nilesh.singh24@outlook.com>
|
||||||
|
Noah Hanjun Lee <noah.lee@buzzvil.com>
|
||||||
|
Noah Zoschke <noah+sso2@convox.com>
|
||||||
|
ns-cweber <cweber@narrativescience.com>
|
||||||
|
Ole Orhagen <ole.orhagen@northern.tech>
|
||||||
|
Oleg Kovalov <iamolegkovalov@gmail.com>
|
||||||
|
Ondřej Kupka <ondra.cap@gmail.com>
|
||||||
|
Ori Talmor <talmorori@gmail.com>
|
||||||
|
Pablo Pérez Schröder <pablo.perezschroder@wetransfer.com>
|
||||||
|
Palash Nigam <npalash25@gmail.com>
|
||||||
|
Panagiotis Moustafellos <pmoust@gmail.com>
|
||||||
|
Parham Alvani <parham.alvani@gmail.com>
|
||||||
|
pari-27 <sonamajumdar2012@gmail.com>
|
||||||
|
Parker Moore <parkrmoore@gmail.com>
|
||||||
|
parkhyukjun89 <park.hyukjun89@gmail.com>
|
||||||
|
Pat Alwell <pat.alwell@gmail.com>
|
||||||
|
Patrick DeVivo <patrick.devivo@gmail.com>
|
||||||
|
Patrick Marabeas <patrick@marabeas.io>
|
||||||
|
Pavel Dvoinos <pavel.dvoinos@transferwise.com>
|
||||||
|
Pavel Shtanko <pavel.shtanko@gmail.com>
|
||||||
|
Pete Wagner <thepwagner@github.com>
|
||||||
|
Petr Shevtsov <petr.shevtsov@gmail.com>
|
||||||
|
Pierce McEntagart <pierce@nightfall.ai>
|
||||||
|
Pierre Carrier <pierre@meteor.com>
|
||||||
|
Piotr Zurek <p.zurek@gmail.com>
|
||||||
|
Piyush Chugh <piyushchugh1993@gmail.com>
|
||||||
|
Pratik Mallya <pratik.mallya@gmail.com>
|
||||||
|
Qais Patankar <qaisjp@gmail.com>
|
||||||
|
Quang Le Hong <iamquang95@gmail.com>
|
||||||
|
Quentin Leffray <fiahil@gmail.com>
|
||||||
|
Quinn Slack <qslack@qslack.com>
|
||||||
|
Rackspace US, Inc.
|
||||||
|
Radek Simko <radek.simko@gmail.com>
|
||||||
|
Radliński Ignacy <radlinsk@student.agh.edu.pl>
|
||||||
|
Rajat Jindal <rajatjindal83@gmail.com>
|
||||||
|
Rajendra arora <rajendraarora16@yahoo.com>
|
||||||
|
Rajkumar <princegosavi12@gmail.com>
|
||||||
|
Ranbir Singh <binkkatal.r@gmail.com>
|
||||||
|
Ravi Shekhar Jethani <rsjethani@gmail.com>
|
||||||
|
RaviTeja Pothana <ravi-teja@live.com>
|
||||||
|
rc1140 <jameel@republiccommandos.co.za>
|
||||||
|
Red Hat, Inc.
|
||||||
|
Reetuparna Mukherjee <reetuparna.1988@gmail.com>
|
||||||
|
reeves122 <reeves122@gmail.com>
|
||||||
|
Reinier Timmer <reinier.timmer@ah.nl>
|
||||||
|
Renjith R <renjithr201097@gmail.com>
|
||||||
|
Ricco Førgaard <ricco@fiskeben.dk>
|
||||||
|
Richard de Vries <richard.de.vries@topicus.nl>
|
||||||
|
Rob Figueiredo <robfig@yext.com>
|
||||||
|
Rohit Upadhyay <urohit011@gmail.com>
|
||||||
|
Rojan Dinc <rojand94@gmail.com>
|
||||||
|
Ronak Jain <ronakjain@outlook.in>
|
||||||
|
Ronan Pelliard <ronan.pelliard@datadoghq.com>
|
||||||
|
Ross Gustafson <srgustafson8@icloud.com>
|
||||||
|
Ruben Vereecken <rubenvereecken@gmail.com>
|
||||||
|
Russell Boley <raboley@gmail.com>
|
||||||
|
Ryan Leung <rleungx@gmail.com>
|
||||||
|
Ryan Lower <rpjlower@gmail.com>
|
||||||
|
Ryo Nakao <nakabonne@gmail.com>
|
||||||
|
Saaarah <sarah.liusy@gmail.com>
|
||||||
|
Safwan Olaimat <safwan.olaimat@gmail.com>
|
||||||
|
Sahil Dua <sahildua2305@gmail.com>
|
||||||
|
saisi <saisi@users.noreply.github.com>
|
||||||
|
Sam Minnée <sam@silverstripe.com>
|
||||||
|
Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
|
||||||
|
Sander Knape <s.knape88@gmail.com>
|
||||||
|
Sander van Harmelen <svanharmelen@schubergphilis.com>
|
||||||
|
Sanket Payghan <sanket.payghan8@gmail.com>
|
||||||
|
Sarah Funkhouser <sarah.k.funkhouser@gmail.com>
|
||||||
|
Sarasa Kisaragi <lingsamuelgrace@gmail.com>
|
||||||
|
Sasha Melentyev <sasha@melentyev.io>
|
||||||
|
Sean Wang <sean@decrypted.org>
|
||||||
|
Sebastian Mandrean <sebastian.mandrean@gmail.com>
|
||||||
|
Sebastian Mæland Pedersen <sem.pedersen@stud.uis.no>
|
||||||
|
Sergei Popinevskii <gurza000@gmail.com>
|
||||||
|
Sergey Romanov <xxsmotur@gmail.com>
|
||||||
|
Sergio Garcia <sergio.garcia@gmail.com>
|
||||||
|
Seth Vargo <seth@sethvargo.com>
|
||||||
|
Sevki <s@sevki.org>
|
||||||
|
Shagun Khemka <shagun.khemka60@gmail.com>
|
||||||
|
shakeelrao <shakeelrao79@gmail.com>
|
||||||
|
Shawn Catanzarite <me@shawncatz.com>
|
||||||
|
Shawn Smith <shawnpsmith@gmail.com>
|
||||||
|
Shibasis Patel <patelshibasis@gmail.com>
|
||||||
|
Sho Okada <shokada3@gmail.com>
|
||||||
|
Shrikrishna Singh <krishnasingh.ss30@gmail.com>
|
||||||
|
Simon Davis <sdavis@hashicorp.com>
|
||||||
|
sona-tar <sona.zip@gmail.com>
|
||||||
|
SoundCloud, Ltd.
|
||||||
|
Sridhar Mocherla <srmocher@microsoft.com>
|
||||||
|
SriVignessh Pss <sriknowledge@gmail.com>
|
||||||
|
Stefan Sedich <stefan.sedich@gmail.com>
|
||||||
|
Steve Teuber <github@steveteuber.com>
|
||||||
|
Stian Eikeland <stian@eikeland.se>
|
||||||
|
Suhaib Mujahid <suhaibmujahid@gmail.com>
|
||||||
|
sushmita wable <sw09007@gmail.com>
|
||||||
|
Szymon Kodrebski <simonkey007@gmail.com>
|
||||||
|
Søren Hansen <soren@dinero.dk>
|
||||||
|
Takashi Yoneuchi <takashi.yoneuchi@shift-js.info>
|
||||||
|
Takayuki Watanabe <takanabe.w@gmail.com>
|
||||||
|
Taketoshi Fujiwara <fujiwara@leapmind.io>
|
||||||
|
Taketoshi Fujiwara <taketoshi.fujiwara@gmail.com>
|
||||||
|
Takuma Kajikawa <kj1ktk@gmail.com>
|
||||||
|
Tasya Aditya Rukmana <tadityar@gmail.com>
|
||||||
|
Theo Henson <theodorehenson@protonmail.com>
|
||||||
|
Theofilos Petsios <theofilos.pe@gmail.com>
|
||||||
|
Thomas Aidan Curran <thomas@ory.sh>
|
||||||
|
Thomas Bruyelle <thomas.bruyelle@gmail.com>
|
||||||
|
Tim Rogers <timrogers@github.com>
|
||||||
|
Timothée Peignier <timothee.peignier@tryphon.org>
|
||||||
|
Tingluo Huang <tingluohuang@github.com>
|
||||||
|
tkhandel <tarunkhandelwal.iitr@gmail.com>
|
||||||
|
Tobias Gesellchen <tobias@gesellix.de>
|
||||||
|
Tom Payne <twpayne@gmail.com>
|
||||||
|
Trey Tacon <ttacon@gmail.com>
|
||||||
|
tsbkw <tsbkw0@gmail.com>
|
||||||
|
ttacon <ttacon@gmail.com>
|
||||||
|
Vaibhav Singh <vaibhav.singh.14cse@bml.edu.in>
|
||||||
|
Varadarajan Aravamudhan <varadaraajan@gmail.com>
|
||||||
|
Victor Castell <victor@victorcastell.com>
|
||||||
|
Victor Vrantchan <vrancean+github@gmail.com>
|
||||||
|
vikkyomkar <vikky.omkar@samsung.com>
|
||||||
|
Vlad Ungureanu <vladu@palantir.com>
|
||||||
|
Wasim Thabraze <wasim@thabraze.me>
|
||||||
|
Weslei Juan Moser Pereira <wesleimsr@gmail.com>
|
||||||
|
Will Maier <wcmaier@gmail.com>
|
||||||
|
Willem D'Haeseleer <dhwillem@gmail.com>
|
||||||
|
William Bailey <mail@williambailey.org.uk>
|
||||||
|
William Cooke <pipeston@gmail.com>
|
||||||
|
Xabi <xmartinez1702@gmail.com>
|
||||||
|
xibz <impactbchang@gmail.com>
|
||||||
|
Yann Malet <yann.malet@gmail.com>
|
||||||
|
Yannick Utard <yannickutard@gmail.com>
|
||||||
|
Yicheng Qin <qycqycqycqycqyc@gmail.com>
|
||||||
|
Yosuke Akatsuka <yosuke.akatsuka@access-company.com>
|
||||||
|
Yumikiyo Osanai <yumios.art@gmail.com>
|
||||||
|
Yusef Mohamadi <yuseferi@gmail.com>
|
||||||
|
Yusuke Kuoka <ykuoka@gmail.com>
|
||||||
|
Zach Latta <zach@zachlatta.com>
|
||||||
|
zhouhaibing089 <zhouhaibing089@gmail.com>
|
||||||
|
六开箱 <lkxed@outlook.com>
|
||||||
|
缘生 <i@ysicing.me>
|
||||||
27
vendor/github.com/google/go-github/v48/LICENSE
generated
vendored
Normal file
27
vendor/github.com/google/go-github/v48/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
12
vendor/github.com/google/go-github/v48/github/actions.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v48/github/actions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// ActionsService handles communication with the actions related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/
|
||||||
|
type ActionsService service
|
||||||
143
vendor/github.com/google/go-github/v48/github/actions_artifacts.go
generated
vendored
Normal file
143
vendor/github.com/google/go-github/v48/github/actions_artifacts.go
generated
vendored
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Artifact reprents a GitHub artifact. Artifacts allow sharing
|
||||||
|
// data between jobs in a workflow and provide storage for data
|
||||||
|
// once a workflow is complete.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts
|
||||||
|
type Artifact struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
SizeInBytes *int64 `json:"size_in_bytes,omitempty"`
|
||||||
|
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"`
|
||||||
|
Expired *bool `json:"expired,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ArtifactList represents a list of GitHub artifacts.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#artifacts
|
||||||
|
type ArtifactList struct {
|
||||||
|
TotalCount *int64 `json:"total_count,omitempty"`
|
||||||
|
Artifacts []*Artifact `json:"artifacts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListArtifacts lists all artifacts that belong to a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-artifacts-for-a-repository
|
||||||
|
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactList := new(ArtifactList)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifactList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifactList, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts
|
||||||
|
func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", owner, repo, runID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactList := new(ArtifactList)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifactList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifactList, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetArtifact gets a specific artifact for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact
|
||||||
|
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact := new(Artifact)
|
||||||
|
resp, err := s.client.Do(ctx, req, artifact)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return artifact, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DownloadArtifact gets a redirect URL to download an archive for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
|
||||||
|
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID)
|
||||||
|
|
||||||
|
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, newResponse(resp), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedURL, newResponse(resp), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteArtifact deletes a workflow run artifact.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#delete-an-artifact
|
||||||
|
func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
311
vendor/github.com/google/go-github/v48/github/actions_runner_groups.go
generated
vendored
Normal file
311
vendor/github.com/google/go-github/v48/github/actions_runner_groups.go
generated
vendored
Normal file
|
|
@ -0,0 +1,311 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunnerGroup represents a self-hosted runner group configured in an organization.
|
||||||
|
type RunnerGroup struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
Default *bool `json:"default,omitempty"`
|
||||||
|
SelectedRepositoriesURL *string `json:"selected_repositories_url,omitempty"`
|
||||||
|
RunnersURL *string `json:"runners_url,omitempty"`
|
||||||
|
Inherited *bool `json:"inherited,omitempty"`
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
|
||||||
|
SelectedWorkflows []string `json:"selected_workflows,omitempty"`
|
||||||
|
WorkflowRestrictionsReadOnly *bool `json:"workflow_restrictions_read_only,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunnerGroups represents a collection of self-hosted runner groups configured for an organization.
|
||||||
|
type RunnerGroups struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
RunnerGroups []*RunnerGroup `json:"runner_groups"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRunnerGroupRequest represents a request to create a Runner group for an organization.
|
||||||
|
type CreateRunnerGroupRequest struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
// List of repository IDs that can access the runner group.
|
||||||
|
SelectedRepositoryIDs []int64 `json:"selected_repository_ids,omitempty"`
|
||||||
|
// Runners represent a list of runner IDs to add to the runner group.
|
||||||
|
Runners []int64 `json:"runners,omitempty"`
|
||||||
|
// If set to True, public repos can use this runner group
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
// If true, the runner group will be restricted to running only the workflows specified in the SelectedWorkflows slice.
|
||||||
|
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
|
||||||
|
// List of workflows the runner group should be allowed to run. This setting will be ignored unless RestrictedToWorkflows is set to true.
|
||||||
|
SelectedWorkflows []string `json:"selected_workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRunnerGroupRequest represents a request to update a Runner group for an organization.
|
||||||
|
type UpdateRunnerGroupRequest struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Visibility *string `json:"visibility,omitempty"`
|
||||||
|
AllowsPublicRepositories *bool `json:"allows_public_repositories,omitempty"`
|
||||||
|
RestrictedToWorkflows *bool `json:"restricted_to_workflows,omitempty"`
|
||||||
|
SelectedWorkflows []string `json:"selected_workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRepoAccessRunnerGroupRequest represents a request to replace the list of repositories
|
||||||
|
// that can access a self-hosted runner group configured in an organization.
|
||||||
|
type SetRepoAccessRunnerGroupRequest struct {
|
||||||
|
// Updated list of repository IDs that should be given access to the runner group.
|
||||||
|
SelectedRepositoryIDs []int64 `json:"selected_repository_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRunnerGroupRunnersRequest represents a request to replace the list of
|
||||||
|
// self-hosted runners that are part of an organization runner group.
|
||||||
|
type SetRunnerGroupRunnersRequest struct {
|
||||||
|
// Updated list of runner IDs that should be given access to the runner group.
|
||||||
|
Runners []int64 `json:"runners"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgRunnerGroupOptions extend ListOptions to have the optional parameters VisibleToRepository.
|
||||||
|
type ListOrgRunnerGroupOptions struct {
|
||||||
|
ListOptions
|
||||||
|
|
||||||
|
// Only return runner groups that are allowed to be used by this repository.
|
||||||
|
VisibleToRepository string `url:"visible_to_repository,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunnerGroups lists all self-hosted runner groups configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOrgRunnerGroupOptions) (*RunnerGroups, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
groups := &RunnerGroups{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &groups)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrganizationRunnerGroup deletes a self-hosted runner group from an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization
|
||||||
|
func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRunnerGroup creates a new self-hosted runner group for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups", org)
|
||||||
|
req, err := s.client.NewRequest("POST", u, createReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOrganizationRunnerGroup updates a self-hosted runner group for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization
|
||||||
|
func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org string, groupID int64, updateReq UpdateRunnerGroupRequest) (*RunnerGroup, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, updateReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runnerGroup := new(RunnerGroup)
|
||||||
|
resp, err := s.client.Do(ctx, req, runnerGroup)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runnerGroup, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos := &ListRepositories{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRepositoryAccessRunnerGroup replaces the list of repositories that have access to a self-hosted runner group configured in an organization
|
||||||
|
// with a new List of repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#set-repository-access-for-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, ids SetRepoAccessRunnerGroupRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRepositoryAccessRunnerGroup adds a repository to the list of selected repositories that can access a self-hosted runner group.
|
||||||
|
// The runner group must have visibility set to 'selected'.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#add-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRepositoryAccessRunnerGroup removes a repository from the list of selected repositories that can access a self-hosted runner group.
|
||||||
|
// The runner group must have visibility set to 'selected'.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization
|
||||||
|
func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string, groupID int64, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an organization runner group
|
||||||
|
// with a new list of runners.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, ids)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#add-a-self-hosted-runner-to-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization.
|
||||||
|
// The runner is then returned to the default group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization
|
||||||
|
func (s *ActionsService) RemoveRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
377
vendor/github.com/google/go-github/v48/github/actions_runners.go
generated
vendored
Normal file
377
vendor/github.com/google/go-github/v48/github/actions_runners.go
generated
vendored
Normal file
|
|
@ -0,0 +1,377 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RunnerApplicationDownload represents a binary for the self-hosted runner application that can be downloaded.
|
||||||
|
type RunnerApplicationDownload struct {
|
||||||
|
OS *string `json:"os,omitempty"`
|
||||||
|
Architecture *string `json:"architecture,omitempty"`
|
||||||
|
DownloadURL *string `json:"download_url,omitempty"`
|
||||||
|
Filename *string `json:"filename,omitempty"`
|
||||||
|
TempDownloadToken *string `json:"temp_download_token,omitempty"`
|
||||||
|
SHA256Checksum *string `json:"sha256_checksum,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActionsEnabledOnOrgRepos represents all the repositories in an organization for which Actions is enabled.
|
||||||
|
type ActionsEnabledOnOrgRepos struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Repositories []*Repository `json:"repositories"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository
|
||||||
|
func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/downloads", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rads []*RunnerApplicationDownload
|
||||||
|
resp, err := s.client.Do(ctx, req, &rads)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rads, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegistrationToken represents a token that can be used to add a self-hosted runner to a repository.
|
||||||
|
type RegistrationToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository
|
||||||
|
func (s *ActionsService) CreateRegistrationToken(ctx context.Context, owner, repo string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/registration-token", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runner represents a self-hosted runner registered with a repository.
|
||||||
|
type Runner struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
OS *string `json:"os,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Busy *bool `json:"busy,omitempty"`
|
||||||
|
Labels []*RunnerLabels `json:"labels,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunnerLabels represents a collection of labels attached to each runner.
|
||||||
|
type RunnerLabels struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runners represents a collection of self-hosted runners for a repository.
|
||||||
|
type Runners struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Runners []*Runner `json:"runners"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunners lists all the self-hosted runners for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository
|
||||||
|
func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRunner gets a specific self-hosted runner for a repository using its runner ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository
|
||||||
|
func (s *ActionsService) GetRunner(ctx context.Context, owner, repo string, runnerID int64) (*Runner, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := new(Runner)
|
||||||
|
resp, err := s.client.Do(ctx, req, runner)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runner, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveToken represents a token that can be used to remove a self-hosted runner from a repository.
|
||||||
|
type RemoveToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRemoveToken creates a token that can be used to remove a self-hosted runner from a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-remove-token-for-a-repository
|
||||||
|
func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo string) (*RemoveToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/remove-token", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken := new(RemoveToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, removeToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return removeToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunner forces the removal of a self-hosted runner in a repository using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-a-repository
|
||||||
|
func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/downloads", owner)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rads []*RunnerApplicationDownload
|
||||||
|
resp, err := s.client.Do(ctx, req, &rads)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rads, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRegistrationToken creates a token that can be used to add a self-hosted runner to an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/registration-token", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrganizationRunners lists all the self-hosted runners for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization
|
||||||
|
func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners", owner)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEnabledReposInOrg lists the selected repositories that are enabled for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnOrgRepos, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos := &ActionsEnabledOnOrgRepos{}
|
||||||
|
resp, err := s.client.Do(ctx, req, repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEnabledReposInOrg replaces the list of selected repositories that are enabled for GitHub Actions in an organization..
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-selected-repositories-enabled-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string, repositoryIDs []int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, struct {
|
||||||
|
IDs []int64 `json:"selected_repository_ids"`
|
||||||
|
}{IDs: repositoryIDs})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEnabledReposInOrg adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#enable-a-selected-repository-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveEnabledRepoInOrg removes a single repository from the list of enabled repos for GitHub Actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#disable-a-selected-repository-for-github-actions-in-an-organization
|
||||||
|
func (s *ActionsService) RemoveEnabledRepoInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-an-organization
|
||||||
|
func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := new(Runner)
|
||||||
|
resp, err := s.client.Do(ctx, req, runner)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runner, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrganizationRemoveToken creates a token that can be used to remove a self-hosted runner from an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-remove-token-for-an-organization
|
||||||
|
func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/remove-token", owner)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
removeToken := new(RemoveToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, removeToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return removeToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveOrganizationRunner forces the removal of a self-hosted runner from an organization using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-organization
|
||||||
|
func (s *ActionsService) RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
358
vendor/github.com/google/go-github/v48/github/actions_secrets.go
generated
vendored
Normal file
358
vendor/github.com/google/go-github/v48/github/actions_secrets.go
generated
vendored
Normal file
|
|
@ -0,0 +1,358 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PublicKey represents the public key that should be used to encrypt secrets.
|
||||||
|
type PublicKey struct {
|
||||||
|
KeyID *string `json:"key_id"`
|
||||||
|
Key *string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||||
|
// This ensures GitHub Enterprise versions which return a numeric key id
|
||||||
|
// do not error out when unmarshaling.
|
||||||
|
func (p *PublicKey) UnmarshalJSON(data []byte) error {
|
||||||
|
var pk struct {
|
||||||
|
KeyID interface{} `json:"key_id,string"`
|
||||||
|
Key *string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := json.Unmarshal(data, &pk); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Key = pk.Key
|
||||||
|
|
||||||
|
switch v := pk.KeyID.(type) {
|
||||||
|
case nil:
|
||||||
|
return nil
|
||||||
|
case string:
|
||||||
|
p.KeyID = &v
|
||||||
|
case float64:
|
||||||
|
p.KeyID = String(strconv.FormatFloat(v, 'f', -1, 64))
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unable to unmarshal %T as a string", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getPublicKey(ctx context.Context, url string) (*PublicKey, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubKey := new(PublicKey)
|
||||||
|
resp, err := s.client.Do(ctx, req, pubKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubKey, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-public-key
|
||||||
|
func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/actions/secrets/public-key", owner, repo)
|
||||||
|
return s.getPublicKey(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-public-key
|
||||||
|
func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org)
|
||||||
|
return s.getPublicKey(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnvPublicKey gets a public key that should be used for secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key
|
||||||
|
func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/public-key", repoID, env)
|
||||||
|
return s.getPublicKey(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secret represents a repository action secret.
|
||||||
|
type Secret struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
CreatedAt Timestamp `json:"created_at"`
|
||||||
|
UpdatedAt Timestamp `json:"updated_at"`
|
||||||
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
SelectedRepositoriesURL string `json:"selected_repositories_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secrets represents one item from the ListSecrets response.
|
||||||
|
type Secrets struct {
|
||||||
|
TotalCount int `json:"total_count"`
|
||||||
|
Secrets []*Secret `json:"secrets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) listSecrets(ctx context.Context, url string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
u, err := addOptions(url, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets := new(Secrets)
|
||||||
|
resp, err := s.client.Do(ctx, req, &secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secrets, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepoSecrets lists all secrets available in a repository
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-repository-secrets
|
||||||
|
func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/actions/secrets", owner, repo)
|
||||||
|
return s.listSecrets(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgSecrets lists all secrets available in an organization
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-organization-secrets
|
||||||
|
func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets", org)
|
||||||
|
return s.listSecrets(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEnvSecrets lists all secrets available in an environment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-environment-secrets
|
||||||
|
func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repositories/%v/environments/%v/secrets", repoID, env)
|
||||||
|
return s.listSecrets(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getSecret(ctx context.Context, url string) (*Secret, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := new(Secret)
|
||||||
|
resp, err := s.client.Do(ctx, req, secret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secret, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoSecret gets a single repository secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-secret
|
||||||
|
func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||||
|
return s.getSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgSecret gets a single organization secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-secret
|
||||||
|
func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||||
|
return s.getSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEnvSecret gets a single environment secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret
|
||||||
|
func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||||
|
return s.getSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectedRepoIDs are the repository IDs that have access to the actions secrets.
|
||||||
|
type SelectedRepoIDs []int64
|
||||||
|
|
||||||
|
// EncryptedSecret represents a secret that is encrypted using a public key.
|
||||||
|
//
|
||||||
|
// The value of EncryptedValue must be your secret, encrypted with
|
||||||
|
// LibSodium (see documentation here: https://libsodium.gitbook.io/doc/bindings_for_other_languages)
|
||||||
|
// using the public key retrieved using the GetPublicKey method.
|
||||||
|
type EncryptedSecret struct {
|
||||||
|
Name string `json:"-"`
|
||||||
|
KeyID string `json:"key_id"`
|
||||||
|
EncryptedValue string `json:"encrypted_value"`
|
||||||
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
SelectedRepositoryIDs SelectedRepoIDs `json:"selected_repository_ids,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) putSecret(ctx context.Context, url string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PUT", url, eSecret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateRepoSecret creates or updates a repository secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, eSecret.Name)
|
||||||
|
return s.putSecret(ctx, url, eSecret)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateOrgSecret creates or updates an organization secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-organization-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name)
|
||||||
|
return s.putSecret(ctx, url, eSecret)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret
|
||||||
|
func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, eSecret.Name)
|
||||||
|
return s.putSecret(ctx, url, eSecret)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) deleteSecret(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRepoSecret deletes a secret in a repository using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-a-repository-secret
|
||||||
|
func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name)
|
||||||
|
return s.deleteSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrgSecret deletes a secret in an organization using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-organization-secret
|
||||||
|
func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name)
|
||||||
|
return s.deleteSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteEnvSecret deletes a secret in an environment using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret
|
||||||
|
func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName)
|
||||||
|
return s.deleteSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SelectedReposList represents the list of repositories selected for an organization secret.
|
||||||
|
type SelectedReposList struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) listSelectedReposForSecret(ctx context.Context, url string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||||
|
u, err := addOptions(url, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := new(SelectedReposList)
|
||||||
|
resp, err := s.client.Do(ctx, req, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSelectedReposForOrgSecret lists all repositories that have access to a secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||||
|
return s.listSelectedReposForSecret(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) setSelectedReposForSecret(ctx context.Context, url string, ids SelectedRepoIDs) (*Response, error) {
|
||||||
|
type repoIDs struct {
|
||||||
|
SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", url, repoIDs{SelectedIDs: ids})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSelectedReposForOrgSecret sets the repositories that have access to a secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#set-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *ActionsService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
|
||||||
|
return s.setSelectedReposForSecret(ctx, url, ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) addSelectedRepoToSecret(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PUT", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSelectedRepoToOrgSecret adds a repository to an organization secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#add-selected-repository-to-an-organization-secret
|
||||||
|
func (s *ActionsService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
return s.addSelectedRepoToSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) removeSelectedRepoFromSecret(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#remove-selected-repository-from-an-organization-secret
|
||||||
|
func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
return s.removeSelectedRepoFromSecret(ctx, url)
|
||||||
|
}
|
||||||
130
vendor/github.com/google/go-github/v48/github/actions_workflow_jobs.go
generated
vendored
Normal file
130
vendor/github.com/google/go-github/v48/github/actions_workflow_jobs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TaskStep represents a single task step from a sequence of tasks of a job.
|
||||||
|
type TaskStep struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
Number *int64 `json:"number,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowJob represents a repository action workflow job.
|
||||||
|
type WorkflowJob struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
RunID *int64 `json:"run_id,omitempty"`
|
||||||
|
RunURL *string `json:"run_url,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Steps []*TaskStep `json:"steps,omitempty"`
|
||||||
|
CheckRunURL *string `json:"check_run_url,omitempty"`
|
||||||
|
// Labels represents runner labels from the `runs-on:` key from a GitHub Actions workflow.
|
||||||
|
Labels []string `json:"labels,omitempty"`
|
||||||
|
RunnerID *int64 `json:"runner_id,omitempty"`
|
||||||
|
RunnerName *string `json:"runner_name,omitempty"`
|
||||||
|
RunnerGroupID *int64 `json:"runner_group_id,omitempty"`
|
||||||
|
RunnerGroupName *string `json:"runner_group_name,omitempty"`
|
||||||
|
RunAttempt *int64 `json:"run_attempt,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jobs represents a slice of repository action workflow job.
|
||||||
|
type Jobs struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Jobs []*WorkflowJob `json:"jobs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowJobsOptions specifies optional parameters to ListWorkflowJobs.
|
||||||
|
type ListWorkflowJobsOptions struct {
|
||||||
|
// Filter specifies how jobs should be filtered by their completed_at timestamp.
|
||||||
|
// Possible values are:
|
||||||
|
// latest - Returns jobs from the most recent execution of the workflow run
|
||||||
|
// all - Returns all jobs for a workflow run, including from old executions of the workflow run
|
||||||
|
//
|
||||||
|
// Default value is "latest".
|
||||||
|
Filter string `url:"filter,omitempty"`
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowJobs lists all jobs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
|
||||||
|
func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jobs := new(Jobs)
|
||||||
|
resp, err := s.client.Do(ctx, req, &jobs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return jobs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowJobByID gets a specific job in a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
job := new(WorkflowJob)
|
||||||
|
resp, err := s.client.Do(ctx, req, job)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return job, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowJobLogs gets a redirect URL to download a plain text file of logs for a workflow job.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID)
|
||||||
|
|
||||||
|
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
return parsedURL, newResponse(resp), err
|
||||||
|
}
|
||||||
351
vendor/github.com/google/go-github/v48/github/actions_workflow_runs.go
generated
vendored
Normal file
351
vendor/github.com/google/go-github/v48/github/actions_workflow_runs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,351 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WorkflowRun represents a repository action workflow run.
|
||||||
|
type WorkflowRun struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
RunNumber *int `json:"run_number,omitempty"`
|
||||||
|
RunAttempt *int `json:"run_attempt,omitempty"`
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
WorkflowID *int64 `json:"workflow_id,omitempty"`
|
||||||
|
CheckSuiteID *int64 `json:"check_suite_id,omitempty"`
|
||||||
|
CheckSuiteNodeID *string `json:"check_suite_node_id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
RunStartedAt *Timestamp `json:"run_started_at,omitempty"`
|
||||||
|
JobsURL *string `json:"jobs_url,omitempty"`
|
||||||
|
LogsURL *string `json:"logs_url,omitempty"`
|
||||||
|
CheckSuiteURL *string `json:"check_suite_url,omitempty"`
|
||||||
|
ArtifactsURL *string `json:"artifacts_url,omitempty"`
|
||||||
|
CancelURL *string `json:"cancel_url,omitempty"`
|
||||||
|
RerunURL *string `json:"rerun_url,omitempty"`
|
||||||
|
PreviousAttemptURL *string `json:"previous_attempt_url,omitempty"`
|
||||||
|
HeadCommit *HeadCommit `json:"head_commit,omitempty"`
|
||||||
|
WorkflowURL *string `json:"workflow_url,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
HeadRepository *Repository `json:"head_repository,omitempty"`
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRuns represents a slice of repository action workflow run.
|
||||||
|
type WorkflowRuns struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
WorkflowRuns []*WorkflowRun `json:"workflow_runs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsOptions specifies optional parameters to ListWorkflowRuns.
|
||||||
|
type ListWorkflowRunsOptions struct {
|
||||||
|
Actor string `url:"actor,omitempty"`
|
||||||
|
Branch string `url:"branch,omitempty"`
|
||||||
|
Event string `url:"event,omitempty"`
|
||||||
|
Status string `url:"status,omitempty"`
|
||||||
|
Created string `url:"created,omitempty"`
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunUsage represents a usage of a specific workflow run.
|
||||||
|
type WorkflowRunUsage struct {
|
||||||
|
Billable *WorkflowRunEnvironment `json:"billable,omitempty"`
|
||||||
|
RunDurationMS *int64 `json:"run_duration_ms,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunEnvironment represents different runner environments available for a workflow run.
|
||||||
|
type WorkflowRunEnvironment struct {
|
||||||
|
Ubuntu *WorkflowRunBill `json:"UBUNTU,omitempty"`
|
||||||
|
MacOS *WorkflowRunBill `json:"MACOS,omitempty"`
|
||||||
|
Windows *WorkflowRunBill `json:"WINDOWS,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunBill specifies billable time for a specific environment in a workflow run.
|
||||||
|
type WorkflowRunBill struct {
|
||||||
|
TotalMS *int64 `json:"total_ms,omitempty"`
|
||||||
|
Jobs *int `json:"jobs,omitempty"`
|
||||||
|
JobRuns []*WorkflowRunJobRun `json:"job_runs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunJobRun represents a usage of individual jobs of a specific workflow run.
|
||||||
|
type WorkflowRunJobRun struct {
|
||||||
|
JobID *int `json:"job_id,omitempty"`
|
||||||
|
DurationMS *int64 `json:"duration_ms,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowRunAttemptOptions specifies optional parameters to GetWorkflowRunAttempt.
|
||||||
|
type WorkflowRunAttemptOptions struct {
|
||||||
|
ExcludePullRequests *bool `url:"exclude_pull_requests,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PendingDeploymentsRequest specifies body parameters to PendingDeployments.
|
||||||
|
type PendingDeploymentsRequest struct {
|
||||||
|
EnvironmentIDs []int64 `json:"environment_ids"`
|
||||||
|
// State can be one of: "approved", "rejected".
|
||||||
|
State string `json:"state"`
|
||||||
|
Comment string `json:"comment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u, err := addOptions(endpoint, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runs := new(WorkflowRuns)
|
||||||
|
resp, err := s.client.Do(ctx, req, &runs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsByID lists all workflow runs by workflow ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs
|
||||||
|
func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowID)
|
||||||
|
return s.listWorkflowRuns(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflowRunsByFileName lists all workflow runs by workflow file name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs
|
||||||
|
func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowFileName)
|
||||||
|
return s.listWorkflowRuns(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryWorkflowRuns lists all workflow runs for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository
|
||||||
|
func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/runs", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runs := new(WorkflowRuns)
|
||||||
|
resp, err := s.client.Do(ctx, req, &runs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunByID gets a specific workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run
|
||||||
|
func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
run := new(WorkflowRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, run)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return run, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunAttempt gets a specific workflow run attempt.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run-attempt
|
||||||
|
func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo string, runID int64, attemptNumber int, opts *WorkflowRunAttemptOptions) (*WorkflowRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v", owner, repo, runID, attemptNumber)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
run := new(WorkflowRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, run)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return run, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RerunWorkflowByID re-runs a workflow by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow
|
||||||
|
func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RerunFailedJobsByID re-runs all of the failed jobs and their dependent jobs in a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-failed-jobs-from-a-workflow-run
|
||||||
|
func (s *ActionsService) RerunFailedJobsByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun-failed-jobs", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RerunJobByID re-runs a job and its dependent jobs in a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run
|
||||||
|
func (s *ActionsService) RerunJobByID(ctx context.Context, owner, repo string, jobID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/rerun", owner, repo, jobID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelWorkflowRunByID cancels a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#cancel-a-workflow-run
|
||||||
|
func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/cancel", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunLogs gets a redirect URL to download a plain text file of logs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#download-workflow-run-logs
|
||||||
|
func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, followRedirects bool) (*url.URL, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
|
||||||
|
|
||||||
|
resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusFound {
|
||||||
|
return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedURL, err := url.Parse(resp.Header.Get("Location"))
|
||||||
|
return parsedURL, newResponse(resp), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteWorkflowRun deletes a workflow run by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-a-workflow-run
|
||||||
|
func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteWorkflowRunLogs deletes all logs for a workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-workflow-run-logs
|
||||||
|
func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowRunUsageByID gets a specific workflow usage run by run ID in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-workflow-run-usage
|
||||||
|
func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRunUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/timing", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowRunUsage := new(WorkflowRunUsage)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflowRunUsage)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflowRunUsage, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PendingDeployments approve or reject pending deployments that are waiting on approval by a required reviewer.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run
|
||||||
|
func (s *ActionsService) PendingDeployments(ctx context.Context, owner, repo string, runID int64, request *PendingDeploymentsRequest) ([]*Deployment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/pending_deployments", owner, repo, runID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, request)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var deployments []*Deployment
|
||||||
|
resp, err := s.client.Do(ctx, req, &deployments)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return deployments, resp, nil
|
||||||
|
}
|
||||||
218
vendor/github.com/google/go-github/v48/github/actions_workflows.go
generated
vendored
Normal file
218
vendor/github.com/google/go-github/v48/github/actions_workflows.go
generated
vendored
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Workflow represents a repository action workflow.
|
||||||
|
type Workflow struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
BadgeURL *string `json:"badge_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workflows represents a slice of repository action workflows.
|
||||||
|
type Workflows struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Workflows []*Workflow `json:"workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowUsage represents a usage of a specific workflow.
|
||||||
|
type WorkflowUsage struct {
|
||||||
|
Billable *WorkflowEnvironment `json:"billable,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowEnvironment represents different runner environments available for a workflow.
|
||||||
|
type WorkflowEnvironment struct {
|
||||||
|
Ubuntu *WorkflowBill `json:"UBUNTU,omitempty"`
|
||||||
|
MacOS *WorkflowBill `json:"MACOS,omitempty"`
|
||||||
|
Windows *WorkflowBill `json:"WINDOWS,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorkflowBill specifies billable time for a specific environment in a workflow.
|
||||||
|
type WorkflowBill struct {
|
||||||
|
TotalMS *int64 `json:"total_ms,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventRequest represents a request to create a workflow dispatch event.
|
||||||
|
type CreateWorkflowDispatchEventRequest struct {
|
||||||
|
// Ref represents the reference of the workflow run.
|
||||||
|
// The reference can be a branch or a tag.
|
||||||
|
// Ref is required when creating a workflow dispatch event.
|
||||||
|
Ref string `json:"ref"`
|
||||||
|
// Inputs represents input keys and values configured in the workflow file.
|
||||||
|
// The maximum number of properties is 10.
|
||||||
|
// Default: Any default properties configured in the workflow file will be used when `inputs` are omitted.
|
||||||
|
Inputs map[string]interface{} `json:"inputs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWorkflows lists all workflows in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#list-repository-workflows
|
||||||
|
func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflows := new(Workflows)
|
||||||
|
resp, err := s.client.Do(ctx, req, &workflows)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflows, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowByID gets a specific workflow by ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow
|
||||||
|
func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.getWorkflow(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowByFileName gets a specific workflow by file name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow
|
||||||
|
func (s *ActionsService) GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.getWorkflow(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow := new(Workflow)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflow)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflow, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowUsageByID gets a specific workflow usage by ID in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage
|
||||||
|
func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo string, workflowID int64) (*WorkflowUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.getWorkflowUsage(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetWorkflowUsageByFileName gets a specific workflow usage by file name in the unit of billable milliseconds.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage
|
||||||
|
func (s *ActionsService) GetWorkflowUsageByFileName(ctx context.Context, owner, repo, workflowFileName string) (*WorkflowUsage, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.getWorkflowUsage(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) getWorkflowUsage(ctx context.Context, url string) (*WorkflowUsage, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workflowUsage := new(WorkflowUsage)
|
||||||
|
resp, err := s.client.Do(ctx, req, workflowUsage)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workflowUsage, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventByID manually triggers a GitHub Actions workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event
|
||||||
|
func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowID)
|
||||||
|
|
||||||
|
return s.createWorkflowDispatchEvent(ctx, u, &event)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateWorkflowDispatchEventByFileName manually triggers a GitHub Actions workflow run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event
|
||||||
|
func (s *ActionsService) CreateWorkflowDispatchEventByFileName(ctx context.Context, owner, repo, workflowFileName string, event CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowFileName)
|
||||||
|
|
||||||
|
return s.createWorkflowDispatchEvent(ctx, u, &event)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) createWorkflowDispatchEvent(ctx context.Context, url string, event *CreateWorkflowDispatchEventRequest) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("POST", url, event)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWorkflowByID enables a workflow and sets the state of the workflow to "active".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
|
||||||
|
func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowID)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWorkflowByFileName enables a workflow and sets the state of the workflow to "active".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
|
||||||
|
func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowFileName)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableWorkflowByID disables a workflow and sets the state of the workflow to "disabled_manually".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
|
||||||
|
func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowID)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DisableWorkflowByFileName disables a workflow and sets the state of the workflow to "disabled_manually".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
|
||||||
|
func (s *ActionsService) DisableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowFileName)
|
||||||
|
return s.doNewPutRequest(ctx, u)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ActionsService) doNewPutRequest(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PUT", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
73
vendor/github.com/google/go-github/v48/github/activity.go
generated
vendored
Normal file
73
vendor/github.com/google/go-github/v48/github/activity.go
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// ActivityService handles communication with the activity related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/
|
||||||
|
type ActivityService service
|
||||||
|
|
||||||
|
// FeedLink represents a link to a related resource.
|
||||||
|
type FeedLink struct {
|
||||||
|
HRef *string `json:"href,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feeds represents timeline resources in Atom format.
|
||||||
|
type Feeds struct {
|
||||||
|
TimelineURL *string `json:"timeline_url,omitempty"`
|
||||||
|
UserURL *string `json:"user_url,omitempty"`
|
||||||
|
CurrentUserPublicURL *string `json:"current_user_public_url,omitempty"`
|
||||||
|
CurrentUserURL *string `json:"current_user_url,omitempty"`
|
||||||
|
CurrentUserActorURL *string `json:"current_user_actor_url,omitempty"`
|
||||||
|
CurrentUserOrganizationURL *string `json:"current_user_organization_url,omitempty"`
|
||||||
|
CurrentUserOrganizationURLs []string `json:"current_user_organization_urls,omitempty"`
|
||||||
|
Links *FeedLinks `json:"_links,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// FeedLinks represents the links in a Feed.
|
||||||
|
type FeedLinks struct {
|
||||||
|
Timeline *FeedLink `json:"timeline,omitempty"`
|
||||||
|
User *FeedLink `json:"user,omitempty"`
|
||||||
|
CurrentUserPublic *FeedLink `json:"current_user_public,omitempty"`
|
||||||
|
CurrentUser *FeedLink `json:"current_user,omitempty"`
|
||||||
|
CurrentUserActor *FeedLink `json:"current_user_actor,omitempty"`
|
||||||
|
CurrentUserOrganization *FeedLink `json:"current_user_organization,omitempty"`
|
||||||
|
CurrentUserOrganizations []*FeedLink `json:"current_user_organizations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListFeeds lists all the feeds available to the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub provides several timeline resources in Atom format:
|
||||||
|
//
|
||||||
|
// Timeline: The GitHub global public timeline
|
||||||
|
// User: The public timeline for any user, using URI template
|
||||||
|
// Current user public: The public timeline for the authenticated user
|
||||||
|
// Current user: The private timeline for the authenticated user
|
||||||
|
// Current user actor: The private timeline for activity created by the
|
||||||
|
// authenticated user
|
||||||
|
// Current user organizations: The private timeline for the organizations
|
||||||
|
// the authenticated user is a member of.
|
||||||
|
//
|
||||||
|
// Note: Private feeds are only returned when authenticating via Basic Auth
|
||||||
|
// since current feed URIs use the older, non revocable auth tokens.
|
||||||
|
func (s *ActivityService) ListFeeds(ctx context.Context) (*Feeds, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", "feeds", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
f := &Feeds{}
|
||||||
|
resp, err := s.client.Do(ctx, req, f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return f, resp, nil
|
||||||
|
}
|
||||||
217
vendor/github.com/google/go-github/v48/github/activity_events.go
generated
vendored
Normal file
217
vendor/github.com/google/go-github/v48/github/activity_events.go
generated
vendored
Normal file
|
|
@ -0,0 +1,217 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListEvents drinks from the firehose of all public events across GitHub.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events
|
||||||
|
func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u, err := addOptions("events", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryEvents lists events for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-repository-events
|
||||||
|
func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueEventsForRepository lists issue events for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository
|
||||||
|
func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsForRepoNetwork lists public events for a network of repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-for-a-network-of-repositories
|
||||||
|
func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsForOrganization lists public events for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-organization-events
|
||||||
|
func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/events", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
|
||||||
|
// true, only public events will be returned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-for-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-for-a-user
|
||||||
|
func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if publicOnly {
|
||||||
|
u = fmt.Sprintf("users/%v/events/public", user)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("users/%v/events", user)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is
|
||||||
|
// true, only public events will be returned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-received-by-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-received-by-a-user
|
||||||
|
func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if publicOnly {
|
||||||
|
u = fmt.Sprintf("users/%v/received_events/public", user)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("users/%v/received_events", user)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserEventsForOrganization provides the user’s organization dashboard. You
|
||||||
|
// must be authenticated as the user to view this.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-organization-events-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*Event
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
223
vendor/github.com/google/go-github/v48/github/activity_notifications.go
generated
vendored
Normal file
223
vendor/github.com/google/go-github/v48/github/activity_notifications.go
generated
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Notification identifies a GitHub notification for a user.
|
||||||
|
type Notification struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
Subject *NotificationSubject `json:"subject,omitempty"`
|
||||||
|
|
||||||
|
// Reason identifies the event that triggered the notification.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity#notification-reasons
|
||||||
|
Reason *string `json:"reason,omitempty"`
|
||||||
|
|
||||||
|
Unread *bool `json:"unread,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
LastReadAt *time.Time `json:"last_read_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotificationSubject identifies the subject of a notification.
|
||||||
|
type NotificationSubject struct {
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
LatestCommentURL *string `json:"latest_comment_url,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotificationListOptions specifies the optional parameters to the
|
||||||
|
// ActivityService.ListNotifications method.
|
||||||
|
type NotificationListOptions struct {
|
||||||
|
All bool `url:"all,omitempty"`
|
||||||
|
Participating bool `url:"participating,omitempty"`
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
Before time.Time `url:"before,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListNotifications lists all notifications for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) {
|
||||||
|
u := "notifications"
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var notifications []*Notification
|
||||||
|
resp, err := s.client.Do(ctx, req, ¬ifications)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return notifications, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryNotifications lists all notifications in a given repository
|
||||||
|
// for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var notifications []*Notification
|
||||||
|
resp, err := s.client.Do(ctx, req, ¬ifications)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return notifications, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type markReadOptions struct {
|
||||||
|
LastReadAt time.Time `json:"last_read_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkNotificationsRead marks all notifications up to lastRead as read.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read
|
||||||
|
func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead time.Time) (*Response, error) {
|
||||||
|
opts := &markReadOptions{
|
||||||
|
LastReadAt: lastRead,
|
||||||
|
}
|
||||||
|
req, err := s.client.NewRequest("PUT", "notifications", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkRepositoryNotificationsRead marks all notifications up to lastRead in
|
||||||
|
// the specified repository as read.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read
|
||||||
|
func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead time.Time) (*Response, error) {
|
||||||
|
opts := &markReadOptions{
|
||||||
|
LastReadAt: lastRead,
|
||||||
|
}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetThread gets the specified notification thread.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread
|
||||||
|
func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) {
|
||||||
|
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
notification := new(Notification)
|
||||||
|
resp, err := s.client.Do(ctx, req, notification)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return notification, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarkThreadRead marks the specified thread as read.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-a-thread-as-read
|
||||||
|
func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("notifications/threads/%v", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetThreadSubscription checks to see if the authenticated user is subscribed
|
||||||
|
// to a thread.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) {
|
||||||
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sub := new(Subscription)
|
||||||
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sub, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetThreadSubscription sets the subscription for the specified thread for the
|
||||||
|
// authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#set-a-thread-subscription
|
||||||
|
func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) {
|
||||||
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, subscription)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sub := new(Subscription)
|
||||||
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sub, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteThreadSubscription deletes the subscription for the specified thread
|
||||||
|
// for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#delete-a-thread-subscription
|
||||||
|
func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("notifications/threads/%v/subscription", id)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
141
vendor/github.com/google/go-github/v48/github/activity_star.go
generated
vendored
Normal file
141
vendor/github.com/google/go-github/v48/github/activity_star.go
generated
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StarredRepository is returned by ListStarred.
|
||||||
|
type StarredRepository struct {
|
||||||
|
StarredAt *Timestamp `json:"starred_at,omitempty"`
|
||||||
|
Repository *Repository `json:"repo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stargazer represents a user that has starred a repository.
|
||||||
|
type Stargazer struct {
|
||||||
|
StarredAt *Timestamp `json:"starred_at,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStargazers lists people who have starred the specified repo.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-stargazers
|
||||||
|
func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches
|
||||||
|
req.Header.Set("Accept", mediaTypeStarringPreview)
|
||||||
|
|
||||||
|
var stargazers []*Stargazer
|
||||||
|
resp, err := s.client.Do(ctx, req, &stargazers)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return stargazers, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActivityListStarredOptions specifies the optional parameters to the
|
||||||
|
// ActivityService.ListStarred method.
|
||||||
|
type ActivityListStarredOptions struct {
|
||||||
|
// How to sort the repository list. Possible values are: created, updated,
|
||||||
|
// pushed, full_name. Default is "full_name".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort repositories. Possible values are: asc, desc.
|
||||||
|
// Default is "asc" when sort is "full_name", otherwise default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarred lists all the repos starred by a user. Passing the empty string
|
||||||
|
// will list the starred repositories for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-a-user
|
||||||
|
func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/starred", user)
|
||||||
|
} else {
|
||||||
|
u = "user/starred"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when APIs fully launch
|
||||||
|
acceptHeaders := []string{mediaTypeStarringPreview, mediaTypeTopicsPreview}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var repos []*StarredRepository
|
||||||
|
resp, err := s.client.Do(ctx, req, &repos)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repos, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStarred checks if a repository is starred by authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#check-if-a-repository-is-starred-by-the-authenticated-user
|
||||||
|
func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
starred, err := parseBoolResponse(err)
|
||||||
|
return starred, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Star a repository as the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#star-a-repository-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unstar a repository as the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/starring#unstar-a-repository-for-the-authenticated-user
|
||||||
|
func (s *ActivityService) Unstar(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/starred/%v/%v", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
147
vendor/github.com/google/go-github/v48/github/activity_watching.go
generated
vendored
Normal file
147
vendor/github.com/google/go-github/v48/github/activity_watching.go
generated
vendored
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Subscription identifies a repository or thread subscription.
|
||||||
|
type Subscription struct {
|
||||||
|
Subscribed *bool `json:"subscribed,omitempty"`
|
||||||
|
Ignored *bool `json:"ignored,omitempty"`
|
||||||
|
Reason *string `json:"reason,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
|
||||||
|
// only populated for repository subscriptions
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
|
||||||
|
// only populated for thread subscriptions
|
||||||
|
ThreadURL *string `json:"thread_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWatchers lists watchers of a particular repo.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-watchers
|
||||||
|
func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var watchers []*User
|
||||||
|
resp, err := s.client.Do(ctx, req, &watchers)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return watchers, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListWatched lists the repositories the specified user is watching. Passing
|
||||||
|
// the empty string will fetch watched repos for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-a-user
|
||||||
|
func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/subscriptions", user)
|
||||||
|
} else {
|
||||||
|
u = "user/subscriptions"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var watched []*Repository
|
||||||
|
resp, err := s.client.Do(ctx, req, &watched)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return watched, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepositorySubscription returns the subscription for the specified
|
||||||
|
// repository for the authenticated user. If the authenticated user is not
|
||||||
|
// watching the repository, a nil Subscription is returned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#get-a-repository-subscription
|
||||||
|
func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sub := new(Subscription)
|
||||||
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
|
if err != nil {
|
||||||
|
// if it's just a 404, don't return that as an error
|
||||||
|
_, err = parseBoolResponse(err)
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sub, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRepositorySubscription sets the subscription for the specified repository
|
||||||
|
// for the authenticated user.
|
||||||
|
//
|
||||||
|
// To watch a repository, set subscription.Subscribed to true.
|
||||||
|
// To ignore notifications made within a repository, set subscription.Ignored to true.
|
||||||
|
// To stop watching a repository, use DeleteRepositorySubscription.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#set-a-repository-subscription
|
||||||
|
func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, subscription)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sub := new(Subscription)
|
||||||
|
resp, err := s.client.Do(ctx, req, sub)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sub, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRepositorySubscription deletes the subscription for the specified
|
||||||
|
// repository for the authenticated user.
|
||||||
|
//
|
||||||
|
// This is used to stop watching a repository. To control whether or not to
|
||||||
|
// receive notifications from a repository, use SetRepositorySubscription.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/activity/watching#delete-a-repository-subscription
|
||||||
|
func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
119
vendor/github.com/google/go-github/v48/github/admin.go
generated
vendored
Normal file
119
vendor/github.com/google/go-github/v48/github/admin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminService handles communication with the admin related methods of the
|
||||||
|
// GitHub API. These API routes are normally only accessible for GitHub
|
||||||
|
// Enterprise installations.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin
|
||||||
|
type AdminService service
|
||||||
|
|
||||||
|
// TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group.
|
||||||
|
type TeamLDAPMapping struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
LDAPDN *string `json:"ldap_dn,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Privacy *string `json:"privacy,omitempty"`
|
||||||
|
Permission *string `json:"permission,omitempty"`
|
||||||
|
|
||||||
|
MembersURL *string `json:"members_url,omitempty"`
|
||||||
|
RepositoriesURL *string `json:"repositories_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m TeamLDAPMapping) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserLDAPMapping represents the mapping between a GitHub user and an LDAP user.
|
||||||
|
type UserLDAPMapping struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
LDAPDN *string `json:"ldap_dn,omitempty"`
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||||
|
GravatarID *string `json:"gravatar_id,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
SiteAdmin *bool `json:"site_admin,omitempty"`
|
||||||
|
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
EventsURL *string `json:"events_url,omitempty"`
|
||||||
|
FollowingURL *string `json:"following_url,omitempty"`
|
||||||
|
FollowersURL *string `json:"followers_url,omitempty"`
|
||||||
|
GistsURL *string `json:"gists_url,omitempty"`
|
||||||
|
OrganizationsURL *string `json:"organizations_url,omitempty"`
|
||||||
|
ReceivedEventsURL *string `json:"received_events_url,omitempty"`
|
||||||
|
ReposURL *string `json:"repos_url,omitempty"`
|
||||||
|
StarredURL *string `json:"starred_url,omitempty"`
|
||||||
|
SubscriptionsURL *string `json:"subscriptions_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m UserLDAPMapping) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enterprise represents the GitHub enterprise profile.
|
||||||
|
type Enterprise struct {
|
||||||
|
ID *int `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
WebsiteURL *string `json:"website_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Enterprise) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/enterprise-server/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
|
||||||
|
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/ldap/users/%v/mapping", user)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, mapping)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(UserLDAPMapping)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/enterprise/ldap/#update-ldap-mapping-for-a-team
|
||||||
|
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, mapping)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(TeamLDAPMapping)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
89
vendor/github.com/google/go-github/v48/github/admin_orgs.go
generated
vendored
Normal file
89
vendor/github.com/google/go-github/v48/github/admin_orgs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// createOrgRequest is a subset of Organization and is used internally
|
||||||
|
// by CreateOrg to pass only the known fields for the endpoint.
|
||||||
|
type createOrgRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
Admin *string `json:"admin,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrg creates a new organization in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// Note that only a subset of the org fields are used and org must
|
||||||
|
// not be nil.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#create-an-organization
|
||||||
|
func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) {
|
||||||
|
u := "admin/organizations"
|
||||||
|
|
||||||
|
orgReq := &createOrgRequest{
|
||||||
|
Login: org.Login,
|
||||||
|
Admin: &admin,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, orgReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
o := new(Organization)
|
||||||
|
resp, err := s.client.Do(ctx, req, o)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return o, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// renameOrgRequest is a subset of Organization and is used internally
|
||||||
|
// by RenameOrg and RenameOrgByName to pass only the known fields for the endpoint.
|
||||||
|
type renameOrgRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrgResponse is the response given when renaming an Organization.
|
||||||
|
type RenameOrgResponse struct {
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrg renames an organization in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization
|
||||||
|
func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) {
|
||||||
|
return s.RenameOrgByName(ctx, *org.Login, newName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RenameOrgByName renames an organization in GitHub Enterprise using its current name.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/orgs/#rename-an-organization
|
||||||
|
func (s *AdminService) RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/organizations/%v", org)
|
||||||
|
|
||||||
|
orgReq := &renameOrgRequest{
|
||||||
|
Login: &newName,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, orgReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
o := new(RenameOrgResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, o)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return o, resp, nil
|
||||||
|
}
|
||||||
171
vendor/github.com/google/go-github/v48/github/admin_stats.go
generated
vendored
Normal file
171
vendor/github.com/google/go-github/v48/github/admin_stats.go
generated
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminStats represents a variety of stats of a GitHub Enterprise
|
||||||
|
// installation.
|
||||||
|
type AdminStats struct {
|
||||||
|
Issues *IssueStats `json:"issues,omitempty"`
|
||||||
|
Hooks *HookStats `json:"hooks,omitempty"`
|
||||||
|
Milestones *MilestoneStats `json:"milestones,omitempty"`
|
||||||
|
Orgs *OrgStats `json:"orgs,omitempty"`
|
||||||
|
Comments *CommentStats `json:"comments,omitempty"`
|
||||||
|
Pages *PageStats `json:"pages,omitempty"`
|
||||||
|
Users *UserStats `json:"users,omitempty"`
|
||||||
|
Gists *GistStats `json:"gists,omitempty"`
|
||||||
|
Pulls *PullStats `json:"pulls,omitempty"`
|
||||||
|
Repos *RepoStats `json:"repos,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s AdminStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueStats represents the number of total, open and closed issues.
|
||||||
|
type IssueStats struct {
|
||||||
|
TotalIssues *int `json:"total_issues,omitempty"`
|
||||||
|
OpenIssues *int `json:"open_issues,omitempty"`
|
||||||
|
ClosedIssues *int `json:"closed_issues,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s IssueStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HookStats represents the number of total, active and inactive hooks.
|
||||||
|
type HookStats struct {
|
||||||
|
TotalHooks *int `json:"total_hooks,omitempty"`
|
||||||
|
ActiveHooks *int `json:"active_hooks,omitempty"`
|
||||||
|
InactiveHooks *int `json:"inactive_hooks,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s HookStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MilestoneStats represents the number of total, open and close milestones.
|
||||||
|
type MilestoneStats struct {
|
||||||
|
TotalMilestones *int `json:"total_milestones,omitempty"`
|
||||||
|
OpenMilestones *int `json:"open_milestones,omitempty"`
|
||||||
|
ClosedMilestones *int `json:"closed_milestones,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s MilestoneStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrgStats represents the number of total, disabled organizations and the team
|
||||||
|
// and team member count.
|
||||||
|
type OrgStats struct {
|
||||||
|
TotalOrgs *int `json:"total_orgs,omitempty"`
|
||||||
|
DisabledOrgs *int `json:"disabled_orgs,omitempty"`
|
||||||
|
TotalTeams *int `json:"total_teams,omitempty"`
|
||||||
|
TotalTeamMembers *int `json:"total_team_members,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s OrgStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommentStats represents the number of total comments on commits, gists, issues
|
||||||
|
// and pull requests.
|
||||||
|
type CommentStats struct {
|
||||||
|
TotalCommitComments *int `json:"total_commit_comments,omitempty"`
|
||||||
|
TotalGistComments *int `json:"total_gist_comments,omitempty"`
|
||||||
|
TotalIssueComments *int `json:"total_issue_comments,omitempty"`
|
||||||
|
TotalPullRequestComments *int `json:"total_pull_request_comments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s CommentStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PageStats represents the total number of github pages.
|
||||||
|
type PageStats struct {
|
||||||
|
TotalPages *int `json:"total_pages,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s PageStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserStats represents the number of total, admin and suspended users.
|
||||||
|
type UserStats struct {
|
||||||
|
TotalUsers *int `json:"total_users,omitempty"`
|
||||||
|
AdminUsers *int `json:"admin_users,omitempty"`
|
||||||
|
SuspendedUsers *int `json:"suspended_users,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s UserStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistStats represents the number of total, private and public gists.
|
||||||
|
type GistStats struct {
|
||||||
|
TotalGists *int `json:"total_gists,omitempty"`
|
||||||
|
PrivateGists *int `json:"private_gists,omitempty"`
|
||||||
|
PublicGists *int `json:"public_gists,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s GistStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PullStats represents the number of total, merged, mergable and unmergeable
|
||||||
|
// pull-requests.
|
||||||
|
type PullStats struct {
|
||||||
|
TotalPulls *int `json:"total_pulls,omitempty"`
|
||||||
|
MergedPulls *int `json:"merged_pulls,omitempty"`
|
||||||
|
MergablePulls *int `json:"mergeable_pulls,omitempty"`
|
||||||
|
UnmergablePulls *int `json:"unmergeable_pulls,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s PullStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RepoStats represents the number of total, root, fork, organization repositories
|
||||||
|
// together with the total number of pushes and wikis.
|
||||||
|
type RepoStats struct {
|
||||||
|
TotalRepos *int `json:"total_repos,omitempty"`
|
||||||
|
RootRepos *int `json:"root_repos,omitempty"`
|
||||||
|
ForkRepos *int `json:"fork_repos,omitempty"`
|
||||||
|
OrgRepos *int `json:"org_repos,omitempty"`
|
||||||
|
TotalPushes *int `json:"total_pushes,omitempty"`
|
||||||
|
TotalWikis *int `json:"total_wikis,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s RepoStats) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAdminStats returns a variety of metrics about a GitHub Enterprise
|
||||||
|
// installation.
|
||||||
|
//
|
||||||
|
// Please note that this is only available to site administrators,
|
||||||
|
// otherwise it will error with a 404 not found (instead of 401 or 403).
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/admin_stats/
|
||||||
|
func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprise/stats/all")
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(AdminStats)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
133
vendor/github.com/google/go-github/v48/github/admin_users.go
generated
vendored
Normal file
133
vendor/github.com/google/go-github/v48/github/admin_users.go
generated
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// createUserRequest is a subset of User and is used internally
|
||||||
|
// by CreateUser to pass only the known fields for the endpoint.
|
||||||
|
type createUserRequest struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateUser creates a new user in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-a-new-user
|
||||||
|
func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*User, *Response, error) {
|
||||||
|
u := "admin/users"
|
||||||
|
|
||||||
|
userReq := &createUserRequest{
|
||||||
|
Login: &login,
|
||||||
|
Email: &email,
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, userReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var user User
|
||||||
|
resp, err := s.client.Do(ctx, req, &user)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &user, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUser deletes a user in GitHub Enterprise.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-user
|
||||||
|
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := "admin/users/" + username
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImpersonateUserOptions represents the scoping for the OAuth token.
|
||||||
|
type ImpersonateUserOptions struct {
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OAuthAPP represents the GitHub Site Administrator OAuth app.
|
||||||
|
type OAuthAPP struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s OAuthAPP) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAuthorization represents the impersonation response.
|
||||||
|
type UserAuthorization struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
TokenLastEight *string `json:"token_last_eight,omitempty"`
|
||||||
|
HashedToken *string `json:"hashed_token,omitempty"`
|
||||||
|
App *OAuthAPP `json:"app,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateUserImpersonation creates an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
||||||
|
func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%s/authorizations", username)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(UserAuthorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserImpersonation deletes an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub Enterprise API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
||||||
|
func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%s/authorizations", username)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
if err != nil {
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
359
vendor/github.com/google/go-github/v48/github/apps.go
generated
vendored
Normal file
359
vendor/github.com/google/go-github/v48/github/apps.go
generated
vendored
Normal file
|
|
@ -0,0 +1,359 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppsService provides access to the installation related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/
|
||||||
|
type AppsService service
|
||||||
|
|
||||||
|
// App represents a GitHub App.
|
||||||
|
type App struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
ExternalURL *string `json:"external_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
Events []string `json:"events,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationToken represents an installation token.
|
||||||
|
type InstallationToken struct {
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationTokenOptions allow restricting a token's access to specific repositories.
|
||||||
|
type InstallationTokenOptions struct {
|
||||||
|
// The IDs of the repositories that the installation token can access.
|
||||||
|
// Providing repository IDs restricts the access of an installation token to specific repositories.
|
||||||
|
RepositoryIDs []int64 `json:"repository_ids,omitempty"`
|
||||||
|
|
||||||
|
// The names of the repositories that the installation token can access.
|
||||||
|
// Providing repository names restricts the access of an installation token to specific repositories.
|
||||||
|
Repositories []string `json:"repositories,omitempty"`
|
||||||
|
|
||||||
|
// The permissions granted to the access token.
|
||||||
|
// The permissions object includes the permission names and their access type.
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationPermissions lists the repository and organization permissions for an installation.
|
||||||
|
//
|
||||||
|
// Permission names taken from:
|
||||||
|
//
|
||||||
|
// https://docs.github.com/en/enterprise-server@3.0/rest/apps#create-an-installation-access-token-for-an-app
|
||||||
|
// https://docs.github.com/en/rest/apps#create-an-installation-access-token-for-an-app
|
||||||
|
type InstallationPermissions struct {
|
||||||
|
Actions *string `json:"actions,omitempty"`
|
||||||
|
Administration *string `json:"administration,omitempty"`
|
||||||
|
Blocking *string `json:"blocking,omitempty"`
|
||||||
|
Checks *string `json:"checks,omitempty"`
|
||||||
|
Contents *string `json:"contents,omitempty"`
|
||||||
|
ContentReferences *string `json:"content_references,omitempty"`
|
||||||
|
Deployments *string `json:"deployments,omitempty"`
|
||||||
|
Emails *string `json:"emails,omitempty"`
|
||||||
|
Environments *string `json:"environments,omitempty"`
|
||||||
|
Followers *string `json:"followers,omitempty"`
|
||||||
|
Issues *string `json:"issues,omitempty"`
|
||||||
|
Metadata *string `json:"metadata,omitempty"`
|
||||||
|
Members *string `json:"members,omitempty"`
|
||||||
|
OrganizationAdministration *string `json:"organization_administration,omitempty"`
|
||||||
|
OrganizationCustomRoles *string `json:"organization_custom_roles,omitempty"`
|
||||||
|
OrganizationHooks *string `json:"organization_hooks,omitempty"`
|
||||||
|
OrganizationPackages *string `json:"organization_packages,omitempty"`
|
||||||
|
OrganizationPlan *string `json:"organization_plan,omitempty"`
|
||||||
|
OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"`
|
||||||
|
OrganizationProjects *string `json:"organization_projects,omitempty"`
|
||||||
|
OrganizationSecrets *string `json:"organization_secrets,omitempty"`
|
||||||
|
OrganizationSelfHostedRunners *string `json:"organization_self_hosted_runners,omitempty"`
|
||||||
|
OrganizationUserBlocking *string `json:"organization_user_blocking,omitempty"`
|
||||||
|
Packages *string `json:"packages,omitempty"`
|
||||||
|
Pages *string `json:"pages,omitempty"`
|
||||||
|
PullRequests *string `json:"pull_requests,omitempty"`
|
||||||
|
RepositoryHooks *string `json:"repository_hooks,omitempty"`
|
||||||
|
RepositoryProjects *string `json:"repository_projects,omitempty"`
|
||||||
|
RepositoryPreReceiveHooks *string `json:"repository_pre_receive_hooks,omitempty"`
|
||||||
|
Secrets *string `json:"secrets,omitempty"`
|
||||||
|
SecretScanningAlerts *string `json:"secret_scanning_alerts,omitempty"`
|
||||||
|
SecurityEvents *string `json:"security_events,omitempty"`
|
||||||
|
SingleFile *string `json:"single_file,omitempty"`
|
||||||
|
Statuses *string `json:"statuses,omitempty"`
|
||||||
|
TeamDiscussions *string `json:"team_discussions,omitempty"`
|
||||||
|
VulnerabilityAlerts *string `json:"vulnerability_alerts,omitempty"`
|
||||||
|
Workflows *string `json:"workflows,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Installation represents a GitHub Apps installation.
|
||||||
|
type Installation struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
AppID *int64 `json:"app_id,omitempty"`
|
||||||
|
AppSlug *string `json:"app_slug,omitempty"`
|
||||||
|
TargetID *int64 `json:"target_id,omitempty"`
|
||||||
|
Account *User `json:"account,omitempty"`
|
||||||
|
AccessTokensURL *string `json:"access_tokens_url,omitempty"`
|
||||||
|
RepositoriesURL *string `json:"repositories_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
TargetType *string `json:"target_type,omitempty"`
|
||||||
|
SingleFileName *string `json:"single_file_name,omitempty"`
|
||||||
|
RepositorySelection *string `json:"repository_selection,omitempty"`
|
||||||
|
Events []string `json:"events,omitempty"`
|
||||||
|
SingleFilePaths []string `json:"single_file_paths,omitempty"`
|
||||||
|
Permissions *InstallationPermissions `json:"permissions,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
HasMultipleSingleFiles *bool `json:"has_multiple_single_files,omitempty"`
|
||||||
|
SuspendedBy *User `json:"suspended_by,omitempty"`
|
||||||
|
SuspendedAt *Timestamp `json:"suspended_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attachment represents a GitHub Apps attachment.
|
||||||
|
type Attachment struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContentReference represents a reference to a URL in an issue or pull request.
|
||||||
|
type ContentReference struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Reference *string `json:"reference,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Installation) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single GitHub App. Passing the empty string will get
|
||||||
|
// the authenticated GitHub App.
|
||||||
|
//
|
||||||
|
// Note: appSlug is just the URL-friendly name of your GitHub App.
|
||||||
|
// You can find this on the settings page for your GitHub App
|
||||||
|
// (e.g., https://github.com/settings/apps/:app_slug).
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-the-authenticated-app
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-app
|
||||||
|
func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if appSlug != "" {
|
||||||
|
u = fmt.Sprintf("apps/%v", appSlug)
|
||||||
|
} else {
|
||||||
|
u = "app"
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
app := new(App)
|
||||||
|
resp, err := s.client.Do(ctx, req, app)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return app, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListInstallations lists the installations that the current GitHub App has.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#list-installations-for-the-authenticated-app
|
||||||
|
func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
|
||||||
|
u, err := addOptions("app/installations", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i []*Installation
|
||||||
|
resp, err := s.client.Do(ctx, req, &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInstallation returns the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("app/installations/%v", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserInstallations lists installations that are accessible to the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-app-installations-accessible-to-the-user-access-token
|
||||||
|
func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) {
|
||||||
|
u, err := addOptions("user/installations", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i struct {
|
||||||
|
Installations []*Installation `json:"installations"`
|
||||||
|
}
|
||||||
|
resp, err := s.client.Do(ctx, req, &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i.Installations, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuspendInstallation suspends the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#suspend-an-app-installation
|
||||||
|
func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnsuspendInstallation unsuspends the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#unsuspend-an-app-installation
|
||||||
|
func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/suspended", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteInstallation deletes the specified installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateInstallationToken creates a new installation token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app
|
||||||
|
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app/installations/%v/access_tokens", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(InstallationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateAttachment creates a new attachment on user comment containing a url.
|
||||||
|
//
|
||||||
|
// TODO: Find GitHub API docs.
|
||||||
|
func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID)
|
||||||
|
payload := &Attachment{Title: String(title), Body: String(body)}
|
||||||
|
req, err := s.client.NewRequest("POST", u, payload)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeContentAttachmentsPreview)
|
||||||
|
|
||||||
|
m := &Attachment{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindOrganizationInstallation finds the organization's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("orgs/%v/installation", org))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindRepositoryInstallation finds the repository's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, repo string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindRepositoryInstallationByID finds the repository's installation information.
|
||||||
|
//
|
||||||
|
// Note: FindRepositoryInstallationByID uses the undocumented GitHub API endpoint /repositories/:id/installation.
|
||||||
|
func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int64) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("repositories/%d/installation", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindUserInstallation finds the user's installation information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app
|
||||||
|
func (s *AppsService) FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) {
|
||||||
|
return s.getInstallation(ctx, fmt.Sprintf("users/%v/installation", user))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *AppsService) getInstallation(ctx context.Context, url string) (*Installation, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Installation)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
48
vendor/github.com/google/go-github/v48/github/apps_hooks.go
generated
vendored
Normal file
48
vendor/github.com/google/go-github/v48/github/apps_hooks.go
generated
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetHookConfig returns the webhook configuration for a GitHub App.
|
||||||
|
// The underlying transport must be authenticated as an app.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-webhook-configuration-for-an-app
|
||||||
|
func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", "app/hook/config", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
config := new(HookConfig)
|
||||||
|
resp, err := s.client.Do(ctx, req, &config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateHookConfig updates the webhook configuration for a GitHub App.
|
||||||
|
// The underlying transport must be authenticated as an app.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#update-a-webhook-configuration-for-an-app
|
||||||
|
func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PATCH", "app/hook/config", config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(HookConfig)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
72
vendor/github.com/google/go-github/v48/github/apps_hooks_deliveries.go
generated
vendored
Normal file
72
vendor/github.com/google/go-github/v48/github/apps_hooks_deliveries.go
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListHookDeliveries lists deliveries of an App webhook.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook
|
||||||
|
func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) {
|
||||||
|
u, err := addOptions("app/hook/deliveries", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
deliveries := []*HookDelivery{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &deliveries)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return deliveries, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHookDelivery returns the App webhook delivery with the specified ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook
|
||||||
|
func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app/hook/deliveries/%v", deliveryID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
h := new(HookDelivery)
|
||||||
|
resp, err := s.client.Do(ctx, req, h)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return h, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RedeliverHookDelivery redelivers a delivery for an App webhook.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook
|
||||||
|
func (s *AppsService) RedeliverHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app/hook/deliveries/%v/attempts", deliveryID)
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
h := new(HookDelivery)
|
||||||
|
resp, err := s.client.Do(ctx, req, h)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return h, resp, nil
|
||||||
|
}
|
||||||
128
vendor/github.com/google/go-github/v48/github/apps_installation.go
generated
vendored
Normal file
128
vendor/github.com/google/go-github/v48/github/apps_installation.go
generated
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRepositories represents the response from the list repos endpoints.
|
||||||
|
type ListRepositories struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepos lists the repositories that are accessible to the authenticated installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-app-installation
|
||||||
|
func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u, err := addOptions("installation/repositories", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
acceptHeaders := []string{
|
||||||
|
mediaTypeTopicsPreview,
|
||||||
|
mediaTypeRepositoryVisibilityPreview,
|
||||||
|
mediaTypeRepositoryTemplatePreview,
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var r *ListRepositories
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserRepos lists repositories that are accessible
|
||||||
|
// to the authenticated user for an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-user-access-token
|
||||||
|
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
acceptHeaders := []string{
|
||||||
|
mediaTypeTopicsPreview,
|
||||||
|
mediaTypeRepositoryVisibilityPreview,
|
||||||
|
mediaTypeRepositoryTemplatePreview,
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var r *ListRepositories
|
||||||
|
resp, err := s.client.Do(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRepository adds a single repository to an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#add-a-repository-to-an-app-installation
|
||||||
|
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := new(Repository)
|
||||||
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRepository removes a single repository from an installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#remove-a-repository-from-an-app-installation
|
||||||
|
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeInstallationToken revokes an installation token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/installations#revoke-an-installation-access-token
|
||||||
|
func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, error) {
|
||||||
|
u := "installation/token"
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
49
vendor/github.com/google/go-github/v48/github/apps_manifest.go
generated
vendored
Normal file
49
vendor/github.com/google/go-github/v48/github/apps_manifest.go
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AppConfig describes the configuration of a GitHub App.
|
||||||
|
type AppConfig struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Slug *string `json:"slug,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
ExternalURL *string `json:"external_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
ClientSecret *string `json:"client_secret,omitempty"`
|
||||||
|
WebhookSecret *string `json:"webhook_secret,omitempty"`
|
||||||
|
PEM *string `json:"pem,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompleteAppManifest completes the App manifest handshake flow for the given
|
||||||
|
// code.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-a-github-app-from-a-manifest
|
||||||
|
func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) {
|
||||||
|
u := fmt.Sprintf("app-manifests/%s/conversions", code)
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg := new(AppConfig)
|
||||||
|
resp, err := s.client.Do(ctx, req, cfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg, resp, nil
|
||||||
|
}
|
||||||
180
vendor/github.com/google/go-github/v48/github/apps_marketplace.go
generated
vendored
Normal file
180
vendor/github.com/google/go-github/v48/github/apps_marketplace.go
generated
vendored
Normal file
|
|
@ -0,0 +1,180 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MarketplaceService handles communication with the marketplace related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#marketplace
|
||||||
|
type MarketplaceService struct {
|
||||||
|
client *Client
|
||||||
|
// Stubbed controls whether endpoints that return stubbed data are used
|
||||||
|
// instead of production endpoints. Stubbed data is fake data that's useful
|
||||||
|
// for testing your GitHub Apps. Stubbed data is hard-coded and will not
|
||||||
|
// change based on actual subscriptions.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#testing-with-stubbed-endpoints
|
||||||
|
Stubbed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePlan represents a GitHub Apps Marketplace Listing Plan.
|
||||||
|
type MarketplacePlan struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
AccountsURL *string `json:"accounts_url,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"`
|
||||||
|
YearlyPriceInCents *int `json:"yearly_price_in_cents,omitempty"`
|
||||||
|
// The pricing model for this listing. Can be one of "flat-rate", "per-unit", or "free".
|
||||||
|
PriceModel *string `json:"price_model,omitempty"`
|
||||||
|
UnitName *string `json:"unit_name,omitempty"`
|
||||||
|
Bullets *[]string `json:"bullets,omitempty"`
|
||||||
|
// State can be one of the values "draft" or "published".
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
HasFreeTrial *bool `json:"has_free_trial,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePurchase represents a GitHub Apps Marketplace Purchase.
|
||||||
|
type MarketplacePurchase struct {
|
||||||
|
// BillingCycle can be one of the values "yearly", "monthly" or nil.
|
||||||
|
BillingCycle *string `json:"billing_cycle,omitempty"`
|
||||||
|
NextBillingDate *Timestamp `json:"next_billing_date,omitempty"`
|
||||||
|
UnitCount *int `json:"unit_count,omitempty"`
|
||||||
|
Plan *MarketplacePlan `json:"plan,omitempty"`
|
||||||
|
OnFreeTrial *bool `json:"on_free_trial,omitempty"`
|
||||||
|
FreeTrialEndsOn *Timestamp `json:"free_trial_ends_on,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePendingChange represents a pending change to a GitHub Apps Marketplace Plan.
|
||||||
|
type MarketplacePendingChange struct {
|
||||||
|
EffectiveDate *Timestamp `json:"effective_date,omitempty"`
|
||||||
|
UnitCount *int `json:"unit_count,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Plan *MarketplacePlan `json:"plan,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarketplacePlanAccount represents a GitHub Account (user or organization) on a specific plan.
|
||||||
|
type MarketplacePlanAccount struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"`
|
||||||
|
MarketplacePurchase *MarketplacePurchase `json:"marketplace_purchase,omitempty"`
|
||||||
|
MarketplacePendingChange *MarketplacePendingChange `json:"marketplace_pending_change,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPlans lists all plans for your Marketplace listing.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#list-plans
|
||||||
|
func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) {
|
||||||
|
uri := s.marketplaceURI("plans")
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var plans []*MarketplacePlan
|
||||||
|
resp, err := s.client.Do(ctx, req, &plans)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return plans, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#list-accounts-for-a-plan
|
||||||
|
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
|
||||||
|
uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID))
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var accounts []*MarketplacePlanAccount
|
||||||
|
resp, err := s.client.Do(ctx, req, &accounts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accounts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPlanAccountForAccount get GitHub account (user or organization) associated with an account.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-subscription-plan-for-an-account
|
||||||
|
func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) {
|
||||||
|
uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID))
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", uri, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var account *MarketplacePlanAccount
|
||||||
|
resp, err := s.client.Do(ctx, req, &account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return account, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user-stubbed
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user
|
||||||
|
func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) {
|
||||||
|
uri := "user/marketplace_purchases"
|
||||||
|
if s.Stubbed {
|
||||||
|
uri = "user/marketplace_purchases/stubbed"
|
||||||
|
}
|
||||||
|
|
||||||
|
u, err := addOptions(uri, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var purchases []*MarketplacePurchase
|
||||||
|
resp, err := s.client.Do(ctx, req, &purchases)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
return purchases, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MarketplaceService) marketplaceURI(endpoint string) string {
|
||||||
|
url := "marketplace_listing"
|
||||||
|
if s.Stubbed {
|
||||||
|
url = "marketplace_listing/stubbed"
|
||||||
|
}
|
||||||
|
return url + "/" + endpoint
|
||||||
|
}
|
||||||
281
vendor/github.com/google/go-github/v48/github/authorizations.go
generated
vendored
Normal file
281
vendor/github.com/google/go-github/v48/github/authorizations.go
generated
vendored
Normal file
|
|
@ -0,0 +1,281 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Scope models a GitHub authorization scope.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/oauth/#scopes
|
||||||
|
type Scope string
|
||||||
|
|
||||||
|
// This is the set of scopes for GitHub API V3
|
||||||
|
const (
|
||||||
|
ScopeNone Scope = "(no scope)" // REVISIT: is this actually returned, or just a documentation artifact?
|
||||||
|
ScopeUser Scope = "user"
|
||||||
|
ScopeUserEmail Scope = "user:email"
|
||||||
|
ScopeUserFollow Scope = "user:follow"
|
||||||
|
ScopePublicRepo Scope = "public_repo"
|
||||||
|
ScopeRepo Scope = "repo"
|
||||||
|
ScopeRepoDeployment Scope = "repo_deployment"
|
||||||
|
ScopeRepoStatus Scope = "repo:status"
|
||||||
|
ScopeDeleteRepo Scope = "delete_repo"
|
||||||
|
ScopeNotifications Scope = "notifications"
|
||||||
|
ScopeGist Scope = "gist"
|
||||||
|
ScopeReadRepoHook Scope = "read:repo_hook"
|
||||||
|
ScopeWriteRepoHook Scope = "write:repo_hook"
|
||||||
|
ScopeAdminRepoHook Scope = "admin:repo_hook"
|
||||||
|
ScopeAdminOrgHook Scope = "admin:org_hook"
|
||||||
|
ScopeReadOrg Scope = "read:org"
|
||||||
|
ScopeWriteOrg Scope = "write:org"
|
||||||
|
ScopeAdminOrg Scope = "admin:org"
|
||||||
|
ScopeReadPublicKey Scope = "read:public_key"
|
||||||
|
ScopeWritePublicKey Scope = "write:public_key"
|
||||||
|
ScopeAdminPublicKey Scope = "admin:public_key"
|
||||||
|
ScopeReadGPGKey Scope = "read:gpg_key"
|
||||||
|
ScopeWriteGPGKey Scope = "write:gpg_key"
|
||||||
|
ScopeAdminGPGKey Scope = "admin:gpg_key"
|
||||||
|
ScopeSecurityEvents Scope = "security_events"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthorizationsService handles communication with the authorization related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// This service requires HTTP Basic Authentication; it cannot be accessed using
|
||||||
|
// an OAuth token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations
|
||||||
|
type AuthorizationsService service
|
||||||
|
|
||||||
|
// Authorization represents an individual GitHub authorization.
|
||||||
|
type Authorization struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Scopes []Scope `json:"scopes,omitempty"`
|
||||||
|
Token *string `json:"token,omitempty"`
|
||||||
|
TokenLastEight *string `json:"token_last_eight,omitempty"`
|
||||||
|
HashedToken *string `json:"hashed_token,omitempty"`
|
||||||
|
App *AuthorizationApp `json:"app,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
|
||||||
|
// User is only populated by the Check and Reset methods.
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a Authorization) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationApp represents an individual GitHub app (in the context of authorization).
|
||||||
|
type AuthorizationApp struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationApp) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grant represents an OAuth application that has been granted access to an account.
|
||||||
|
type Grant struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
App *AuthorizationApp `json:"app,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Grant) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationRequest represents a request to create an authorization.
|
||||||
|
type AuthorizationRequest struct {
|
||||||
|
Scopes []Scope `json:"scopes,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
ClientID *string `json:"client_id,omitempty"`
|
||||||
|
ClientSecret *string `json:"client_secret,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationRequest) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthorizationUpdateRequest represents a request to update an authorization.
|
||||||
|
//
|
||||||
|
// Note that for any one update, you must only provide one of the "scopes"
|
||||||
|
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
|
||||||
|
// "RemoveScopes".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations#update-an-existing-authorization
|
||||||
|
type AuthorizationUpdateRequest struct {
|
||||||
|
Scopes []string `json:"scopes,omitempty"`
|
||||||
|
AddScopes []string `json:"add_scopes,omitempty"`
|
||||||
|
RemoveScopes []string `json:"remove_scopes,omitempty"`
|
||||||
|
Note *string `json:"note,omitempty"`
|
||||||
|
NoteURL *string `json:"note_url,omitempty"`
|
||||||
|
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AuthorizationUpdateRequest) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if an OAuth token is valid for a specific app.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// The returned Authorization.User field will be populated.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#check-a-token
|
||||||
|
func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset is used to reset a valid OAuth token without end user involvement.
|
||||||
|
// Applications must save the "token" property in the response, because changes
|
||||||
|
// take effect immediately.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// The returned Authorization.User field will be populated.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#reset-a-token
|
||||||
|
func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Revoke an authorization for an application.
|
||||||
|
//
|
||||||
|
// Note that this operation requires the use of BasicAuth, but where the
|
||||||
|
// username is the OAuth application clientID, and the password is its
|
||||||
|
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-token
|
||||||
|
func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/token", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteGrant deletes an OAuth application grant. Deleting an application's
|
||||||
|
// grant will also delete all OAuth tokens associated with the application for
|
||||||
|
// the user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-authorization
|
||||||
|
func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("applications/%v/grant", clientID)
|
||||||
|
|
||||||
|
reqBody := &struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
}{AccessToken: accessToken}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, reqBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.Header.Set("Accept", mediaTypeOAuthAppPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateImpersonation creates an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// This requires admin permissions. With the returned Authorization.Token
|
||||||
|
// you can e.g. create or delete a user's public SSH key. NOTE: creating a
|
||||||
|
// new token automatically revokes an existing one.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
||||||
|
func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||||
|
req, err := s.client.NewRequest("POST", u, authReq)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(Authorization)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteImpersonation deletes an impersonation OAuth token.
|
||||||
|
//
|
||||||
|
// NOTE: there can be only one at a time.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
||||||
|
func (s *AuthorizationsService) DeleteImpersonation(ctx context.Context, username string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
199
vendor/github.com/google/go-github/v48/github/billing.go
generated
vendored
Normal file
199
vendor/github.com/google/go-github/v48/github/billing.go
generated
vendored
Normal file
|
|
@ -0,0 +1,199 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BillingService provides access to the billing related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing
|
||||||
|
type BillingService service
|
||||||
|
|
||||||
|
// ActionBilling represents a GitHub Action billing.
|
||||||
|
type ActionBilling struct {
|
||||||
|
TotalMinutesUsed int `json:"total_minutes_used"`
|
||||||
|
TotalPaidMinutesUsed float64 `json:"total_paid_minutes_used"`
|
||||||
|
IncludedMinutes int `json:"included_minutes"`
|
||||||
|
MinutesUsedBreakdown MinutesUsedBreakdown `json:"minutes_used_breakdown"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MinutesUsedBreakdown struct {
|
||||||
|
Ubuntu int `json:"UBUNTU"`
|
||||||
|
MacOS int `json:"MACOS"`
|
||||||
|
Windows int `json:"WINDOWS"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PackageBilling represents a GitHub Package billing.
|
||||||
|
type PackageBilling struct {
|
||||||
|
TotalGigabytesBandwidthUsed int `json:"total_gigabytes_bandwidth_used"`
|
||||||
|
TotalPaidGigabytesBandwidthUsed int `json:"total_paid_gigabytes_bandwidth_used"`
|
||||||
|
IncludedGigabytesBandwidth int `json:"included_gigabytes_bandwidth"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StorageBilling represents a GitHub Storage billing.
|
||||||
|
type StorageBilling struct {
|
||||||
|
DaysLeftInBillingCycle int `json:"days_left_in_billing_cycle"`
|
||||||
|
EstimatedPaidStorageForMonth float64 `json:"estimated_paid_storage_for_month"`
|
||||||
|
EstimatedStorageForMonth int `json:"estimated_storage_for_month"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ActiveCommitters represents the total active committers across all repositories in an Organization.
|
||||||
|
type ActiveCommitters struct {
|
||||||
|
TotalAdvancedSecurityCommitters int `json:"total_advanced_security_committers"`
|
||||||
|
Repositories []*RepositoryActiveCommitters `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RepositoryActiveCommitters represents active committers on each repository.
|
||||||
|
type RepositoryActiveCommitters struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
AdvancedSecurityCommitters *int `json:"advanced_security_committers,omitempty"`
|
||||||
|
AdvancedSecurityCommittersBreakdown []*AdvancedSecurityCommittersBreakdown `json:"advanced_security_committers_breakdown,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdvancedSecurityCommittersBreakdown represents the user activity breakdown for ActiveCommitters.
|
||||||
|
type AdvancedSecurityCommittersBreakdown struct {
|
||||||
|
UserLogin *string `json:"user_login,omitempty"`
|
||||||
|
LastPushedDate *string `json:"last_pushed_date,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsBillingOrg returns the summary of the free and paid GitHub Actions minutes used for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-actions-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/actions", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
actionsOrgBilling := new(ActionBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, actionsOrgBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsOrgBilling, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPackagesBillingOrg returns the free and paid storage used for GitHub Packages in gigabytes for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-packages-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/packages", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
packagesOrgBilling := new(PackageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, packagesOrgBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return packagesOrgBilling, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStorageBillingOrg returns the estimated paid and estimated total storage used for GitHub Actions
|
||||||
|
// and GitHub Packages in gigabytes for an Org.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-an-organization
|
||||||
|
func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
storageOrgBilling := new(StorageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, storageOrgBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageOrgBilling, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAdvancedSecurityActiveCommittersOrg returns the GitHub Advanced Security active committers for an organization per repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-advanced-security-active-committers-for-an-organization
|
||||||
|
func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string) (*ActiveCommitters, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
activeOrgCommitters := new(ActiveCommitters)
|
||||||
|
resp, err := s.client.Do(ctx, req, activeOrgCommitters)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return activeOrgCommitters, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsBillingUser returns the summary of the free and paid GitHub Actions minutes used for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-actions-billing-for-a-user
|
||||||
|
func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/actions", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
actionsUserBilling := new(ActionBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, actionsUserBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsUserBilling, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPackagesBillingUser returns the free and paid storage used for GitHub Packages in gigabytes for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-packages-billing-for-a-user
|
||||||
|
func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/packages", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
packagesUserBilling := new(PackageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, packagesUserBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return packagesUserBilling, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetStorageBillingUser returns the estimated paid and estimated total storage used for GitHub Actions
|
||||||
|
// and GitHub Packages in gigabytes for a user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-a-user
|
||||||
|
func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) {
|
||||||
|
u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
storageUserBilling := new(StorageBilling)
|
||||||
|
resp, err := s.client.Do(ctx, req, storageUserBilling)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageUserBilling, resp, nil
|
||||||
|
}
|
||||||
451
vendor/github.com/google/go-github/v48/github/checks.go
generated
vendored
Normal file
451
vendor/github.com/google/go-github/v48/github/checks.go
generated
vendored
Normal file
|
|
@ -0,0 +1,451 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChecksService provides access to the Checks API in the
|
||||||
|
// GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/
|
||||||
|
type ChecksService service
|
||||||
|
|
||||||
|
// CheckRun represents a GitHub check run on a repository associated with a GitHub app.
|
||||||
|
type CheckRun struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
ExternalID *string `json:"external_id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"`
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
CheckSuite *CheckSuite `json:"check_suite,omitempty"`
|
||||||
|
App *App `json:"app,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunOutput represents the output of a CheckRun.
|
||||||
|
type CheckRunOutput struct {
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Summary *string `json:"summary,omitempty"`
|
||||||
|
Text *string `json:"text,omitempty"`
|
||||||
|
AnnotationsCount *int `json:"annotations_count,omitempty"`
|
||||||
|
AnnotationsURL *string `json:"annotations_url,omitempty"`
|
||||||
|
Annotations []*CheckRunAnnotation `json:"annotations,omitempty"`
|
||||||
|
Images []*CheckRunImage `json:"images,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunAnnotation represents an annotation object for a CheckRun output.
|
||||||
|
type CheckRunAnnotation struct {
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
StartLine *int `json:"start_line,omitempty"`
|
||||||
|
EndLine *int `json:"end_line,omitempty"`
|
||||||
|
StartColumn *int `json:"start_column,omitempty"`
|
||||||
|
EndColumn *int `json:"end_column,omitempty"`
|
||||||
|
AnnotationLevel *string `json:"annotation_level,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
RawDetails *string `json:"raw_details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunImage represents an image object for a CheckRun output.
|
||||||
|
type CheckRunImage struct {
|
||||||
|
Alt *string `json:"alt,omitempty"`
|
||||||
|
ImageURL *string `json:"image_url,omitempty"`
|
||||||
|
Caption *string `json:"caption,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuite represents a suite of check runs.
|
||||||
|
type CheckSuite struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"`
|
||||||
|
HeadSHA *string `json:"head_sha,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
BeforeSHA *string `json:"before,omitempty"`
|
||||||
|
AfterSHA *string `json:"after,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
App *App `json:"app,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
PullRequests []*PullRequest `json:"pull_requests,omitempty"`
|
||||||
|
|
||||||
|
// The following fields are only populated by Webhook events.
|
||||||
|
HeadCommit *Commit `json:"head_commit,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CheckRun) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CheckSuite) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCheckRun gets a check-run for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#get-a-check-run
|
||||||
|
func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCheckSuite gets a single check suite.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#get-a-check-suite
|
||||||
|
func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v", owner, repo, checkSuiteID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
checkSuite := new(CheckSuite)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkSuite)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuite, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckRunOptions sets up parameters needed to create a CheckRun.
|
||||||
|
type CreateCheckRunOptions struct {
|
||||||
|
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
|
||||||
|
HeadSHA string `json:"head_sha"` // The SHA of the commit. (Required.)
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
|
||||||
|
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
|
||||||
|
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "skipped", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"` // The time that the check run began. (Optional.)
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
|
||||||
|
Actions []*CheckRunAction `json:"actions,omitempty"` // Possible further actions the integrator can perform, which a user may trigger. (Optional.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckRunAction exposes further actions the integrator can perform, which a user may trigger.
|
||||||
|
type CheckRunAction struct {
|
||||||
|
Label string `json:"label"` // The text to be displayed on a button in the web UI. The maximum size is 20 characters. (Required.)
|
||||||
|
Description string `json:"description"` // A short explanation of what this action would do. The maximum size is 40 characters. (Required.)
|
||||||
|
Identifier string `json:"identifier"` // A reference for the action on the integrator's system. The maximum size is 20 characters. (Required.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckRun creates a check run for repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#create-a-check-run
|
||||||
|
func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCheckRunOptions sets up parameters needed to update a CheckRun.
|
||||||
|
type UpdateCheckRunOptions struct {
|
||||||
|
Name string `json:"name"` // The name of the check (e.g., "code-coverage"). (Required.)
|
||||||
|
DetailsURL *string `json:"details_url,omitempty"` // The URL of the integrator's site that has the full details of the check. (Optional.)
|
||||||
|
ExternalID *string `json:"external_id,omitempty"` // A reference for the run on the integrator's system. (Optional.)
|
||||||
|
Status *string `json:"status,omitempty"` // The current status. Can be one of "queued", "in_progress", or "completed". Default: "queued". (Optional.)
|
||||||
|
Conclusion *string `json:"conclusion,omitempty"` // Can be one of "success", "failure", "neutral", "cancelled", "skipped", "timed_out", or "action_required". (Optional. Required if you provide a status of "completed".)
|
||||||
|
CompletedAt *Timestamp `json:"completed_at,omitempty"` // The time the check completed. (Optional. Required if you provide conclusion.)
|
||||||
|
Output *CheckRunOutput `json:"output,omitempty"` // Provide descriptive details about the run. (Optional)
|
||||||
|
Actions []*CheckRunAction `json:"actions,omitempty"` // Possible further actions the integrator can perform, which a user may trigger. (Optional.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCheckRun updates a check run for a specific commit in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#update-a-check-run
|
||||||
|
func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
checkRun := new(CheckRun)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkRun)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRun, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunAnnotations lists the annotations for a check run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-run-annotations
|
||||||
|
func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/annotations", owner, repo, checkRunID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
var checkRunAnnotations []*CheckRunAnnotation
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunAnnotations)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunAnnotations, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsOptions represents parameters to list check runs.
|
||||||
|
type ListCheckRunsOptions struct {
|
||||||
|
CheckName *string `url:"check_name,omitempty"` // Returns check runs with the specified name.
|
||||||
|
Status *string `url:"status,omitempty"` // Returns check runs with the specified status. Can be one of "queued", "in_progress", or "completed".
|
||||||
|
Filter *string `url:"filter,omitempty"` // Filters check runs by their completed_at timestamp. Can be one of "latest" (returning the most recent check runs) or "all". Default: "latest"
|
||||||
|
AppID *int64 `url:"app_id,omitempty"` // Filters check runs by GitHub App ID.
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsResults represents the result of a check run list.
|
||||||
|
type ListCheckRunsResults struct {
|
||||||
|
Total *int `json:"total_count,omitempty"`
|
||||||
|
CheckRuns []*CheckRun `json:"check_runs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsForRef lists check runs for a specific ref.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-for-a-git-reference
|
||||||
|
func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
var checkRunResults *ListCheckRunsResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckRunsCheckSuite lists check runs for a check suite.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-in-a-check-suite
|
||||||
|
func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/check-runs", owner, repo, checkSuiteID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
var checkRunResults *ListCheckRunsResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkRunResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkRunResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReRequestCheckRun triggers GitHub to rerequest an existing check run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/runs#rerequest-a-check-run
|
||||||
|
func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-runs/%v/rerequest", owner, repo, checkRunID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuiteOptions represents parameters to list check suites.
|
||||||
|
type ListCheckSuiteOptions struct {
|
||||||
|
CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run.
|
||||||
|
AppID *int `url:"app_id,omitempty"` // Filters check suites by GitHub App id.
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuiteResults represents the result of a check run list.
|
||||||
|
type ListCheckSuiteResults struct {
|
||||||
|
Total *int `json:"total_count,omitempty"`
|
||||||
|
CheckSuites []*CheckSuite `json:"check_suites,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCheckSuitesForRef lists check suite for a specific ref.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#list-check-suites-for-a-git-reference
|
||||||
|
func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
var checkSuiteResults *ListCheckSuiteResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkSuiteResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuiteResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoTriggerCheck enables or disables automatic creation of CheckSuite events upon pushes to the repository.
|
||||||
|
type AutoTriggerCheck struct {
|
||||||
|
AppID *int64 `json:"app_id,omitempty"` // The id of the GitHub App. (Required.)
|
||||||
|
Setting *bool `json:"setting,omitempty"` // Set to "true" to enable automatic creation of CheckSuite events upon pushes to the repository, or "false" to disable them. Default: "true" (Required.)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuitePreferenceOptions set options for check suite preferences for a repository.
|
||||||
|
type CheckSuitePreferenceOptions struct {
|
||||||
|
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckSuitePreferenceResults represents the results of the preference set operation.
|
||||||
|
type CheckSuitePreferenceResults struct {
|
||||||
|
Preferences *PreferenceList `json:"preferences,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferenceList represents a list of auto trigger checks for repository
|
||||||
|
type PreferenceList struct {
|
||||||
|
AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCheckSuitePreferences changes the default automatic flow when creating check suites.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#update-repository-preferences-for-check-suites
|
||||||
|
func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, repo string, opts CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/preferences", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
var checkSuitePrefResults *CheckSuitePreferenceResults
|
||||||
|
resp, err := s.client.Do(ctx, req, &checkSuitePrefResults)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuitePrefResults, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckSuiteOptions sets up parameters to manually create a check suites
|
||||||
|
type CreateCheckSuiteOptions struct {
|
||||||
|
HeadSHA string `json:"head_sha"` // The sha of the head commit. (Required.)
|
||||||
|
HeadBranch *string `json:"head_branch,omitempty"` // The name of the head branch where the code changes are implemented.
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCheckSuite manually creates a check suite for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#create-a-check-suite
|
||||||
|
func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
checkSuite := new(CheckSuite)
|
||||||
|
resp, err := s.client.Do(ctx, req, checkSuite)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkSuite, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/checks/suites#rerequest-a-check-suite
|
||||||
|
func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeCheckRunsPreview)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
339
vendor/github.com/google/go-github/v48/github/code-scanning.go
generated
vendored
Normal file
339
vendor/github.com/google/go-github/v48/github/code-scanning.go
generated
vendored
Normal file
|
|
@ -0,0 +1,339 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CodeScanningService handles communication with the code scanning related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||||
|
type CodeScanningService service
|
||||||
|
|
||||||
|
// Rule represents the complete details of GitHub Code Scanning alert type.
|
||||||
|
type Rule struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Severity *string `json:"severity,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
SecuritySeverityLevel *string `json:"security_severity_level,omitempty"`
|
||||||
|
FullDescription *string `json:"full_description,omitempty"`
|
||||||
|
Tags []string `json:"tags,omitempty"`
|
||||||
|
Help *string `json:"help,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Location represents the exact location of the GitHub Code Scanning Alert in the scanned project.
|
||||||
|
type Location struct {
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
StartLine *int `json:"start_line,omitempty"`
|
||||||
|
EndLine *int `json:"end_line,omitempty"`
|
||||||
|
StartColumn *int `json:"start_column,omitempty"`
|
||||||
|
EndColumn *int `json:"end_column,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object.
|
||||||
|
type Message struct {
|
||||||
|
Text *string `json:"text,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference.
|
||||||
|
type MostRecentInstance struct {
|
||||||
|
Ref *string `json:"ref,omitempty"`
|
||||||
|
AnalysisKey *string `json:"analysis_key,omitempty"`
|
||||||
|
Environment *string `json:"environment,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
CommitSHA *string `json:"commit_sha,omitempty"`
|
||||||
|
Message *Message `json:"message,omitempty"`
|
||||||
|
Location *Location `json:"location,omitempty"`
|
||||||
|
Classifications []string `json:"classifications,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tool represents the tool used to generate a GitHub Code Scanning Alert.
|
||||||
|
type Tool struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
GUID *string `json:"guid,omitempty"`
|
||||||
|
Version *string `json:"version,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alert represents an individual GitHub Code Scanning Alert on a single repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||||
|
type Alert struct {
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
RuleID *string `json:"rule_id,omitempty"`
|
||||||
|
RuleSeverity *string `json:"rule_severity,omitempty"`
|
||||||
|
RuleDescription *string `json:"rule_description,omitempty"`
|
||||||
|
Rule *Rule `json:"rule,omitempty"`
|
||||||
|
Tool *Tool `json:"tool,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
FixedAt *Timestamp `json:"fixed_at,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
ClosedBy *User `json:"closed_by,omitempty"`
|
||||||
|
ClosedAt *Timestamp `json:"closed_at,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"`
|
||||||
|
Instances []*MostRecentInstance `json:"instances,omitempty"`
|
||||||
|
DismissedBy *User `json:"dismissed_by,omitempty"`
|
||||||
|
DismissedAt *Timestamp `json:"dismissed_at,omitempty"`
|
||||||
|
DismissedReason *string `json:"dismissed_reason,omitempty"`
|
||||||
|
DismissedComment *string `json:"dismissed_comment,omitempty"`
|
||||||
|
InstancesURL *string `json:"instances_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ID returns the ID associated with an alert. It is the number at the end of the security alert's URL.
|
||||||
|
func (a *Alert) ID() int64 {
|
||||||
|
if a == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
s := a.GetHTMLURL()
|
||||||
|
|
||||||
|
// Check for an ID to parse at the end of the url
|
||||||
|
if i := strings.LastIndex(s, "/"); i >= 0 {
|
||||||
|
s = s[i+1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the alert ID as a 64-bit integer. Unable to convert or out of range returns 0.
|
||||||
|
id, err := strconv.ParseInt(s, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlertListOptions specifies optional parameters to the CodeScanningService.ListAlerts
|
||||||
|
// method.
|
||||||
|
type AlertListOptions struct {
|
||||||
|
// State of the code scanning alerts to list. Set to closed to list only closed code scanning alerts. Default: open
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Return code scanning alerts for a specific branch reference. The ref must be formatted as heads/<branch name>.
|
||||||
|
Ref string `url:"ref,omitempty"`
|
||||||
|
|
||||||
|
ListCursorOptions
|
||||||
|
|
||||||
|
// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
|
||||||
|
// since ListCursorOptions accepts "page" as string only.
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// AnalysesListOptions specifies optional parameters to the CodeScanningService.ListAnalysesForRepo method.
|
||||||
|
type AnalysesListOptions struct {
|
||||||
|
// Return code scanning analyses belonging to the same SARIF upload.
|
||||||
|
SarifID *string `url:"sarif_id,omitempty"`
|
||||||
|
|
||||||
|
// Return code scanning analyses for a specific branch reference. The ref can be formatted as refs/heads/<branch name> or simply <branch name>.
|
||||||
|
Ref *string `url:"ref,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||||
|
type ScanningAnalysis struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Ref *string `json:"ref,omitempty"`
|
||||||
|
CommitSHA *string `json:"commit_sha,omitempty"`
|
||||||
|
AnalysisKey *string `json:"analysis_key,omitempty"`
|
||||||
|
Environment *string `json:"environment,omitempty"`
|
||||||
|
Error *string `json:"error,omitempty"`
|
||||||
|
Category *string `json:"category,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
ResultsCount *int `json:"results_count,omitempty"`
|
||||||
|
RulesCount *int `json:"rules_count,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
SarifID *string `json:"sarif_id,omitempty"`
|
||||||
|
Tool *Tool `json:"tool,omitempty"`
|
||||||
|
Deletable *bool `json:"deletable,omitempty"`
|
||||||
|
Warning *string `json:"warning,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SarifAnalysis specifies the results of a code scanning job.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||||
|
type SarifAnalysis struct {
|
||||||
|
CommitSHA *string `json:"commit_sha,omitempty"`
|
||||||
|
Ref *string `json:"ref,omitempty"`
|
||||||
|
Sarif *string `json:"sarif,omitempty"`
|
||||||
|
CheckoutURI *string `json:"checkout_uri,omitempty"`
|
||||||
|
StartedAt *Timestamp `json:"started_at,omitempty"`
|
||||||
|
ToolName *string `json:"tool_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SarifID identifies a sarif analysis upload.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning
|
||||||
|
type SarifID struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAlertsForOrg lists code scanning alerts for an org.
|
||||||
|
//
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events
|
||||||
|
// read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-alerts-for-an-organization
|
||||||
|
func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *AlertListOptions) ([]*Alert, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/code-scanning/alerts", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var alerts []*Alert
|
||||||
|
resp, err := s.client.Do(ctx, req, &alerts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return alerts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAlertsForRepo lists code scanning alerts for a repository.
|
||||||
|
//
|
||||||
|
// Lists all open code scanning alerts for the default branch (usually master) and protected branches in a repository.
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events
|
||||||
|
// read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-alerts-for-a-repository
|
||||||
|
func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *AlertListOptions) ([]*Alert, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var alerts []*Alert
|
||||||
|
resp, err := s.client.Do(ctx, req, &alerts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return alerts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAlert gets a single code scanning alert for a repository.
|
||||||
|
//
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint.
|
||||||
|
// GitHub Apps must have the security_events read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// The security alert_id is the number at the end of the security alert's URL.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-alert
|
||||||
|
func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string, id int64) (*Alert, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
a := new(Alert)
|
||||||
|
resp, err := s.client.Do(ctx, req, a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UploadSarif uploads the result of code scanning job to GitHub.
|
||||||
|
//
|
||||||
|
// For the parameter sarif, you must first compress your SARIF file using gzip and then translate the contents of the file into a Base64 encoding string.
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events
|
||||||
|
// write permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#upload-an-analysis-as-sarif-data
|
||||||
|
func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, sarif *SarifAnalysis) (*SarifID, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs", owner, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, sarif)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sarifID := new(SarifID)
|
||||||
|
resp, err := s.client.Do(ctx, req, sarifID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sarifID, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAnalysesForRepo lists code scanning analyses for a repository.
|
||||||
|
//
|
||||||
|
// Lists the details of all code scanning analyses for a repository, starting with the most recent.
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint.
|
||||||
|
// GitHub Apps must have the security_events read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-analyses-for-a-repository
|
||||||
|
func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*ScanningAnalysis, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var analyses []*ScanningAnalysis
|
||||||
|
resp, err := s.client.Do(ctx, req, &analyses)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return analyses, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAnalysis gets a single code scanning analysis for a repository.
|
||||||
|
//
|
||||||
|
// You must use an access token with the security_events scope to use this endpoint.
|
||||||
|
// GitHub Apps must have the security_events read permission to use this endpoint.
|
||||||
|
//
|
||||||
|
// The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-analysis-for-a-repository
|
||||||
|
func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*ScanningAnalysis, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
analysis := new(ScanningAnalysis)
|
||||||
|
resp, err := s.client.Do(ctx, req, analysis)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return analysis, resp, nil
|
||||||
|
}
|
||||||
12
vendor/github.com/google/go-github/v48/github/dependabot.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v48/github/dependabot.go
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// DependabotService handles communication with the Dependabot related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/
|
||||||
|
type DependabotService service
|
||||||
134
vendor/github.com/google/go-github/v48/github/dependabot_alerts.go
generated
vendored
Normal file
134
vendor/github.com/google/go-github/v48/github/dependabot_alerts.go
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Dependency reprensents the vulnerable dependency.
|
||||||
|
type Dependency struct {
|
||||||
|
Package *VulnerabilityPackage `json:"package,omitempty"`
|
||||||
|
ManifestPath *string `json:"manifest_path,omitempty"`
|
||||||
|
Scope *string `json:"scope,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdvisoryCVSs represents the advisory pertaining to the Common Vulnerability Scoring System.
|
||||||
|
type AdvisoryCVSs struct {
|
||||||
|
Score *float64 `json:"score,omitempty"`
|
||||||
|
VectorString *string `json:"vector_string,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdvisoryCWEs reprensent the advisory pertaining to Common Weakness Enumeration.
|
||||||
|
type AdvisoryCWEs struct {
|
||||||
|
CWEID *string `json:"cwe_id,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DependabotSecurityAdvisory represents the GitHub Security Advisory.
|
||||||
|
type DependabotSecurityAdvisory struct {
|
||||||
|
GHSAID *string `json:"ghsa_id,omitempty"`
|
||||||
|
CVEID *string `json:"cve_id,omitempty"`
|
||||||
|
Summary *string `json:"summary,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"`
|
||||||
|
Severity *string `json:"severity,omitempty"`
|
||||||
|
CVSs *AdvisoryCVSs `json:"cvss,omitempty"`
|
||||||
|
CWEs []*AdvisoryCWEs `json:"cwes,omitempty"`
|
||||||
|
Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"`
|
||||||
|
References []*AdvisoryReference `json:"references,omitempty"`
|
||||||
|
PublishedAt *Timestamp `json:"published_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DependabotAlert represents a Dependabot alert.
|
||||||
|
type DependabotAlert struct {
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
Dependency *Dependency `json:"dependency,omitempty"`
|
||||||
|
SecurityAdvisory *DependabotSecurityAdvisory `json:"security_advisory,omitempty"`
|
||||||
|
SecurityVulnerability *AdvisoryVulnerability `json:"security_vulnerability,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
DismissedAt *Timestamp `json:"dismissed_at,omitempty"`
|
||||||
|
DismissedBy *User `json:"dismissed_by,omitempty"`
|
||||||
|
DismissedReason *string `json:"dismissed_reason,omitempty"`
|
||||||
|
DismissedComment *string `json:"dismissed_comment,omitempty"`
|
||||||
|
FixedAt *Timestamp `json:"fixed_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAlertsOptions specifies the optional parameters to the DependabotService.ListRepoAlerts
|
||||||
|
// and DependabotService.ListOrgAlerts methods.
|
||||||
|
type ListAlertsOptions struct {
|
||||||
|
State *string `url:"state,omitempty"`
|
||||||
|
Severity *string `url:"severity,omitempty"`
|
||||||
|
Ecosystem *string `url:"ecosystem,omitempty"`
|
||||||
|
Package *string `url:"package,omitempty"`
|
||||||
|
Scope *string `url:"scope,omitempty"`
|
||||||
|
Sort *string `url:"sort,omitempty"`
|
||||||
|
Direction *string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
ListCursorOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DependabotService) listAlerts(ctx context.Context, url string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) {
|
||||||
|
u, err := addOptions(url, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var alerts []*DependabotAlert
|
||||||
|
resp, err := s.client.Do(ctx, req, &alerts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return alerts, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepoAlerts lists all Dependabot alerts of a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository
|
||||||
|
func (s *DependabotService) ListRepoAlerts(ctx context.Context, owner, repo string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/alerts", owner, repo)
|
||||||
|
return s.listAlerts(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgAlerts lists all Dependabot alerts of an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#list-dependabot-alerts-for-an-organization
|
||||||
|
func (s *DependabotService) ListOrgAlerts(ctx context.Context, org string, opts *ListAlertsOptions) ([]*DependabotAlert, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/alerts", org)
|
||||||
|
return s.listAlerts(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoAlert gets a single repository Dependabot alert.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/alerts#get-a-dependabot-alert
|
||||||
|
func (s *DependabotService) GetRepoAlert(ctx context.Context, owner, repo string, number int) (*DependabotAlert, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/alerts/%v", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
alert := new(DependabotAlert)
|
||||||
|
resp, err := s.client.Do(ctx, req, alert)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return alert, resp, nil
|
||||||
|
}
|
||||||
244
vendor/github.com/google/go-github/v48/github/dependabot_secrets.go
generated
vendored
Normal file
244
vendor/github.com/google/go-github/v48/github/dependabot_secrets.go
generated
vendored
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
// Copyright 2022 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *DependabotService) getPublicKey(ctx context.Context, url string) (*PublicKey, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
pubKey := new(PublicKey)
|
||||||
|
resp, err := s.client.Do(ctx, req, pubKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubKey, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-public-key
|
||||||
|
func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/public-key", owner, repo)
|
||||||
|
return s.getPublicKey(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-public-key
|
||||||
|
func (s *DependabotService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", org)
|
||||||
|
return s.getPublicKey(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DependabotService) listSecrets(ctx context.Context, url string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
u, err := addOptions(url, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secrets := new(Secrets)
|
||||||
|
resp, err := s.client.Do(ctx, req, &secrets)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secrets, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepoSecrets lists all Dependabot secrets available in a repository
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-repository-secrets
|
||||||
|
func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets", owner, repo)
|
||||||
|
return s.listSecrets(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOrgSecrets lists all Dependabot secrets available in an organization
|
||||||
|
// without revealing their encrypted values.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-organization-secrets
|
||||||
|
func (s *DependabotService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets", org)
|
||||||
|
return s.listSecrets(ctx, url, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DependabotService) getSecret(ctx context.Context, url string) (*Secret, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
secret := new(Secret)
|
||||||
|
resp, err := s.client.Do(ctx, req, secret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return secret, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-secret
|
||||||
|
func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
|
||||||
|
return s.getSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-secret
|
||||||
|
func (s *DependabotService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
|
||||||
|
return s.getSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DependabotEncryptedSecret represents a secret that is encrypted using a public key for Dependabot.
|
||||||
|
//
|
||||||
|
// The value of EncryptedValue must be your secret, encrypted with
|
||||||
|
// LibSodium (see documentation here: https://libsodium.gitbook.io/doc/bindings_for_other_languages)
|
||||||
|
// using the public key retrieved using the GetPublicKey method.
|
||||||
|
type DependabotEncryptedSecret struct {
|
||||||
|
Name string `json:"-"`
|
||||||
|
KeyID string `json:"key_id"`
|
||||||
|
EncryptedValue string `json:"encrypted_value"`
|
||||||
|
Visibility string `json:"visibility,omitempty"`
|
||||||
|
SelectedRepositoryIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("PUT", url, eSecret)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret
|
||||||
|
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name)
|
||||||
|
return s.putSecret(ctx, url, eSecret)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
|
||||||
|
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
|
||||||
|
return s.putSecret(ctx, url, eSecret)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Response, error) {
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret
|
||||||
|
func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name)
|
||||||
|
return s.deleteSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret
|
||||||
|
func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name)
|
||||||
|
return s.deleteSecret(ctx, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
|
||||||
|
u, err := addOptions(url, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := new(SelectedReposList)
|
||||||
|
resp, err := s.client.Do(ctx, req, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DependabotSecretsSelectedRepoIDs are the repository IDs that have access to the dependabot secrets.
|
||||||
|
type DependabotSecretsSelectedRepoIDs []string
|
||||||
|
|
||||||
|
// SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret
|
||||||
|
func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids DependabotSecretsSelectedRepoIDs) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name)
|
||||||
|
type repoIDs struct {
|
||||||
|
SelectedIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", url, repoIDs{SelectedIDs: ids})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret
|
||||||
|
func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
req, err := s.client.NewRequest("PUT", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret
|
||||||
|
func (s *DependabotService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
212
vendor/github.com/google/go-github/v48/github/doc.go
generated
vendored
Normal file
212
vendor/github.com/google/go-github/v48/github/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,212 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
/*
|
||||||
|
Package github provides a client for using the GitHub API.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
import "github.com/google/go-github/v48/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
|
||||||
|
import "github.com/google/go-github/github" // with go modules disabled
|
||||||
|
|
||||||
|
Construct a new GitHub client, then use the various services on the client to
|
||||||
|
access different parts of the GitHub API. For example:
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
// list all organizations for user "willnorris"
|
||||||
|
orgs, _, err := client.Organizations.List(ctx, "willnorris", nil)
|
||||||
|
|
||||||
|
Some API methods have optional parameters that can be passed. For example:
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
// list public repositories for org "github"
|
||||||
|
opt := &github.RepositoryListByOrgOptions{Type: "public"}
|
||||||
|
repos, _, err := client.Repositories.ListByOrg(ctx, "github", opt)
|
||||||
|
|
||||||
|
The services of a client divide the API into logical chunks and correspond to
|
||||||
|
the structure of the GitHub API documentation at
|
||||||
|
https://docs.github.com/en/rest .
|
||||||
|
|
||||||
|
NOTE: Using the https://godoc.org/context package, one can easily
|
||||||
|
pass cancelation signals and deadlines to various services of the client for
|
||||||
|
handling a request. In case there is no context available, then context.Background()
|
||||||
|
can be used as a starting point.
|
||||||
|
|
||||||
|
For more sample code snippets, head over to the https://github.com/google/go-github/tree/master/example directory.
|
||||||
|
|
||||||
|
# Authentication
|
||||||
|
|
||||||
|
The go-github library does not directly handle authentication. Instead, when
|
||||||
|
creating a new client, pass an http.Client that can handle authentication for
|
||||||
|
you. The easiest and recommended way to do this is using the golang.org/x/oauth2
|
||||||
|
library, but you can always use any other library that provides an http.Client.
|
||||||
|
If you have an OAuth2 access token (for example, a personal API token), you can
|
||||||
|
use it with the oauth2 library using:
|
||||||
|
|
||||||
|
import "golang.org/x/oauth2"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
ctx := context.Background()
|
||||||
|
ts := oauth2.StaticTokenSource(
|
||||||
|
&oauth2.Token{AccessToken: "... your access token ..."},
|
||||||
|
)
|
||||||
|
tc := oauth2.NewClient(ctx, ts)
|
||||||
|
|
||||||
|
client := github.NewClient(tc)
|
||||||
|
|
||||||
|
// list all repositories for the authenticated user
|
||||||
|
repos, _, err := client.Repositories.List(ctx, "", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
Note that when using an authenticated Client, all calls made by the client will
|
||||||
|
include the specified OAuth token. Therefore, authenticated clients should
|
||||||
|
almost never be shared between different users.
|
||||||
|
|
||||||
|
See the oauth2 docs for complete instructions on using that library.
|
||||||
|
|
||||||
|
For API methods that require HTTP Basic Authentication, use the
|
||||||
|
BasicAuthTransport.
|
||||||
|
|
||||||
|
GitHub Apps authentication can be provided by the
|
||||||
|
https://github.com/bradleyfalzon/ghinstallation package.
|
||||||
|
It supports both authentication as an installation, using an installation access token,
|
||||||
|
and as an app, using a JWT.
|
||||||
|
|
||||||
|
To authenticate as an installation:
|
||||||
|
|
||||||
|
import "github.com/bradleyfalzon/ghinstallation"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
|
||||||
|
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, 1, 99, "2016-10-19.private-key.pem")
|
||||||
|
if err != nil {
|
||||||
|
// Handle error.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use installation transport with client
|
||||||
|
client := github.NewClient(&http.Client{Transport: itr})
|
||||||
|
|
||||||
|
// Use client...
|
||||||
|
}
|
||||||
|
|
||||||
|
To authenticate as an app, using a JWT:
|
||||||
|
|
||||||
|
import "github.com/bradleyfalzon/ghinstallation"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Wrap the shared transport for use with the application ID 1.
|
||||||
|
atr, err := ghinstallation.NewAppsTransportKeyFromFile(http.DefaultTransport, 1, "2016-10-19.private-key.pem")
|
||||||
|
if err != nil {
|
||||||
|
// Handle error.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use app transport with client
|
||||||
|
client := github.NewClient(&http.Client{Transport: atr})
|
||||||
|
|
||||||
|
// Use client...
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rate Limiting
|
||||||
|
|
||||||
|
GitHub imposes a rate limit on all API clients. Unauthenticated clients are
|
||||||
|
limited to 60 requests per hour, while authenticated clients can make up to
|
||||||
|
5,000 requests per hour. The Search API has a custom rate limit. Unauthenticated
|
||||||
|
clients are limited to 10 requests per minute, while authenticated clients
|
||||||
|
can make up to 30 requests per minute. To receive the higher rate limit when
|
||||||
|
making calls that are not issued on behalf of a user,
|
||||||
|
use UnauthenticatedRateLimitedTransport.
|
||||||
|
|
||||||
|
The returned Response.Rate value contains the rate limit information
|
||||||
|
from the most recent API call. If a recent enough response isn't
|
||||||
|
available, you can use RateLimits to fetch the most up-to-date rate
|
||||||
|
limit data for the client.
|
||||||
|
|
||||||
|
To detect an API rate limit error, you can check if its type is *github.RateLimitError.
|
||||||
|
For secondary rate limits, you can check if its type is *github.AbuseRateLimitError:
|
||||||
|
|
||||||
|
repos, _, err := client.Repositories.List(ctx, "", nil)
|
||||||
|
if _, ok := err.(*github.RateLimitError); ok {
|
||||||
|
log.Println("hit rate limit")
|
||||||
|
}
|
||||||
|
if _, ok := err.(*github.AbuseRateLimitError); ok {
|
||||||
|
log.Println("hit secondary rate limit")
|
||||||
|
}
|
||||||
|
|
||||||
|
Learn more about GitHub rate limiting at
|
||||||
|
https://docs.github.com/en/rest/rate-limit .
|
||||||
|
|
||||||
|
# Accepted Status
|
||||||
|
|
||||||
|
Some endpoints may return a 202 Accepted status code, meaning that the
|
||||||
|
information required is not yet ready and was scheduled to be gathered on
|
||||||
|
the GitHub side. Methods known to behave like this are documented specifying
|
||||||
|
this behavior.
|
||||||
|
|
||||||
|
To detect this condition of error, you can check if its type is
|
||||||
|
*github.AcceptedError:
|
||||||
|
|
||||||
|
stats, _, err := client.Repositories.ListContributorsStats(ctx, org, repo)
|
||||||
|
if _, ok := err.(*github.AcceptedError); ok {
|
||||||
|
log.Println("scheduled on GitHub side")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Conditional Requests
|
||||||
|
|
||||||
|
The GitHub API has good support for conditional requests which will help
|
||||||
|
prevent you from burning through your rate limit, as well as help speed up your
|
||||||
|
application. go-github does not handle conditional requests directly, but is
|
||||||
|
instead designed to work with a caching http.Transport. We recommend using
|
||||||
|
https://github.com/gregjones/httpcache for that.
|
||||||
|
|
||||||
|
Learn more about GitHub conditional requests at
|
||||||
|
https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests.
|
||||||
|
|
||||||
|
# Creating and Updating Resources
|
||||||
|
|
||||||
|
All structs for GitHub resources use pointer values for all non-repeated fields.
|
||||||
|
This allows distinguishing between unset fields and those set to a zero-value.
|
||||||
|
Helper functions have been provided to easily create these pointers for string,
|
||||||
|
bool, and int values. For example:
|
||||||
|
|
||||||
|
// create a new private repository named "foo"
|
||||||
|
repo := &github.Repository{
|
||||||
|
Name: github.String("foo"),
|
||||||
|
Private: github.Bool(true),
|
||||||
|
}
|
||||||
|
client.Repositories.Create(ctx, "", repo)
|
||||||
|
|
||||||
|
Users who have worked with protocol buffers should find this pattern familiar.
|
||||||
|
|
||||||
|
# Pagination
|
||||||
|
|
||||||
|
All requests for resource collections (repos, pull requests, issues, etc.)
|
||||||
|
support pagination. Pagination options are described in the
|
||||||
|
github.ListOptions struct and passed to the list methods directly or as an
|
||||||
|
embedded type of a more specific list options struct (for example
|
||||||
|
github.PullRequestListOptions). Pages information is available via the
|
||||||
|
github.Response struct.
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
|
||||||
|
opt := &github.RepositoryListByOrgOptions{
|
||||||
|
ListOptions: github.ListOptions{PerPage: 10},
|
||||||
|
}
|
||||||
|
// get all pages of results
|
||||||
|
var allRepos []*github.Repository
|
||||||
|
for {
|
||||||
|
repos, resp, err := client.Repositories.ListByOrg(ctx, "github", opt)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
allRepos = append(allRepos, repos...)
|
||||||
|
if resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
opt.Page = resp.NextPage
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
package github
|
||||||
12
vendor/github.com/google/go-github/v48/github/enterprise.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v48/github/enterprise.go
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// EnterpriseService provides access to the enterprise related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/
|
||||||
|
type EnterpriseService service
|
||||||
88
vendor/github.com/google/go-github/v48/github/enterprise_actions_runners.go
generated
vendored
Normal file
88
vendor/github.com/google/go-github/v48/github/enterprise_actions_runners.go
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rads []*RunnerApplicationDownload
|
||||||
|
resp, err := s.client.Do(ctx, req, &rads)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rads, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRegistrationToken creates a token that can be used to add a self-hosted runner.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners/registration-token", enterprise)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
registrationToken := new(RegistrationToken)
|
||||||
|
resp, err := s.client.Do(ctx, req, registrationToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return registrationToken, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRunners lists all the self-hosted runners for a enterprise.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
runners := &Runners{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &runners)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runners, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRunner forces the removal of a self-hosted runner from an enterprise using the runner id.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-enterprise
|
||||||
|
func (s *EnterpriseService) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/actions/runners/%v", enterprise, runnerID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
35
vendor/github.com/google/go-github/v48/github/enterprise_audit_log.go
generated
vendored
Normal file
35
vendor/github.com/google/go-github/v48/github/enterprise_audit_log.go
generated
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetAuditLog gets the audit-log entries for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise
|
||||||
|
func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) {
|
||||||
|
u := fmt.Sprintf("enterprises/%v/audit-log", enterprise)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var auditEntries []*AuditEntry
|
||||||
|
resp, err := s.client.Do(ctx, req, &auditEntries)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return auditEntries, resp, nil
|
||||||
|
}
|
||||||
162
vendor/github.com/google/go-github/v48/github/event.go
generated
vendored
Normal file
162
vendor/github.com/google/go-github/v48/github/event.go
generated
vendored
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Event represents a GitHub event.
|
||||||
|
type Event struct {
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Public *bool `json:"public,omitempty"`
|
||||||
|
RawPayload *json.RawMessage `json:"payload,omitempty"`
|
||||||
|
Repo *Repository `json:"repo,omitempty"`
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
Org *Organization `json:"org,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Event) String() string {
|
||||||
|
return Stringify(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParsePayload parses the event payload. For recognized event types,
|
||||||
|
// a value of the corresponding struct type will be returned.
|
||||||
|
func (e *Event) ParsePayload() (payload interface{}, err error) {
|
||||||
|
switch *e.Type {
|
||||||
|
case "BranchProtectionRuleEvent":
|
||||||
|
payload = &BranchProtectionRuleEvent{}
|
||||||
|
case "CheckRunEvent":
|
||||||
|
payload = &CheckRunEvent{}
|
||||||
|
case "CheckSuiteEvent":
|
||||||
|
payload = &CheckSuiteEvent{}
|
||||||
|
case "CodeScanningAlertEvent":
|
||||||
|
payload = &CodeScanningAlertEvent{}
|
||||||
|
case "CommitCommentEvent":
|
||||||
|
payload = &CommitCommentEvent{}
|
||||||
|
case "ContentReferenceEvent":
|
||||||
|
payload = &ContentReferenceEvent{}
|
||||||
|
case "CreateEvent":
|
||||||
|
payload = &CreateEvent{}
|
||||||
|
case "DeleteEvent":
|
||||||
|
payload = &DeleteEvent{}
|
||||||
|
case "DeployKeyEvent":
|
||||||
|
payload = &DeployKeyEvent{}
|
||||||
|
case "DeploymentEvent":
|
||||||
|
payload = &DeploymentEvent{}
|
||||||
|
case "DeploymentStatusEvent":
|
||||||
|
payload = &DeploymentStatusEvent{}
|
||||||
|
case "DiscussionEvent":
|
||||||
|
payload = &DiscussionEvent{}
|
||||||
|
case "ForkEvent":
|
||||||
|
payload = &ForkEvent{}
|
||||||
|
case "GitHubAppAuthorizationEvent":
|
||||||
|
payload = &GitHubAppAuthorizationEvent{}
|
||||||
|
case "GollumEvent":
|
||||||
|
payload = &GollumEvent{}
|
||||||
|
case "InstallationEvent":
|
||||||
|
payload = &InstallationEvent{}
|
||||||
|
case "InstallationRepositoriesEvent":
|
||||||
|
payload = &InstallationRepositoriesEvent{}
|
||||||
|
case "IssueCommentEvent":
|
||||||
|
payload = &IssueCommentEvent{}
|
||||||
|
case "IssuesEvent":
|
||||||
|
payload = &IssuesEvent{}
|
||||||
|
case "LabelEvent":
|
||||||
|
payload = &LabelEvent{}
|
||||||
|
case "MarketplacePurchaseEvent":
|
||||||
|
payload = &MarketplacePurchaseEvent{}
|
||||||
|
case "MemberEvent":
|
||||||
|
payload = &MemberEvent{}
|
||||||
|
case "MembershipEvent":
|
||||||
|
payload = &MembershipEvent{}
|
||||||
|
case "MergeGroupEvent":
|
||||||
|
payload = &MergeGroupEvent{}
|
||||||
|
case "MetaEvent":
|
||||||
|
payload = &MetaEvent{}
|
||||||
|
case "MilestoneEvent":
|
||||||
|
payload = &MilestoneEvent{}
|
||||||
|
case "OrganizationEvent":
|
||||||
|
payload = &OrganizationEvent{}
|
||||||
|
case "OrgBlockEvent":
|
||||||
|
payload = &OrgBlockEvent{}
|
||||||
|
case "PackageEvent":
|
||||||
|
payload = &PackageEvent{}
|
||||||
|
case "PageBuildEvent":
|
||||||
|
payload = &PageBuildEvent{}
|
||||||
|
case "PingEvent":
|
||||||
|
payload = &PingEvent{}
|
||||||
|
case "ProjectEvent":
|
||||||
|
payload = &ProjectEvent{}
|
||||||
|
case "ProjectCardEvent":
|
||||||
|
payload = &ProjectCardEvent{}
|
||||||
|
case "ProjectColumnEvent":
|
||||||
|
payload = &ProjectColumnEvent{}
|
||||||
|
case "PublicEvent":
|
||||||
|
payload = &PublicEvent{}
|
||||||
|
case "PullRequestEvent":
|
||||||
|
payload = &PullRequestEvent{}
|
||||||
|
case "PullRequestReviewEvent":
|
||||||
|
payload = &PullRequestReviewEvent{}
|
||||||
|
case "PullRequestReviewCommentEvent":
|
||||||
|
payload = &PullRequestReviewCommentEvent{}
|
||||||
|
case "PullRequestReviewThreadEvent":
|
||||||
|
payload = &PullRequestReviewThreadEvent{}
|
||||||
|
case "PullRequestTargetEvent":
|
||||||
|
payload = &PullRequestTargetEvent{}
|
||||||
|
case "PushEvent":
|
||||||
|
payload = &PushEvent{}
|
||||||
|
case "ReleaseEvent":
|
||||||
|
payload = &ReleaseEvent{}
|
||||||
|
case "RepositoryEvent":
|
||||||
|
payload = &RepositoryEvent{}
|
||||||
|
case "RepositoryDispatchEvent":
|
||||||
|
payload = &RepositoryDispatchEvent{}
|
||||||
|
case "RepositoryImportEvent":
|
||||||
|
payload = &RepositoryImportEvent{}
|
||||||
|
case "RepositoryVulnerabilityAlertEvent":
|
||||||
|
payload = &RepositoryVulnerabilityAlertEvent{}
|
||||||
|
case "SecretScanningAlertEvent":
|
||||||
|
payload = &SecretScanningAlertEvent{}
|
||||||
|
case "StarEvent":
|
||||||
|
payload = &StarEvent{}
|
||||||
|
case "StatusEvent":
|
||||||
|
payload = &StatusEvent{}
|
||||||
|
case "TeamEvent":
|
||||||
|
payload = &TeamEvent{}
|
||||||
|
case "TeamAddEvent":
|
||||||
|
payload = &TeamAddEvent{}
|
||||||
|
case "UserEvent":
|
||||||
|
payload = &UserEvent{}
|
||||||
|
case "WatchEvent":
|
||||||
|
payload = &WatchEvent{}
|
||||||
|
case "WorkflowDispatchEvent":
|
||||||
|
payload = &WorkflowDispatchEvent{}
|
||||||
|
case "WorkflowJobEvent":
|
||||||
|
payload = &WorkflowJobEvent{}
|
||||||
|
case "WorkflowRunEvent":
|
||||||
|
payload = &WorkflowRunEvent{}
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(*e.RawPayload, &payload)
|
||||||
|
return payload, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload returns the parsed event payload. For recognized event types,
|
||||||
|
// a value of the corresponding struct type will be returned.
|
||||||
|
//
|
||||||
|
// Deprecated: Use ParsePayload instead, which returns an error
|
||||||
|
// rather than panics if JSON unmarshaling raw payload fails.
|
||||||
|
func (e *Event) Payload() (payload interface{}) {
|
||||||
|
var err error
|
||||||
|
payload, err = e.ParsePayload()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return payload
|
||||||
|
}
|
||||||
1392
vendor/github.com/google/go-github/v48/github/event_types.go
generated
vendored
Normal file
1392
vendor/github.com/google/go-github/v48/github/event_types.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
368
vendor/github.com/google/go-github/v48/github/gists.go
generated
vendored
Normal file
368
vendor/github.com/google/go-github/v48/github/gists.go
generated
vendored
Normal file
|
|
@ -0,0 +1,368 @@
|
||||||
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GistsService handles communication with the Gist related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists
|
||||||
|
type GistsService service
|
||||||
|
|
||||||
|
// Gist represents a GitHub's gist.
|
||||||
|
type Gist struct {
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Public *bool `json:"public,omitempty"`
|
||||||
|
Owner *User `json:"owner,omitempty"`
|
||||||
|
Files map[GistFilename]GistFile `json:"files,omitempty"`
|
||||||
|
Comments *int `json:"comments,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
GitPullURL *string `json:"git_pull_url,omitempty"`
|
||||||
|
GitPushURL *string `json:"git_push_url,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Gist) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistFilename represents filename on a gist.
|
||||||
|
type GistFilename string
|
||||||
|
|
||||||
|
// GistFile represents a file on a gist.
|
||||||
|
type GistFile struct {
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Filename *string `json:"filename,omitempty"`
|
||||||
|
Language *string `json:"language,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
RawURL *string `json:"raw_url,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g GistFile) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistCommit represents a commit on a gist.
|
||||||
|
type GistCommit struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Version *string `json:"version,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
ChangeStatus *CommitStats `json:"change_status,omitempty"`
|
||||||
|
CommittedAt *Timestamp `json:"committed_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gc GistCommit) String() string {
|
||||||
|
return Stringify(gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistFork represents a fork of a gist.
|
||||||
|
type GistFork struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
ID *string `json:"id,omitempty"`
|
||||||
|
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gf GistFork) String() string {
|
||||||
|
return Stringify(gf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GistListOptions specifies the optional parameters to the
|
||||||
|
// GistsService.List, GistsService.ListAll, and GistsService.ListStarred methods.
|
||||||
|
type GistListOptions struct {
|
||||||
|
// Since filters Gists by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gists for a user. Passing the empty string will list
|
||||||
|
// all public gists if called anonymously. However, if the call
|
||||||
|
// is authenticated, it will returns all gists for the authenticated
|
||||||
|
// user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-a-user
|
||||||
|
func (s *GistsService) List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/gists", user)
|
||||||
|
} else {
|
||||||
|
u = "gists"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAll lists all public gists.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-public-gists
|
||||||
|
func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
u, err := addOptions("gists/public", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListStarred lists starred gists of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-starred-gists
|
||||||
|
func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) {
|
||||||
|
u, err := addOptions("gists/starred", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gists []*Gist
|
||||||
|
resp, err := s.client.Do(ctx, req, &gists)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gists, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist
|
||||||
|
func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
gist := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gist, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRevision gets a specific revision of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist-revision
|
||||||
|
func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/%v", id, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
gist := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gist, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a gist for authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#create-a-gist
|
||||||
|
func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) {
|
||||||
|
u := "gists"
|
||||||
|
req, err := s.client.NewRequest("POST", u, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#update-a-gist
|
||||||
|
func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, gist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCommits lists commits of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-commits
|
||||||
|
func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/commits", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gistCommits []*GistCommit
|
||||||
|
resp, err := s.client.Do(ctx, req, &gistCommits)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gistCommits, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#delete-a-gist
|
||||||
|
func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v", id)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Star a gist on behalf of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#star-a-gist
|
||||||
|
func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unstar a gist on a behalf of authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#unstar-a-gist
|
||||||
|
func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStarred checks if a gist is starred by authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#check-if-a-gist-is-starred
|
||||||
|
func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/star", id)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
starred, err := parseBoolResponse(err)
|
||||||
|
return starred, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fork a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#fork-a-gist
|
||||||
|
func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/forks", id)
|
||||||
|
req, err := s.client.NewRequest("POST", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
g := new(Gist)
|
||||||
|
resp, err := s.client.Do(ctx, req, g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForks lists forks of a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-forks
|
||||||
|
func (s *GistsService) ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/forks", id)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var gistForks []*GistFork
|
||||||
|
resp, err := s.client.Do(ctx, req, &gistForks)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gistForks, resp, nil
|
||||||
|
}
|
||||||
119
vendor/github.com/google/go-github/v48/github/gists_comments.go
generated
vendored
Normal file
119
vendor/github.com/google/go-github/v48/github/gists_comments.go
generated
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GistComment represents a Gist comment.
|
||||||
|
type GistComment struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g GistComment) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComments lists all comments for a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#list-gist-comments
|
||||||
|
func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var comments []*GistComment
|
||||||
|
resp, err := s.client.Do(ctx, req, &comments)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetComment retrieves a single comment from a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#get-a-gist-comment
|
||||||
|
func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(GistComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateComment creates a comment for a gist.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#create-a-gist-comment
|
||||||
|
func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/comments", gistID)
|
||||||
|
req, err := s.client.NewRequest("POST", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(GistComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditComment edits an existing gist comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#update-a-gist-comment
|
||||||
|
func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(GistComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteComment deletes a gist comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gists/comments#delete-a-gist-comment
|
||||||
|
func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
12
vendor/github.com/google/go-github/v48/github/git.go
generated
vendored
Normal file
12
vendor/github.com/google/go-github/v48/github/git.go
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// GitService handles communication with the git data related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/
|
||||||
|
type GitService service
|
||||||
82
vendor/github.com/google/go-github/v48/github/git_blobs.go
generated
vendored
Normal file
82
vendor/github.com/google/go-github/v48/github/git_blobs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Blob represents a blob object.
|
||||||
|
type Blob struct {
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
Encoding *string `json:"encoding,omitempty"`
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlob fetches a blob from a repo given a SHA.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob
|
||||||
|
func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
blob := new(Blob)
|
||||||
|
resp, err := s.client.Do(ctx, req, blob)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return blob, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBlobRaw fetches a blob's contents from a repo.
|
||||||
|
// Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob
|
||||||
|
func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", "application/vnd.github.v3.raw")
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
resp, err := s.client.Do(ctx, req, &buf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Bytes(), resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBlob creates a blob object.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/blobs#create-a-blob
|
||||||
|
func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, blob)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Blob)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
200
vendor/github.com/google/go-github/v48/github/git_commits.go
generated
vendored
Normal file
200
vendor/github.com/google/go-github/v48/github/git_commits.go
generated
vendored
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/openpgp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SignatureVerification represents GPG signature verification.
|
||||||
|
type SignatureVerification struct {
|
||||||
|
Verified *bool `json:"verified,omitempty"`
|
||||||
|
Reason *string `json:"reason,omitempty"`
|
||||||
|
Signature *string `json:"signature,omitempty"`
|
||||||
|
Payload *string `json:"payload,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit represents a GitHub commit.
|
||||||
|
type Commit struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Author *CommitAuthor `json:"author,omitempty"`
|
||||||
|
Committer *CommitAuthor `json:"committer,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Tree *Tree `json:"tree,omitempty"`
|
||||||
|
Parents []*Commit `json:"parents,omitempty"`
|
||||||
|
Stats *CommitStats `json:"stats,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Verification *SignatureVerification `json:"verification,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
|
||||||
|
// CommentCount is the number of GitHub comments on the commit. This
|
||||||
|
// is only populated for requests that fetch GitHub data like
|
||||||
|
// Pulls.ListCommits, Repositories.ListCommits, etc.
|
||||||
|
CommentCount *int `json:"comment_count,omitempty"`
|
||||||
|
|
||||||
|
// SigningKey denotes a key to sign the commit with. If not nil this key will
|
||||||
|
// be used to sign the commit. The private key must be present and already
|
||||||
|
// decrypted. Ignored if Verification.Signature is defined.
|
||||||
|
SigningKey *openpgp.Entity `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Commit) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommitAuthor represents the author or committer of a commit. The commit
|
||||||
|
// author may not correspond to a GitHub User.
|
||||||
|
type CommitAuthor struct {
|
||||||
|
Date *time.Time `json:"date,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
|
||||||
|
// The following fields are only populated by Webhook events.
|
||||||
|
Login *string `json:"username,omitempty"` // Renamed for go-github consistency.
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c CommitAuthor) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCommit fetches the Commit object for a given SHA.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/commits#get-a-commit
|
||||||
|
func (s *GitService) GetCommit(ctx context.Context, owner string, repo string, sha string) (*Commit, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/commits/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(Commit)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// createCommit represents the body of a CreateCommit request.
|
||||||
|
type createCommit struct {
|
||||||
|
Author *CommitAuthor `json:"author,omitempty"`
|
||||||
|
Committer *CommitAuthor `json:"committer,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Tree *string `json:"tree,omitempty"`
|
||||||
|
Parents []string `json:"parents,omitempty"`
|
||||||
|
Signature *string `json:"signature,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCommit creates a new commit in a repository.
|
||||||
|
// commit must not be nil.
|
||||||
|
//
|
||||||
|
// The commit.Committer is optional and will be filled with the commit.Author
|
||||||
|
// data if omitted. If the commit.Author is omitted, it will be filled in with
|
||||||
|
// the authenticated user’s information and the current date.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/commits#create-a-commit
|
||||||
|
func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit) (*Commit, *Response, error) {
|
||||||
|
if commit == nil {
|
||||||
|
return nil, nil, fmt.Errorf("commit must be provided")
|
||||||
|
}
|
||||||
|
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/commits", owner, repo)
|
||||||
|
|
||||||
|
parents := make([]string, len(commit.Parents))
|
||||||
|
for i, parent := range commit.Parents {
|
||||||
|
parents[i] = *parent.SHA
|
||||||
|
}
|
||||||
|
|
||||||
|
body := &createCommit{
|
||||||
|
Author: commit.Author,
|
||||||
|
Committer: commit.Committer,
|
||||||
|
Message: commit.Message,
|
||||||
|
Parents: parents,
|
||||||
|
}
|
||||||
|
if commit.Tree != nil {
|
||||||
|
body.Tree = commit.Tree.SHA
|
||||||
|
}
|
||||||
|
if commit.SigningKey != nil {
|
||||||
|
signature, err := createSignature(commit.SigningKey, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
body.Signature = &signature
|
||||||
|
}
|
||||||
|
if commit.Verification != nil {
|
||||||
|
body.Signature = commit.Verification.Signature
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c := new(Commit)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSignature(signingKey *openpgp.Entity, commit *createCommit) (string, error) {
|
||||||
|
if signingKey == nil || commit == nil {
|
||||||
|
return "", errors.New("createSignature: invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
message, err := createSignatureMessage(commit)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
writer := new(bytes.Buffer)
|
||||||
|
reader := bytes.NewReader([]byte(message))
|
||||||
|
if err := openpgp.ArmoredDetachSign(writer, signingKey, reader, nil); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return writer.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createSignatureMessage(commit *createCommit) (string, error) {
|
||||||
|
if commit == nil || commit.Message == nil || *commit.Message == "" || commit.Author == nil {
|
||||||
|
return "", errors.New("createSignatureMessage: invalid parameters")
|
||||||
|
}
|
||||||
|
|
||||||
|
var message []string
|
||||||
|
|
||||||
|
if commit.Tree != nil {
|
||||||
|
message = append(message, fmt.Sprintf("tree %s", *commit.Tree))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, parent := range commit.Parents {
|
||||||
|
message = append(message, fmt.Sprintf("parent %s", parent))
|
||||||
|
}
|
||||||
|
|
||||||
|
message = append(message, fmt.Sprintf("author %s <%s> %d %s", commit.Author.GetName(), commit.Author.GetEmail(), commit.Author.GetDate().Unix(), commit.Author.GetDate().Format("-0700")))
|
||||||
|
|
||||||
|
committer := commit.Committer
|
||||||
|
if committer == nil {
|
||||||
|
committer = commit.Author
|
||||||
|
}
|
||||||
|
|
||||||
|
// There needs to be a double newline after committer
|
||||||
|
message = append(message, fmt.Sprintf("committer %s <%s> %d %s\n", committer.GetName(), committer.GetEmail(), committer.GetDate().Unix(), committer.GetDate().Format("-0700")))
|
||||||
|
message = append(message, *commit.Message)
|
||||||
|
|
||||||
|
return strings.Join(message, "\n"), nil
|
||||||
|
}
|
||||||
175
vendor/github.com/google/go-github/v48/github/git_refs.go
generated
vendored
Normal file
175
vendor/github.com/google/go-github/v48/github/git_refs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference represents a GitHub reference.
|
||||||
|
type Reference struct {
|
||||||
|
Ref *string `json:"ref"`
|
||||||
|
URL *string `json:"url"`
|
||||||
|
Object *GitObject `json:"object"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Reference) String() string {
|
||||||
|
return Stringify(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GitObject represents a Git object.
|
||||||
|
type GitObject struct {
|
||||||
|
Type *string `json:"type"`
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
URL *string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o GitObject) String() string {
|
||||||
|
return Stringify(o)
|
||||||
|
}
|
||||||
|
|
||||||
|
// createRefRequest represents the payload for creating a reference.
|
||||||
|
type createRefRequest struct {
|
||||||
|
Ref *string `json:"ref"`
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateRefRequest represents the payload for updating a reference.
|
||||||
|
type updateRefRequest struct {
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
Force *bool `json:"force"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRef fetches a single reference in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/refs#get-a-reference
|
||||||
|
func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) {
|
||||||
|
ref = strings.TrimPrefix(ref, "refs/")
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref))
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := new(Reference)
|
||||||
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// refURLEscape escapes every path segment of the given ref. Those must
|
||||||
|
// not contain escaped "/" - as "%2F" - or github will not recognize it.
|
||||||
|
func refURLEscape(ref string) string {
|
||||||
|
parts := strings.Split(ref, "/")
|
||||||
|
for i, s := range parts {
|
||||||
|
parts[i] = url.PathEscape(s)
|
||||||
|
}
|
||||||
|
return strings.Join(parts, "/")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReferenceListOptions specifies optional parameters to the
|
||||||
|
// GitService.ListMatchingRefs method.
|
||||||
|
type ReferenceListOptions struct {
|
||||||
|
Ref string `url:"-"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListMatchingRefs lists references in a repository that match a supplied ref.
|
||||||
|
// Use an empty ref to list all references.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/refs#list-matching-references
|
||||||
|
func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) {
|
||||||
|
var ref string
|
||||||
|
if opts != nil {
|
||||||
|
ref = strings.TrimPrefix(opts.Ref, "refs/")
|
||||||
|
}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/matching-refs/%v", owner, repo, refURLEscape(ref))
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var rs []*Reference
|
||||||
|
resp, err := s.client.Do(ctx, req, &rs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return rs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateRef creates a new ref in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/refs#create-a-reference
|
||||||
|
func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, &createRefRequest{
|
||||||
|
// back-compat with previous behavior that didn't require 'refs/' prefix
|
||||||
|
Ref: String("refs/" + strings.TrimPrefix(*ref.Ref, "refs/")),
|
||||||
|
SHA: ref.Object.SHA,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := new(Reference)
|
||||||
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRef updates an existing ref in a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/refs#update-a-reference
|
||||||
|
func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) {
|
||||||
|
refPath := strings.TrimPrefix(*ref.Ref, "refs/")
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(refPath))
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, &updateRefRequest{
|
||||||
|
SHA: ref.Object.SHA,
|
||||||
|
Force: &force,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := new(Reference)
|
||||||
|
resp, err := s.client.Do(ctx, req, r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteRef deletes a ref from a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/refs#delete-a-reference
|
||||||
|
func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) {
|
||||||
|
ref = strings.TrimPrefix(ref, "refs/")
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref))
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
84
vendor/github.com/google/go-github/v48/github/git_tags.go
generated
vendored
Normal file
84
vendor/github.com/google/go-github/v48/github/git_tags.go
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tag represents a tag object.
|
||||||
|
type Tag struct {
|
||||||
|
Tag *string `json:"tag,omitempty"`
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
||||||
|
Object *GitObject `json:"object,omitempty"`
|
||||||
|
Verification *SignatureVerification `json:"verification,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// createTagRequest represents the body of a CreateTag request. This is mostly
|
||||||
|
// identical to Tag with the exception that the object SHA and Type are
|
||||||
|
// top-level fields, rather than being nested inside a JSON object.
|
||||||
|
type createTagRequest struct {
|
||||||
|
Tag *string `json:"tag,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
Object *string `json:"object,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Tagger *CommitAuthor `json:"tagger,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTag fetches a tag from a repo given a SHA.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/tags#get-a-tag
|
||||||
|
func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tag := new(Tag)
|
||||||
|
resp, err := s.client.Do(ctx, req, tag)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTag creates a tag object.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/tags#create-a-tag-object
|
||||||
|
func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo)
|
||||||
|
|
||||||
|
// convert Tag into a createTagRequest
|
||||||
|
tagRequest := &createTagRequest{
|
||||||
|
Tag: tag.Tag,
|
||||||
|
Message: tag.Message,
|
||||||
|
Tagger: tag.Tagger,
|
||||||
|
}
|
||||||
|
if tag.Object != nil {
|
||||||
|
tagRequest.Object = tag.Object.SHA
|
||||||
|
tagRequest.Type = tag.Object.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, tagRequest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Tag)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
162
vendor/github.com/google/go-github/v48/github/git_trees.go
generated
vendored
Normal file
162
vendor/github.com/google/go-github/v48/github/git_trees.go
generated
vendored
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tree represents a GitHub tree.
|
||||||
|
type Tree struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Entries []*TreeEntry `json:"tree,omitempty"`
|
||||||
|
|
||||||
|
// Truncated is true if the number of items in the tree
|
||||||
|
// exceeded GitHub's maximum limit and the Entries were truncated
|
||||||
|
// in the response. Only populated for requests that fetch
|
||||||
|
// trees like Git.GetTree.
|
||||||
|
Truncated *bool `json:"truncated,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Tree) String() string {
|
||||||
|
return Stringify(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TreeEntry represents the contents of a tree structure. TreeEntry can
|
||||||
|
// represent either a blob, a commit (in the case of a submodule), or another
|
||||||
|
// tree.
|
||||||
|
type TreeEntry struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t TreeEntry) String() string {
|
||||||
|
return Stringify(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// treeEntryWithFileDelete is used internally to delete a file whose
|
||||||
|
// Content and SHA fields are empty. It does this by removing the "omitempty"
|
||||||
|
// tag modifier on the SHA field which causes the GitHub API to receive
|
||||||
|
// {"sha":null} and thereby delete the file.
|
||||||
|
type treeEntryWithFileDelete struct {
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TreeEntry) MarshalJSON() ([]byte, error) {
|
||||||
|
if t.SHA == nil && t.Content == nil {
|
||||||
|
return json.Marshal(struct {
|
||||||
|
SHA *string `json:"sha"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
}{
|
||||||
|
nil,
|
||||||
|
t.Path,
|
||||||
|
t.Mode,
|
||||||
|
t.Type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return json.Marshal(struct {
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
}{
|
||||||
|
SHA: t.SHA,
|
||||||
|
Path: t.Path,
|
||||||
|
Mode: t.Mode,
|
||||||
|
Type: t.Type,
|
||||||
|
Size: t.Size,
|
||||||
|
Content: t.Content,
|
||||||
|
URL: t.URL,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTree fetches the Tree object for a given sha hash from a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/trees#get-a-tree
|
||||||
|
func (s *GitService) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha)
|
||||||
|
if recursive {
|
||||||
|
u += "?recursive=1"
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Tree)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// createTree represents the body of a CreateTree request.
|
||||||
|
type createTree struct {
|
||||||
|
BaseTree string `json:"base_tree,omitempty"`
|
||||||
|
Entries []interface{} `json:"tree"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTree creates a new tree in a repository. If both a tree and a nested
|
||||||
|
// path modifying that tree are specified, it will overwrite the contents of
|
||||||
|
// that tree with the new path contents and write a new tree out.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/git/trees#create-a-tree
|
||||||
|
func (s *GitService) CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo)
|
||||||
|
|
||||||
|
newEntries := make([]interface{}, 0, len(entries))
|
||||||
|
for _, entry := range entries {
|
||||||
|
if entry.Content == nil && entry.SHA == nil {
|
||||||
|
newEntries = append(newEntries, treeEntryWithFileDelete{
|
||||||
|
Path: entry.Path,
|
||||||
|
Mode: entry.Mode,
|
||||||
|
Type: entry.Type,
|
||||||
|
Size: entry.Size,
|
||||||
|
URL: entry.URL,
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newEntries = append(newEntries, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
body := &createTree{
|
||||||
|
BaseTree: baseTree,
|
||||||
|
Entries: newEntries,
|
||||||
|
}
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := new(Tree)
|
||||||
|
resp, err := s.client.Do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, resp, nil
|
||||||
|
}
|
||||||
21183
vendor/github.com/google/go-github/v48/github/github-accessors.go
generated
vendored
Normal file
21183
vendor/github.com/google/go-github/v48/github/github-accessors.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1434
vendor/github.com/google/go-github/v48/github/github.go
generated
vendored
Normal file
1434
vendor/github.com/google/go-github/v48/github/github.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
64
vendor/github.com/google/go-github/v48/github/gitignore.go
generated
vendored
Normal file
64
vendor/github.com/google/go-github/v48/github/gitignore.go
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GitignoresService provides access to the gitignore related functions in the
|
||||||
|
// GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gitignore/
|
||||||
|
type GitignoresService service
|
||||||
|
|
||||||
|
// Gitignore represents a .gitignore file as returned by the GitHub API.
|
||||||
|
type Gitignore struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Source *string `json:"source,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Gitignore) String() string {
|
||||||
|
return Stringify(g)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List all available Gitignore templates.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gitignore/#listing-available-templates
|
||||||
|
func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", "gitignore/templates", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var availableTemplates []string
|
||||||
|
resp, err := s.client.Do(ctx, req, &availableTemplates)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return availableTemplates, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a Gitignore by name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/gitignore#get-a-gitignore-template
|
||||||
|
func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) {
|
||||||
|
u := fmt.Sprintf("gitignore/templates/%v", name)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
gitignore := new(Gitignore)
|
||||||
|
resp, err := s.client.Do(ctx, req, gitignore)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitignore, resp, nil
|
||||||
|
}
|
||||||
28
vendor/github.com/google/go-github/v48/github/interactions.go
generated
vendored
Normal file
28
vendor/github.com/google/go-github/v48/github/interactions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
// InteractionsService handles communication with the repository and organization related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/
|
||||||
|
type InteractionsService service
|
||||||
|
|
||||||
|
// InteractionRestriction represents the interaction restrictions for repository and organization.
|
||||||
|
type InteractionRestriction struct {
|
||||||
|
// Specifies the group of GitHub users who can
|
||||||
|
// comment, open issues, or create pull requests for the given repository.
|
||||||
|
// Possible values are: "existing_users", "contributors_only" and "collaborators_only".
|
||||||
|
Limit *string `json:"limit,omitempty"`
|
||||||
|
|
||||||
|
// Origin specifies the type of the resource to interact with.
|
||||||
|
// Possible values are: "repository" and "organization".
|
||||||
|
Origin *string `json:"origin,omitempty"`
|
||||||
|
|
||||||
|
// ExpiresAt specifies the time after which the interaction restrictions expire.
|
||||||
|
// The default expiry time is 24 hours from the time restriction is created.
|
||||||
|
ExpiresAt *Timestamp `json:"expires_at,omitempty"`
|
||||||
|
}
|
||||||
80
vendor/github.com/google/go-github/v48/github/interactions_orgs.go
generated
vendored
Normal file
80
vendor/github.com/google/go-github/v48/github/interactions_orgs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright 2019 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRestrictionsForOrg fetches the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#get-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
organizationInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organizationInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRestrictionsForOrg adds or updates the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// limit specifies the group of GitHub users who can comment, open issues, or create pull requests
|
||||||
|
// in public repositories for the given organization.
|
||||||
|
// Possible values are: "existing_users", "contributors_only", "collaborators_only".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#set-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
|
||||||
|
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
organizationInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organizationInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRestrictionsFromOrg removes the interaction restrictions for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization
|
||||||
|
func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
80
vendor/github.com/google/go-github/v48/github/interactions_repos.go
generated
vendored
Normal file
80
vendor/github.com/google/go-github/v48/github/interactions_repos.go
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRestrictionsForRepo fetches the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#get-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
repositoryInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, repositoryInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositoryInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateRestrictionsForRepo adds or updates the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// limit specifies the group of GitHub users who can comment, open issues, or create pull requests
|
||||||
|
// for the given repository.
|
||||||
|
// Possible values are: "existing_users", "contributors_only", "collaborators_only".
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#set-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
|
||||||
|
interaction := &InteractionRestriction{Limit: String(limit)}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("PUT", u, interaction)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
repositoryInteractions := new(InteractionRestriction)
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, repositoryInteractions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositoryInteractions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveRestrictionsFromRepo removes the interaction restrictions for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#remove-interaction-restrictions-for-a-repository
|
||||||
|
func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
152
vendor/github.com/google/go-github/v48/github/issue_import.go
generated
vendored
Normal file
152
vendor/github.com/google/go-github/v48/github/issue_import.go
generated
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueImportService handles communication with the issue import related
|
||||||
|
// methods of the Issue Import GitHub API.
|
||||||
|
type IssueImportService service
|
||||||
|
|
||||||
|
// IssueImportRequest represents a request to create an issue.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#supported-issue-and-comment-fields
|
||||||
|
type IssueImportRequest struct {
|
||||||
|
IssueImport IssueImport `json:"issue"`
|
||||||
|
Comments []*Comment `json:"comments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImport represents body of issue to import.
|
||||||
|
type IssueImport struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
Assignee *string `json:"assignee,omitempty"`
|
||||||
|
Milestone *int `json:"milestone,omitempty"`
|
||||||
|
Closed *bool `json:"closed,omitempty"`
|
||||||
|
Labels []string `json:"labels,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comment represents comments of issue to import.
|
||||||
|
type Comment struct {
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImportResponse represents the response of an issue import create request.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#import-issue-response
|
||||||
|
type IssueImportResponse struct {
|
||||||
|
ID *int `json:"id,omitempty"`
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
ImportIssuesURL *string `json:"import_issues_url,omitempty"`
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
DocumentationURL *string `json:"documentation_url,omitempty"`
|
||||||
|
Errors []*IssueImportError `json:"errors,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueImportError represents errors of an issue import create request.
|
||||||
|
type IssueImportError struct {
|
||||||
|
Location *string `json:"location,omitempty"`
|
||||||
|
Resource *string `json:"resource,omitempty"`
|
||||||
|
Field *string `json:"field,omitempty"`
|
||||||
|
Value *string `json:"value,omitempty"`
|
||||||
|
Code *string `json:"code,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new imported issue on the specified repository.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#start-an-issue-import
|
||||||
|
func (s *IssueImportService) Create(ctx context.Context, owner, repo string, issue *IssueImportRequest) (*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
i := new(IssueImportResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
aerr, ok := err.(*AcceptedError)
|
||||||
|
if ok {
|
||||||
|
decErr := json.Unmarshal(aerr.Raw, i)
|
||||||
|
if decErr != nil {
|
||||||
|
err = decErr
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckStatus checks the status of an imported issue.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#import-status-request
|
||||||
|
func (s *IssueImportService) CheckStatus(ctx context.Context, owner, repo string, issueID int64) (*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues/%v", owner, repo, issueID)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
i := new(IssueImportResponse)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckStatusSince checks the status of multiple imported issues since a given date.
|
||||||
|
//
|
||||||
|
// https://gist.github.com/jonmagic/5282384165e0f86ef105#check-status-of-multiple-issues
|
||||||
|
func (s *IssueImportService) CheckStatusSince(ctx context.Context, owner, repo string, since time.Time) ([]*IssueImportResponse, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/issues?since=%v", owner, repo, since.Format("2006-01-02"))
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept headers when APIs fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeIssueImportAPI)
|
||||||
|
|
||||||
|
var b bytes.Buffer
|
||||||
|
resp, err := s.client.Do(ctx, req, &b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var i []*IssueImportResponse
|
||||||
|
err = json.Unmarshal(b.Bytes(), &i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
362
vendor/github.com/google/go-github/v48/github/issues.go
generated
vendored
Normal file
362
vendor/github.com/google/go-github/v48/github/issues.go
generated
vendored
Normal file
|
|
@ -0,0 +1,362 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssuesService handles communication with the issue related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/
|
||||||
|
type IssuesService service
|
||||||
|
|
||||||
|
// Issue represents a GitHub issue on a repository.
|
||||||
|
//
|
||||||
|
// Note: As far as the GitHub API is concerned, every pull request is an issue,
|
||||||
|
// but not every issue is a pull request. Some endpoints, events, and webhooks
|
||||||
|
// may also return pull requests via this struct. If PullRequestLinks is nil,
|
||||||
|
// this is an issue, and if PullRequestLinks is not nil, this is a pull request.
|
||||||
|
// The IsPullRequest helper method can be used to check that.
|
||||||
|
type Issue struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
// StateReason can be one of: "completed", "not_planned", "reopened".
|
||||||
|
StateReason *string `json:"state_reason,omitempty"`
|
||||||
|
Locked *bool `json:"locked,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
AuthorAssociation *string `json:"author_association,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
Labels []*Label `json:"labels,omitempty"`
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
Comments *int `json:"comments,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
ClosedBy *User `json:"closed_by,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
CommentsURL *string `json:"comments_url,omitempty"`
|
||||||
|
EventsURL *string `json:"events_url,omitempty"`
|
||||||
|
LabelsURL *string `json:"labels_url,omitempty"`
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
PullRequestLinks *PullRequestLinks `json:"pull_request,omitempty"`
|
||||||
|
Repository *Repository `json:"repository,omitempty"`
|
||||||
|
Reactions *Reactions `json:"reactions,omitempty"`
|
||||||
|
Assignees []*User `json:"assignees,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
|
||||||
|
// TextMatches is only populated from search results that request text matches
|
||||||
|
// See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata
|
||||||
|
TextMatches []*TextMatch `json:"text_matches,omitempty"`
|
||||||
|
|
||||||
|
// ActiveLockReason is populated only when LockReason is provided while locking the issue.
|
||||||
|
// Possible values are: "off-topic", "too heated", "resolved", and "spam".
|
||||||
|
ActiveLockReason *string `json:"active_lock_reason,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Issue) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsPullRequest reports whether the issue is also a pull request. It uses the
|
||||||
|
// method recommended by GitHub's API documentation, which is to check whether
|
||||||
|
// PullRequestLinks is non-nil.
|
||||||
|
func (i Issue) IsPullRequest() bool {
|
||||||
|
return i.PullRequestLinks != nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueRequest represents a request to create/edit an issue.
|
||||||
|
// It is separate from Issue above because otherwise Labels
|
||||||
|
// and Assignee fail to serialize to the correct JSON.
|
||||||
|
type IssueRequest struct {
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
Labels *[]string `json:"labels,omitempty"`
|
||||||
|
Assignee *string `json:"assignee,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
// StateReason can be 'completed' or 'not_planned'.
|
||||||
|
StateReason *string `json:"state_reason,omitempty"`
|
||||||
|
Milestone *int `json:"milestone,omitempty"`
|
||||||
|
Assignees *[]string `json:"assignees,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListOptions specifies the optional parameters to the IssuesService.List
|
||||||
|
// and IssuesService.ListByOrg methods.
|
||||||
|
type IssueListOptions struct {
|
||||||
|
// Filter specifies which issues to list. Possible values are: assigned,
|
||||||
|
// created, mentioned, subscribed, all. Default is "assigned".
|
||||||
|
Filter string `url:"filter,omitempty"`
|
||||||
|
|
||||||
|
// State filters issues based on their state. Possible values are: open,
|
||||||
|
// closed, all. Default is "open".
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Labels filters issues based on their label.
|
||||||
|
Labels []string `url:"labels,comma,omitempty"`
|
||||||
|
|
||||||
|
// Sort specifies how to sort issues. Possible values are: created, updated,
|
||||||
|
// and comments. Default value is "created".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort issues. Possible values are: asc, desc.
|
||||||
|
// Default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters issues by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// PullRequestLinks object is added to the Issue object when it's an issue included
|
||||||
|
// in the IssueCommentEvent webhook payload, if the webhook is fired by a comment on a PR.
|
||||||
|
type PullRequestLinks struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
DiffURL *string `json:"diff_url,omitempty"`
|
||||||
|
PatchURL *string `json:"patch_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the issues for the authenticated user. If all is true, list issues
|
||||||
|
// across all the user's visible repositories including owned, member, and
|
||||||
|
// organization repositories; if false, list only owned and member
|
||||||
|
// repositories.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-issues-assigned-to-the-authenticated-user
|
||||||
|
func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if all {
|
||||||
|
u = "issues"
|
||||||
|
} else {
|
||||||
|
u = "user/issues"
|
||||||
|
}
|
||||||
|
return s.listIssues(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByOrg fetches the issues in the specified organization for the
|
||||||
|
// authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user
|
||||||
|
func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/issues", org)
|
||||||
|
return s.listIssues(ctx, u, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *IssuesService) listIssues(ctx context.Context, u string, opts *IssueListOptions) ([]*Issue, *Response, error) {
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var issues []*Issue
|
||||||
|
resp, err := s.client.Do(ctx, req, &issues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issues, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListByRepoOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.ListByRepo method.
|
||||||
|
type IssueListByRepoOptions struct {
|
||||||
|
// Milestone limits issues for the specified milestone. Possible values are
|
||||||
|
// a milestone number, "none" for issues with no milestone, "*" for issues
|
||||||
|
// with any milestone.
|
||||||
|
Milestone string `url:"milestone,omitempty"`
|
||||||
|
|
||||||
|
// State filters issues based on their state. Possible values are: open,
|
||||||
|
// closed, all. Default is "open".
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Assignee filters issues based on their assignee. Possible values are a
|
||||||
|
// user name, "none" for issues that are not assigned, "*" for issues with
|
||||||
|
// any assigned user.
|
||||||
|
Assignee string `url:"assignee,omitempty"`
|
||||||
|
|
||||||
|
// Creator filters issues based on their creator.
|
||||||
|
Creator string `url:"creator,omitempty"`
|
||||||
|
|
||||||
|
// Mentioned filters issues to those mentioned a specific user.
|
||||||
|
Mentioned string `url:"mentioned,omitempty"`
|
||||||
|
|
||||||
|
// Labels filters issues based on their label.
|
||||||
|
Labels []string `url:"labels,omitempty,comma"`
|
||||||
|
|
||||||
|
// Sort specifies how to sort issues. Possible values are: created, updated,
|
||||||
|
// and comments. Default value is "created".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort issues. Possible values are: asc, desc.
|
||||||
|
// Default is "desc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters issues by time.
|
||||||
|
Since time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByRepo lists the issues for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-repository-issues
|
||||||
|
func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var issues []*Issue
|
||||||
|
resp, err := s.client.Do(ctx, req, &issues)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issues, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a single issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#get-an-issue
|
||||||
|
func (s *IssuesService) Get(ctx context.Context, owner string, repo string, number int) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launch.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
issue := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issue, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new issue on the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#create-an-issue
|
||||||
|
func (s *IssuesService) Create(ctx context.Context, owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit (update) an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue
|
||||||
|
func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a milestone from an issue.
|
||||||
|
//
|
||||||
|
// This is a helper method to explicitly update an issue with a `null` milestone, thereby removing it.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue
|
||||||
|
func (s *IssuesService) RemoveMilestone(ctx context.Context, owner, repo string, issueNumber int) (*Issue, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, issueNumber)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, &struct {
|
||||||
|
Milestone *Milestone `json:"milestone"`
|
||||||
|
}{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
i := new(Issue)
|
||||||
|
resp, err := s.client.Do(ctx, req, i)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return i, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LockIssueOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.Lock method.
|
||||||
|
type LockIssueOptions struct {
|
||||||
|
// LockReason specifies the reason to lock this issue.
|
||||||
|
// Providing a lock reason can help make it clearer to contributors why an issue
|
||||||
|
// was locked. Possible values are: "off-topic", "too heated", "resolved", and "spam".
|
||||||
|
LockReason string `json:"lock_reason,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock an issue's conversation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#lock-an-issue
|
||||||
|
func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int, opts *LockIssueOptions) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock an issue's conversation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/issues#unlock-an-issue
|
||||||
|
func (s *IssuesService) Unlock(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
95
vendor/github.com/google/go-github/v48/github/issues_assignees.go
generated
vendored
Normal file
95
vendor/github.com/google/go-github/v48/github/issues_assignees.go
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListAssignees fetches all available assignees (owners and collaborators) to
|
||||||
|
// which issues may be assigned.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#list-assignees
|
||||||
|
func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var assignees []*User
|
||||||
|
resp, err := s.client.Do(ctx, req, &assignees)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return assignees, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAssignee checks if a user is an assignee for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#check-if-a-user-can-be-assigned
|
||||||
|
func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(ctx, req, nil)
|
||||||
|
assignee, err := parseBoolResponse(err)
|
||||||
|
return assignee, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddAssignees adds the provided GitHub users as assignees to the issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#add-assignees-to-an-issue
|
||||||
|
func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
|
||||||
|
users := &struct {
|
||||||
|
Assignees []string `json:"assignees,omitempty"`
|
||||||
|
}{Assignees: assignees}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, users)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
issue := &Issue{}
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issue, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveAssignees removes the provided GitHub users as assignees from the issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#remove-assignees-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) {
|
||||||
|
users := &struct {
|
||||||
|
Assignees []string `json:"assignees,omitempty"`
|
||||||
|
}{Assignees: assignees}
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, users)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
issue := &Issue{}
|
||||||
|
resp, err := s.client.Do(ctx, req, issue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return issue, resp, nil
|
||||||
|
}
|
||||||
154
vendor/github.com/google/go-github/v48/github/issues_comments.go
generated
vendored
Normal file
154
vendor/github.com/google/go-github/v48/github/issues_comments.go
generated
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueComment represents a comment left on an issue.
|
||||||
|
type IssueComment struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
Reactions *Reactions `json:"reactions,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
// AuthorAssociation is the comment author's relationship to the issue's repository.
|
||||||
|
// Possible values are "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".
|
||||||
|
AuthorAssociation *string `json:"author_association,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
IssueURL *string `json:"issue_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i IssueComment) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssueListCommentsOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.ListComments method.
|
||||||
|
type IssueListCommentsOptions struct {
|
||||||
|
// Sort specifies how to sort comments. Possible values are: created, updated.
|
||||||
|
Sort *string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort comments. Possible values are: asc, desc.
|
||||||
|
Direction *string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
// Since filters comments by time.
|
||||||
|
Since *time.Time `url:"since,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComments lists all comments on the specified issue. Specifying an issue
|
||||||
|
// number of 0 will return all comments on all issues for the repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments-for-a-repository
|
||||||
|
func (s *IssuesService) ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if number == 0 {
|
||||||
|
u = fmt.Sprintf("repos/%v/%v/issues/comments", owner, repo)
|
||||||
|
} else {
|
||||||
|
u = fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
var comments []*IssueComment
|
||||||
|
resp, err := s.client.Do(ctx, req, &comments)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetComment fetches the specified issue comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#get-an-issue-comment
|
||||||
|
func (s *IssuesService) GetComment(ctx context.Context, owner string, repo string, commentID int64) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeReactionsPreview)
|
||||||
|
|
||||||
|
comment := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return comment, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateComment creates a new comment on the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#create-an-issue-comment
|
||||||
|
func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
c := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditComment updates an issue comment.
|
||||||
|
// A non-nil comment.Body must be provided. Other comment fields should be left nil.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#update-an-issue-comment
|
||||||
|
func (s *IssuesService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, comment)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
c := new(IssueComment)
|
||||||
|
resp, err := s.client.Do(ctx, req, c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteComment deletes an issue comment.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/comments#delete-an-issue-comment
|
||||||
|
func (s *IssuesService) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
179
vendor/github.com/google/go-github/v48/github/issues_events.go
generated
vendored
Normal file
179
vendor/github.com/google/go-github/v48/github/issues_events.go
generated
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IssueEvent represents an event that occurred around an Issue or Pull Request.
|
||||||
|
type IssueEvent struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
|
||||||
|
// The User that generated this event.
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
|
||||||
|
// Event identifies the actual type of Event that occurred. Possible
|
||||||
|
// values are:
|
||||||
|
//
|
||||||
|
// closed
|
||||||
|
// The Actor closed the issue.
|
||||||
|
// If the issue was closed by commit message, CommitID holds the SHA1 hash of the commit.
|
||||||
|
//
|
||||||
|
// merged
|
||||||
|
// The Actor merged into master a branch containing a commit mentioning the issue.
|
||||||
|
// CommitID holds the SHA1 of the merge commit.
|
||||||
|
//
|
||||||
|
// referenced
|
||||||
|
// The Actor committed to master a commit mentioning the issue in its commit message.
|
||||||
|
// CommitID holds the SHA1 of the commit.
|
||||||
|
//
|
||||||
|
// reopened, unlocked
|
||||||
|
// The Actor did that to the issue.
|
||||||
|
//
|
||||||
|
// locked
|
||||||
|
// The Actor locked the issue.
|
||||||
|
// LockReason holds the reason of locking the issue (if provided while locking).
|
||||||
|
//
|
||||||
|
// renamed
|
||||||
|
// The Actor changed the issue title from Rename.From to Rename.To.
|
||||||
|
//
|
||||||
|
// mentioned
|
||||||
|
// Someone unspecified @mentioned the Actor [sic] in an issue comment body.
|
||||||
|
//
|
||||||
|
// assigned, unassigned
|
||||||
|
// The Assigner assigned the issue to or removed the assignment from the Assignee.
|
||||||
|
//
|
||||||
|
// labeled, unlabeled
|
||||||
|
// The Actor added or removed the Label from the issue.
|
||||||
|
//
|
||||||
|
// milestoned, demilestoned
|
||||||
|
// The Actor added or removed the issue from the Milestone.
|
||||||
|
//
|
||||||
|
// subscribed, unsubscribed
|
||||||
|
// The Actor subscribed to or unsubscribed from notifications for an issue.
|
||||||
|
//
|
||||||
|
// head_ref_deleted, head_ref_restored
|
||||||
|
// The pull request’s branch was deleted or restored.
|
||||||
|
//
|
||||||
|
// review_dismissed
|
||||||
|
// The review was dismissed and `DismissedReview` will be populated below.
|
||||||
|
//
|
||||||
|
// review_requested, review_request_removed
|
||||||
|
// The Actor requested or removed the request for a review.
|
||||||
|
// RequestedReviewer and ReviewRequester will be populated below.
|
||||||
|
//
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
Issue *Issue `json:"issue,omitempty"`
|
||||||
|
|
||||||
|
// Only present on certain events; see above.
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
Assigner *User `json:"assigner,omitempty"`
|
||||||
|
CommitID *string `json:"commit_id,omitempty"`
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
Label *Label `json:"label,omitempty"`
|
||||||
|
Rename *Rename `json:"rename,omitempty"`
|
||||||
|
LockReason *string `json:"lock_reason,omitempty"`
|
||||||
|
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||||
|
DismissedReview *DismissedReview `json:"dismissed_review,omitempty"`
|
||||||
|
RequestedReviewer *User `json:"requested_reviewer,omitempty"`
|
||||||
|
ReviewRequester *User `json:"review_requester,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DismissedReview represents details for 'dismissed_review' events.
|
||||||
|
type DismissedReview struct {
|
||||||
|
// State represents the state of the dismissed review.
|
||||||
|
// Possible values are: "commented", "approved", and "changes_requested".
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
ReviewID *int64 `json:"review_id,omitempty"`
|
||||||
|
DismissalMessage *string `json:"dismissal_message,omitempty"`
|
||||||
|
DismissalCommitID *string `json:"dismissal_commit_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueEvents lists events for the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events
|
||||||
|
func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Accept", mediaTypeProjectCardDetailsPreview)
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRepositoryEvents lists events for the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository
|
||||||
|
func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var events []*IssueEvent
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetEvent returns the specified issue event.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/events#get-an-issue-event
|
||||||
|
func (s *IssuesService) GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
event := new(IssueEvent)
|
||||||
|
resp, err := s.client.Do(ctx, req, event)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return event, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename contains details for 'renamed' events.
|
||||||
|
type Rename struct {
|
||||||
|
From *string `json:"from,omitempty"`
|
||||||
|
To *string `json:"to,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r Rename) String() string {
|
||||||
|
return Stringify(r)
|
||||||
|
}
|
||||||
231
vendor/github.com/google/go-github/v48/github/issues_labels.go
generated
vendored
Normal file
231
vendor/github.com/google/go-github/v48/github/issues_labels.go
generated
vendored
Normal file
|
|
@ -0,0 +1,231 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Label represents a GitHub label on an Issue
|
||||||
|
type Label struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Color *string `json:"color,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Default *bool `json:"default,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l Label) String() string {
|
||||||
|
return Stringify(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabels lists all labels for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-a-repository
|
||||||
|
func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLabel gets a single label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#get-a-label
|
||||||
|
func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, name string) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
label := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return label, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLabel creates a new label on the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#create-a-label
|
||||||
|
func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo string, label *Label) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
l := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditLabel edits a label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#update-a-label
|
||||||
|
func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string, name string, label *Label) (*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, label)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
l := new(Label)
|
||||||
|
resp, err := s.client.Do(ctx, req, l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteLabel deletes a label.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#delete-a-label
|
||||||
|
func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo string, name string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabelsByIssue lists all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-an-issue
|
||||||
|
func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLabelsToIssue adds labels to an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#add-labels-to-an-issue
|
||||||
|
func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("POST", u, labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var l []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLabelForIssue removes a label for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-a-label-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplaceLabelsForIssue replaces all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#set-labels-for-an-issue
|
||||||
|
func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var l []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &l)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLabelsForIssue removes all labels for an issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-all-labels-from-an-issue
|
||||||
|
func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListLabelsForMilestone lists labels for every issue in a milestone.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-issues-in-a-milestone
|
||||||
|
func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var labels []*Label
|
||||||
|
resp, err := s.client.Do(ctx, req, &labels)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels, resp, nil
|
||||||
|
}
|
||||||
148
vendor/github.com/google/go-github/v48/github/issues_milestones.go
generated
vendored
Normal file
148
vendor/github.com/google/go-github/v48/github/issues_milestones.go
generated
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Milestone represents a GitHub repository milestone.
|
||||||
|
type Milestone struct {
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
LabelsURL *string `json:"labels_url,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
Number *int `json:"number,omitempty"`
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
Title *string `json:"title,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Creator *User `json:"creator,omitempty"`
|
||||||
|
OpenIssues *int `json:"open_issues,omitempty"`
|
||||||
|
ClosedIssues *int `json:"closed_issues,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
||||||
|
DueOn *time.Time `json:"due_on,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Milestone) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MilestoneListOptions specifies the optional parameters to the
|
||||||
|
// IssuesService.ListMilestones method.
|
||||||
|
type MilestoneListOptions struct {
|
||||||
|
// State filters milestones based on their state. Possible values are:
|
||||||
|
// open, closed, all. Default is "open".
|
||||||
|
State string `url:"state,omitempty"`
|
||||||
|
|
||||||
|
// Sort specifies how to sort milestones. Possible values are: due_on, completeness.
|
||||||
|
// Default value is "due_on".
|
||||||
|
Sort string `url:"sort,omitempty"`
|
||||||
|
|
||||||
|
// Direction in which to sort milestones. Possible values are: asc, desc.
|
||||||
|
// Default is "asc".
|
||||||
|
Direction string `url:"direction,omitempty"`
|
||||||
|
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListMilestones lists all milestones for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#list-milestones
|
||||||
|
func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var milestones []*Milestone
|
||||||
|
resp, err := s.client.Do(ctx, req, &milestones)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return milestones, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMilestone gets a single milestone.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#get-a-milestone
|
||||||
|
func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
milestone := new(Milestone)
|
||||||
|
resp, err := s.client.Do(ctx, req, milestone)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return milestone, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMilestone creates a new milestone on the specified repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#create-a-milestone
|
||||||
|
func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("POST", u, milestone)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(Milestone)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditMilestone edits a milestone.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#update-a-milestone
|
||||||
|
func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, milestone)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := new(Milestone)
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteMilestone deletes a milestone.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#delete-a-milestone
|
||||||
|
func (s *IssuesService) DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
190
vendor/github.com/google/go-github/v48/github/issues_timeline.go
generated
vendored
Normal file
190
vendor/github.com/google/go-github/v48/github/issues_timeline.go
generated
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Timeline represents an event that occurred around an Issue or Pull Request.
|
||||||
|
//
|
||||||
|
// It is similar to an IssueEvent but may contain more information.
|
||||||
|
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/issue-event-types
|
||||||
|
type Timeline struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
CommitURL *string `json:"commit_url,omitempty"`
|
||||||
|
|
||||||
|
// The User object that generated the event.
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
|
||||||
|
// The person who commented on the issue.
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
|
||||||
|
// The person who authored the commit.
|
||||||
|
Author *CommitAuthor `json:"author,omitempty"`
|
||||||
|
// The person who committed the commit on behalf of the author.
|
||||||
|
Committer *CommitAuthor `json:"committer,omitempty"`
|
||||||
|
// The SHA of the commit in the pull request.
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
// The commit message.
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
// A list of parent commits.
|
||||||
|
Parents []*Commit `json:"parents,omitempty"`
|
||||||
|
|
||||||
|
// Event identifies the actual type of Event that occurred. Possible values
|
||||||
|
// are:
|
||||||
|
//
|
||||||
|
// assigned
|
||||||
|
// The issue was assigned to the assignee.
|
||||||
|
//
|
||||||
|
// closed
|
||||||
|
// The issue was closed by the actor. When the commit_id is present, it
|
||||||
|
// identifies the commit that closed the issue using "closes / fixes #NN"
|
||||||
|
// syntax.
|
||||||
|
//
|
||||||
|
// commented
|
||||||
|
// A comment was added to the issue.
|
||||||
|
//
|
||||||
|
// committed
|
||||||
|
// A commit was added to the pull request's 'HEAD' branch. Only provided
|
||||||
|
// for pull requests.
|
||||||
|
//
|
||||||
|
// cross-referenced
|
||||||
|
// The issue was referenced from another issue. The 'source' attribute
|
||||||
|
// contains the 'id', 'actor', and 'url' of the reference's source.
|
||||||
|
//
|
||||||
|
// demilestoned
|
||||||
|
// The issue was removed from a milestone.
|
||||||
|
//
|
||||||
|
// head_ref_deleted
|
||||||
|
// The pull request's branch was deleted.
|
||||||
|
//
|
||||||
|
// head_ref_restored
|
||||||
|
// The pull request's branch was restored.
|
||||||
|
//
|
||||||
|
// labeled
|
||||||
|
// A label was added to the issue.
|
||||||
|
//
|
||||||
|
// locked
|
||||||
|
// The issue was locked by the actor.
|
||||||
|
//
|
||||||
|
// mentioned
|
||||||
|
// The actor was @mentioned in an issue body.
|
||||||
|
//
|
||||||
|
// merged
|
||||||
|
// The issue was merged by the actor. The 'commit_id' attribute is the
|
||||||
|
// SHA1 of the HEAD commit that was merged.
|
||||||
|
//
|
||||||
|
// milestoned
|
||||||
|
// The issue was added to a milestone.
|
||||||
|
//
|
||||||
|
// referenced
|
||||||
|
// The issue was referenced from a commit message. The 'commit_id'
|
||||||
|
// attribute is the commit SHA1 of where that happened.
|
||||||
|
//
|
||||||
|
// renamed
|
||||||
|
// The issue title was changed.
|
||||||
|
//
|
||||||
|
// reopened
|
||||||
|
// The issue was reopened by the actor.
|
||||||
|
//
|
||||||
|
// reviewed
|
||||||
|
// The pull request was reviewed.
|
||||||
|
//
|
||||||
|
// subscribed
|
||||||
|
// The actor subscribed to receive notifications for an issue.
|
||||||
|
//
|
||||||
|
// unassigned
|
||||||
|
// The assignee was unassigned from the issue.
|
||||||
|
//
|
||||||
|
// unlabeled
|
||||||
|
// A label was removed from the issue.
|
||||||
|
//
|
||||||
|
// unlocked
|
||||||
|
// The issue was unlocked by the actor.
|
||||||
|
//
|
||||||
|
// unsubscribed
|
||||||
|
// The actor unsubscribed to stop receiving notifications for an issue.
|
||||||
|
//
|
||||||
|
Event *string `json:"event,omitempty"`
|
||||||
|
|
||||||
|
// The string SHA of a commit that referenced this Issue or Pull Request.
|
||||||
|
CommitID *string `json:"commit_id,omitempty"`
|
||||||
|
// The timestamp indicating when the event occurred.
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
// The Label object including `name` and `color` attributes. Only provided for
|
||||||
|
// 'labeled' and 'unlabeled' events.
|
||||||
|
Label *Label `json:"label,omitempty"`
|
||||||
|
// The User object which was assigned to (or unassigned from) this Issue or
|
||||||
|
// Pull Request. Only provided for 'assigned' and 'unassigned' events.
|
||||||
|
Assignee *User `json:"assignee,omitempty"`
|
||||||
|
Assigner *User `json:"assigner,omitempty"`
|
||||||
|
|
||||||
|
// The Milestone object including a 'title' attribute.
|
||||||
|
// Only provided for 'milestoned' and 'demilestoned' events.
|
||||||
|
Milestone *Milestone `json:"milestone,omitempty"`
|
||||||
|
// The 'id', 'actor', and 'url' for the source of a reference from another issue.
|
||||||
|
// Only provided for 'cross-referenced' events.
|
||||||
|
Source *Source `json:"source,omitempty"`
|
||||||
|
// An object containing rename details including 'from' and 'to' attributes.
|
||||||
|
// Only provided for 'renamed' events.
|
||||||
|
Rename *Rename `json:"rename,omitempty"`
|
||||||
|
ProjectCard *ProjectCard `json:"project_card,omitempty"`
|
||||||
|
// The state of a submitted review. Can be one of: 'commented',
|
||||||
|
// 'changes_requested' or 'approved'.
|
||||||
|
// Only provided for 'reviewed' events.
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
|
||||||
|
// The person requested to review the pull request.
|
||||||
|
Reviewer *User `json:"requested_reviewer,omitempty"`
|
||||||
|
// The person who requested a review.
|
||||||
|
Requester *User `json:"review_requester,omitempty"`
|
||||||
|
|
||||||
|
// The review summary text.
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
SubmittedAt *time.Time `json:"submitted_at,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source represents a reference's source.
|
||||||
|
type Source struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Actor *User `json:"actor,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Issue *Issue `json:"issue,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListIssueTimeline lists events for the specified issue.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/issues/timeline#list-timeline-events-for-an-issue
|
||||||
|
func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
acceptHeaders := []string{mediaTypeTimelinePreview, mediaTypeProjectCardDetailsPreview}
|
||||||
|
req.Header.Set("Accept", strings.Join(acceptHeaders, ", "))
|
||||||
|
|
||||||
|
var events []*Timeline
|
||||||
|
resp, err := s.client.Do(ctx, req, &events)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return events, resp, nil
|
||||||
|
}
|
||||||
97
vendor/github.com/google/go-github/v48/github/licenses.go
generated
vendored
Normal file
97
vendor/github.com/google/go-github/v48/github/licenses.go
generated
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LicensesService handles communication with the license related
|
||||||
|
// methods of the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/licenses/
|
||||||
|
type LicensesService service
|
||||||
|
|
||||||
|
// RepositoryLicense represents the license for a repository.
|
||||||
|
type RepositoryLicense struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
|
||||||
|
SHA *string `json:"sha,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
GitURL *string `json:"git_url,omitempty"`
|
||||||
|
DownloadURL *string `json:"download_url,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Content *string `json:"content,omitempty"`
|
||||||
|
Encoding *string `json:"encoding,omitempty"`
|
||||||
|
License *License `json:"license,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l RepositoryLicense) String() string {
|
||||||
|
return Stringify(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// License represents an open source license.
|
||||||
|
type License struct {
|
||||||
|
Key *string `json:"key,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
|
||||||
|
SPDXID *string `json:"spdx_id,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
Featured *bool `json:"featured,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
Implementation *string `json:"implementation,omitempty"`
|
||||||
|
Permissions *[]string `json:"permissions,omitempty"`
|
||||||
|
Conditions *[]string `json:"conditions,omitempty"`
|
||||||
|
Limitations *[]string `json:"limitations,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l License) String() string {
|
||||||
|
return Stringify(l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List popular open source licenses.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/licenses/#list-all-licenses
|
||||||
|
func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) {
|
||||||
|
req, err := s.client.NewRequest("GET", "licenses", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var licenses []*License
|
||||||
|
resp, err := s.client.Do(ctx, req, &licenses)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return licenses, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get extended metadata for one license.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/licenses#get-a-license
|
||||||
|
func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) {
|
||||||
|
u := fmt.Sprintf("licenses/%s", licenseName)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
license := new(License)
|
||||||
|
resp, err := s.client.Do(ctx, req, license)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return license, resp, nil
|
||||||
|
}
|
||||||
305
vendor/github.com/google/go-github/v48/github/messages.go
generated
vendored
Normal file
305
vendor/github.com/google/go-github/v48/github/messages.go
generated
vendored
Normal file
|
|
@ -0,0 +1,305 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
// This file provides functions for validating payloads from GitHub Webhooks.
|
||||||
|
// GitHub API docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha1"
|
||||||
|
"crypto/sha256"
|
||||||
|
"crypto/sha512"
|
||||||
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"hash"
|
||||||
|
"io"
|
||||||
|
"mime"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// sha1Prefix is the prefix used by GitHub before the HMAC hexdigest.
|
||||||
|
sha1Prefix = "sha1"
|
||||||
|
// sha256Prefix and sha512Prefix are provided for future compatibility.
|
||||||
|
sha256Prefix = "sha256"
|
||||||
|
sha512Prefix = "sha512"
|
||||||
|
// SHA1SignatureHeader is the GitHub header key used to pass the HMAC-SHA1 hexdigest.
|
||||||
|
SHA1SignatureHeader = "X-Hub-Signature"
|
||||||
|
// SHA256SignatureHeader is the GitHub header key used to pass the HMAC-SHA256 hexdigest.
|
||||||
|
SHA256SignatureHeader = "X-Hub-Signature-256"
|
||||||
|
// EventTypeHeader is the GitHub header key used to pass the event type.
|
||||||
|
EventTypeHeader = "X-Github-Event"
|
||||||
|
// DeliveryIDHeader is the GitHub header key used to pass the unique ID for the webhook event.
|
||||||
|
DeliveryIDHeader = "X-Github-Delivery"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// eventTypeMapping maps webhooks types to their corresponding go-github struct types.
|
||||||
|
eventTypeMapping = map[string]string{
|
||||||
|
"branch_protection_rule": "BranchProtectionRuleEvent",
|
||||||
|
"check_run": "CheckRunEvent",
|
||||||
|
"check_suite": "CheckSuiteEvent",
|
||||||
|
"code_scanning_alert": "CodeScanningAlertEvent",
|
||||||
|
"commit_comment": "CommitCommentEvent",
|
||||||
|
"content_reference": "ContentReferenceEvent",
|
||||||
|
"create": "CreateEvent",
|
||||||
|
"delete": "DeleteEvent",
|
||||||
|
"deploy_key": "DeployKeyEvent",
|
||||||
|
"deployment": "DeploymentEvent",
|
||||||
|
"deployment_status": "DeploymentStatusEvent",
|
||||||
|
"discussion": "DiscussionEvent",
|
||||||
|
"fork": "ForkEvent",
|
||||||
|
"github_app_authorization": "GitHubAppAuthorizationEvent",
|
||||||
|
"gollum": "GollumEvent",
|
||||||
|
"installation": "InstallationEvent",
|
||||||
|
"installation_repositories": "InstallationRepositoriesEvent",
|
||||||
|
"issue_comment": "IssueCommentEvent",
|
||||||
|
"issues": "IssuesEvent",
|
||||||
|
"label": "LabelEvent",
|
||||||
|
"marketplace_purchase": "MarketplacePurchaseEvent",
|
||||||
|
"member": "MemberEvent",
|
||||||
|
"membership": "MembershipEvent",
|
||||||
|
"merge_group": "MergeGroupEvent",
|
||||||
|
"meta": "MetaEvent",
|
||||||
|
"milestone": "MilestoneEvent",
|
||||||
|
"organization": "OrganizationEvent",
|
||||||
|
"org_block": "OrgBlockEvent",
|
||||||
|
"package": "PackageEvent",
|
||||||
|
"page_build": "PageBuildEvent",
|
||||||
|
"ping": "PingEvent",
|
||||||
|
"project": "ProjectEvent",
|
||||||
|
"project_card": "ProjectCardEvent",
|
||||||
|
"project_column": "ProjectColumnEvent",
|
||||||
|
"public": "PublicEvent",
|
||||||
|
"pull_request": "PullRequestEvent",
|
||||||
|
"pull_request_review": "PullRequestReviewEvent",
|
||||||
|
"pull_request_review_comment": "PullRequestReviewCommentEvent",
|
||||||
|
"pull_request_review_thread": "PullRequestReviewThreadEvent",
|
||||||
|
"pull_request_target": "PullRequestTargetEvent",
|
||||||
|
"push": "PushEvent",
|
||||||
|
"repository": "RepositoryEvent",
|
||||||
|
"repository_dispatch": "RepositoryDispatchEvent",
|
||||||
|
"repository_import": "RepositoryImportEvent",
|
||||||
|
"repository_vulnerability_alert": "RepositoryVulnerabilityAlertEvent",
|
||||||
|
"release": "ReleaseEvent",
|
||||||
|
"secret_scanning_alert": "SecretScanningAlertEvent",
|
||||||
|
"star": "StarEvent",
|
||||||
|
"status": "StatusEvent",
|
||||||
|
"team": "TeamEvent",
|
||||||
|
"team_add": "TeamAddEvent",
|
||||||
|
"user": "UserEvent",
|
||||||
|
"watch": "WatchEvent",
|
||||||
|
"workflow_dispatch": "WorkflowDispatchEvent",
|
||||||
|
"workflow_job": "WorkflowJobEvent",
|
||||||
|
"workflow_run": "WorkflowRunEvent",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// genMAC generates the HMAC signature for a message provided the secret key
|
||||||
|
// and hashFunc.
|
||||||
|
func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte {
|
||||||
|
mac := hmac.New(hashFunc, key)
|
||||||
|
mac.Write(message)
|
||||||
|
return mac.Sum(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkMAC reports whether messageMAC is a valid HMAC tag for message.
|
||||||
|
func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool {
|
||||||
|
expectedMAC := genMAC(message, key, hashFunc)
|
||||||
|
return hmac.Equal(messageMAC, expectedMAC)
|
||||||
|
}
|
||||||
|
|
||||||
|
// messageMAC returns the hex-decoded HMAC tag from the signature and its
|
||||||
|
// corresponding hash function.
|
||||||
|
func messageMAC(signature string) ([]byte, func() hash.Hash, error) {
|
||||||
|
if signature == "" {
|
||||||
|
return nil, nil, errors.New("missing signature")
|
||||||
|
}
|
||||||
|
sigParts := strings.SplitN(signature, "=", 2)
|
||||||
|
if len(sigParts) != 2 {
|
||||||
|
return nil, nil, fmt.Errorf("error parsing signature %q", signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
var hashFunc func() hash.Hash
|
||||||
|
switch sigParts[0] {
|
||||||
|
case sha1Prefix:
|
||||||
|
hashFunc = sha1.New
|
||||||
|
case sha256Prefix:
|
||||||
|
hashFunc = sha256.New
|
||||||
|
case sha512Prefix:
|
||||||
|
hashFunc = sha512.New
|
||||||
|
default:
|
||||||
|
return nil, nil, fmt.Errorf("unknown hash type prefix: %q", sigParts[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
buf, err := hex.DecodeString(sigParts[1])
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("error decoding signature %q: %v", signature, err)
|
||||||
|
}
|
||||||
|
return buf, hashFunc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidatePayload validates an incoming GitHub Webhook event request body
|
||||||
|
// and returns the (JSON) payload.
|
||||||
|
// The Content-Type header of the payload can be "application/json" or "application/x-www-form-urlencoded".
|
||||||
|
// If the Content-Type is neither then an error is returned.
|
||||||
|
// secretToken is the GitHub Webhook secret token.
|
||||||
|
// If your webhook does not contain a secret token, you can pass nil or an empty slice.
|
||||||
|
// This is intended for local development purposes only and all webhooks should ideally set up a secret token.
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
//
|
||||||
|
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// // read signature from request
|
||||||
|
// signature := ""
|
||||||
|
// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey)
|
||||||
|
// if err != nil { ... }
|
||||||
|
// // Process payload...
|
||||||
|
// }
|
||||||
|
func ValidatePayloadFromBody(contentType string, readable io.Reader, signature string, secretToken []byte) (payload []byte, err error) {
|
||||||
|
var body []byte // Raw body that GitHub uses to calculate the signature.
|
||||||
|
|
||||||
|
switch contentType {
|
||||||
|
case "application/json":
|
||||||
|
var err error
|
||||||
|
if body, err = io.ReadAll(readable); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the content type is application/json,
|
||||||
|
// the JSON payload is just the original body.
|
||||||
|
payload = body
|
||||||
|
|
||||||
|
case "application/x-www-form-urlencoded":
|
||||||
|
// payloadFormParam is the name of the form parameter that the JSON payload
|
||||||
|
// will be in if a webhook has its content type set to application/x-www-form-urlencoded.
|
||||||
|
const payloadFormParam = "payload"
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if body, err = io.ReadAll(readable); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the content type is application/x-www-form-urlencoded,
|
||||||
|
// the JSON payload will be under the "payload" form param.
|
||||||
|
form, err := url.ParseQuery(string(body))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
payload = []byte(form.Get(payloadFormParam))
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("webhook request has unsupported Content-Type %q", contentType)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only validate the signature if a secret token exists. This is intended for
|
||||||
|
// local development only and all webhooks should ideally set up a secret token.
|
||||||
|
if len(secretToken) > 0 {
|
||||||
|
if err := ValidateSignature(signature, body, secretToken); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidatePayload validates an incoming GitHub Webhook event request
|
||||||
|
// and returns the (JSON) payload.
|
||||||
|
// The Content-Type header of the payload can be "application/json" or "application/x-www-form-urlencoded".
|
||||||
|
// If the Content-Type is neither then an error is returned.
|
||||||
|
// secretToken is the GitHub Webhook secret token.
|
||||||
|
// If your webhook does not contain a secret token, you can pass nil or an empty slice.
|
||||||
|
// This is intended for local development purposes only and all webhooks should ideally set up a secret token.
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
//
|
||||||
|
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||||
|
// if err != nil { ... }
|
||||||
|
// // Process payload...
|
||||||
|
// }
|
||||||
|
func ValidatePayload(r *http.Request, secretToken []byte) (payload []byte, err error) {
|
||||||
|
signature := r.Header.Get(SHA256SignatureHeader)
|
||||||
|
if signature == "" {
|
||||||
|
signature = r.Header.Get(SHA1SignatureHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValidatePayloadFromBody(contentType, r.Body, signature, secretToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidateSignature validates the signature for the given payload.
|
||||||
|
// signature is the GitHub hash signature delivered in the X-Hub-Signature header.
|
||||||
|
// payload is the JSON payload sent by GitHub Webhooks.
|
||||||
|
// secretToken is the GitHub Webhook secret token.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github
|
||||||
|
func ValidateSignature(signature string, payload, secretToken []byte) error {
|
||||||
|
messageMAC, hashFunc, err := messageMAC(signature)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !checkMAC(payload, messageMAC, secretToken, hashFunc) {
|
||||||
|
return errors.New("payload signature check failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WebHookType returns the event type of webhook request r.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types
|
||||||
|
func WebHookType(r *http.Request) string {
|
||||||
|
return r.Header.Get(EventTypeHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeliveryID returns the unique delivery ID of webhook request r.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types
|
||||||
|
func DeliveryID(r *http.Request) string {
|
||||||
|
return r.Header.Get(DeliveryIDHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseWebHook parses the event payload. For recognized event types, a
|
||||||
|
// value of the corresponding struct type will be returned (as returned
|
||||||
|
// by Event.ParsePayload()). An error will be returned for unrecognized event
|
||||||
|
// types.
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
//
|
||||||
|
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
|
||||||
|
// if err != nil { ... }
|
||||||
|
// event, err := github.ParseWebHook(github.WebHookType(r), payload)
|
||||||
|
// if err != nil { ... }
|
||||||
|
// switch event := event.(type) {
|
||||||
|
// case *github.CommitCommentEvent:
|
||||||
|
// processCommitCommentEvent(event)
|
||||||
|
// case *github.CreateEvent:
|
||||||
|
// processCreateEvent(event)
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
func ParseWebHook(messageType string, payload []byte) (interface{}, error) {
|
||||||
|
eventType, ok := eventTypeMapping[messageType]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unknown X-Github-Event in message: %v", messageType)
|
||||||
|
}
|
||||||
|
|
||||||
|
event := Event{
|
||||||
|
Type: &eventType,
|
||||||
|
RawPayload: (*json.RawMessage)(&payload),
|
||||||
|
}
|
||||||
|
return event.ParsePayload()
|
||||||
|
}
|
||||||
228
vendor/github.com/google/go-github/v48/github/migrations.go
generated
vendored
Normal file
228
vendor/github.com/google/go-github/v48/github/migrations.go
generated
vendored
Normal file
|
|
@ -0,0 +1,228 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrationService provides access to the migration related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migration/
|
||||||
|
type MigrationService service
|
||||||
|
|
||||||
|
// Migration represents a GitHub migration (archival).
|
||||||
|
type Migration struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
GUID *string `json:"guid,omitempty"`
|
||||||
|
// State is the current state of a migration.
|
||||||
|
// Possible values are:
|
||||||
|
// "pending" which means the migration hasn't started yet,
|
||||||
|
// "exporting" which means the migration is in progress,
|
||||||
|
// "exported" which means the migration finished successfully, or
|
||||||
|
// "failed" which means the migration failed.
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
// LockRepositories indicates whether repositories are locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories *bool `json:"lock_repositories,omitempty"`
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
CreatedAt *string `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *string `json:"updated_at,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Migration) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrationOptions specifies the optional parameters to Migration methods.
|
||||||
|
type MigrationOptions struct {
|
||||||
|
// LockRepositories indicates whether repositories should be locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories bool
|
||||||
|
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// startMigration represents the body of a StartMigration request.
|
||||||
|
type startMigration struct {
|
||||||
|
// Repositories is a slice of repository names to migrate.
|
||||||
|
Repositories []string `json:"repositories,omitempty"`
|
||||||
|
|
||||||
|
// LockRepositories indicates whether repositories should be locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories *bool `json:"lock_repositories,omitempty"`
|
||||||
|
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartMigration starts the generation of a migration archive.
|
||||||
|
// repos is a slice of repository names to migrate.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#start-an-organization-migration
|
||||||
|
func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations", org)
|
||||||
|
|
||||||
|
body := &startMigration{Repositories: repos}
|
||||||
|
if opts != nil {
|
||||||
|
body.LockRepositories = Bool(opts.LockRepositories)
|
||||||
|
body.ExcludeAttachments = Bool(opts.ExcludeAttachments)
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
m := &Migration{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListMigrations lists the most recent migrations.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#list-organization-migrations
|
||||||
|
func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations", org)
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
var m []*Migration
|
||||||
|
resp, err := s.client.Do(ctx, req, &m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrationStatus gets the status of a specific migration archive.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#get-an-organization-migration-status
|
||||||
|
func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations/%v", org, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
m := &Migration{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrationArchiveURL fetches a migration archive URL.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#download-an-organization-migration-archive
|
||||||
|
func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
s.client.clientMu.Lock()
|
||||||
|
defer s.client.clientMu.Unlock()
|
||||||
|
|
||||||
|
// Disable the redirect mechanism because AWS fails if the GitHub auth token is provided.
|
||||||
|
var loc string
|
||||||
|
saveRedirect := s.client.client.CheckRedirect
|
||||||
|
s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
|
loc = req.URL.String()
|
||||||
|
return errors.New("disable redirect")
|
||||||
|
}
|
||||||
|
defer func() { s.client.client.CheckRedirect = saveRedirect }()
|
||||||
|
|
||||||
|
_, err = s.client.Do(ctx, req, nil) // expect error from disable redirect
|
||||||
|
if err == nil {
|
||||||
|
return "", errors.New("expected redirect, none provided")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "disable redirect") {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return loc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteMigration deletes a previous migration archive.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#delete-an-organization-migration-archive
|
||||||
|
func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnlockRepo unlocks a repository that was locked for migration.
|
||||||
|
// id is the migration ID.
|
||||||
|
// You should unlock each migrated repository and delete them when the migration
|
||||||
|
// is complete and you no longer need the source data.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#unlock-an-organization-repository
|
||||||
|
func (s *MigrationService) UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/migrations/%v/repos/%v/lock", org, id, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
305
vendor/github.com/google/go-github/v48/github/migrations_source_import.go
generated
vendored
Normal file
305
vendor/github.com/google/go-github/v48/github/migrations_source_import.go
generated
vendored
Normal file
|
|
@ -0,0 +1,305 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Import represents a repository import request.
|
||||||
|
type Import struct {
|
||||||
|
// The URL of the originating repository.
|
||||||
|
VCSURL *string `json:"vcs_url,omitempty"`
|
||||||
|
// The originating VCS type. Can be one of 'subversion', 'git',
|
||||||
|
// 'mercurial', or 'tfvc'. Without this parameter, the import job will
|
||||||
|
// take additional time to detect the VCS type before beginning the
|
||||||
|
// import. This detection step will be reflected in the response.
|
||||||
|
VCS *string `json:"vcs,omitempty"`
|
||||||
|
// VCSUsername and VCSPassword are only used for StartImport calls that
|
||||||
|
// are importing a password-protected repository.
|
||||||
|
VCSUsername *string `json:"vcs_username,omitempty"`
|
||||||
|
VCSPassword *string `json:"vcs_password,omitempty"`
|
||||||
|
// For a tfvc import, the name of the project that is being imported.
|
||||||
|
TFVCProject *string `json:"tfvc_project,omitempty"`
|
||||||
|
|
||||||
|
// LFS related fields that may be preset in the Import Progress response
|
||||||
|
|
||||||
|
// Describes whether the import has been opted in or out of using Git
|
||||||
|
// LFS. The value can be 'opt_in', 'opt_out', or 'undecided' if no
|
||||||
|
// action has been taken.
|
||||||
|
UseLFS *string `json:"use_lfs,omitempty"`
|
||||||
|
// Describes whether files larger than 100MB were found during the
|
||||||
|
// importing step.
|
||||||
|
HasLargeFiles *bool `json:"has_large_files,omitempty"`
|
||||||
|
// The total size in gigabytes of files larger than 100MB found in the
|
||||||
|
// originating repository.
|
||||||
|
LargeFilesSize *int `json:"large_files_size,omitempty"`
|
||||||
|
// The total number of files larger than 100MB found in the originating
|
||||||
|
// repository. To see a list of these files, call LargeFiles.
|
||||||
|
LargeFilesCount *int `json:"large_files_count,omitempty"`
|
||||||
|
|
||||||
|
// Identifies the current status of an import. An import that does not
|
||||||
|
// have errors will progress through these steps:
|
||||||
|
//
|
||||||
|
// detecting - the "detection" step of the import is in progress
|
||||||
|
// because the request did not include a VCS parameter. The
|
||||||
|
// import is identifying the type of source control present at
|
||||||
|
// the URL.
|
||||||
|
// importing - the "raw" step of the import is in progress. This is
|
||||||
|
// where commit data is fetched from the original repository.
|
||||||
|
// The import progress response will include CommitCount (the
|
||||||
|
// total number of raw commits that will be imported) and
|
||||||
|
// Percent (0 - 100, the current progress through the import).
|
||||||
|
// mapping - the "rewrite" step of the import is in progress. This
|
||||||
|
// is where SVN branches are converted to Git branches, and
|
||||||
|
// where author updates are applied. The import progress
|
||||||
|
// response does not include progress information.
|
||||||
|
// pushing - the "push" step of the import is in progress. This is
|
||||||
|
// where the importer updates the repository on GitHub. The
|
||||||
|
// import progress response will include PushPercent, which is
|
||||||
|
// the percent value reported by git push when it is "Writing
|
||||||
|
// objects".
|
||||||
|
// complete - the import is complete, and the repository is ready
|
||||||
|
// on GitHub.
|
||||||
|
//
|
||||||
|
// If there are problems, you will see one of these in the status field:
|
||||||
|
//
|
||||||
|
// auth_failed - the import requires authentication in order to
|
||||||
|
// connect to the original repository. Make an UpdateImport
|
||||||
|
// request, and include VCSUsername and VCSPassword.
|
||||||
|
// error - the import encountered an error. The import progress
|
||||||
|
// response will include the FailedStep and an error message.
|
||||||
|
// Contact GitHub support for more information.
|
||||||
|
// detection_needs_auth - the importer requires authentication for
|
||||||
|
// the originating repository to continue detection. Make an
|
||||||
|
// UpdatImport request, and include VCSUsername and
|
||||||
|
// VCSPassword.
|
||||||
|
// detection_found_nothing - the importer didn't recognize any
|
||||||
|
// source control at the URL.
|
||||||
|
// detection_found_multiple - the importer found several projects
|
||||||
|
// or repositories at the provided URL. When this is the case,
|
||||||
|
// the Import Progress response will also include a
|
||||||
|
// ProjectChoices field with the possible project choices as
|
||||||
|
// values. Make an UpdateImport request, and include VCS and
|
||||||
|
// (if applicable) TFVCProject.
|
||||||
|
Status *string `json:"status,omitempty"`
|
||||||
|
CommitCount *int `json:"commit_count,omitempty"`
|
||||||
|
StatusText *string `json:"status_text,omitempty"`
|
||||||
|
AuthorsCount *int `json:"authors_count,omitempty"`
|
||||||
|
Percent *int `json:"percent,omitempty"`
|
||||||
|
PushPercent *int `json:"push_percent,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
AuthorsURL *string `json:"authors_url,omitempty"`
|
||||||
|
RepositoryURL *string `json:"repository_url,omitempty"`
|
||||||
|
Message *string `json:"message,omitempty"`
|
||||||
|
FailedStep *string `json:"failed_step,omitempty"`
|
||||||
|
|
||||||
|
// Human readable display name, provided when the Import appears as
|
||||||
|
// part of ProjectChoices.
|
||||||
|
HumanName *string `json:"human_name,omitempty"`
|
||||||
|
|
||||||
|
// When the importer finds several projects or repositories at the
|
||||||
|
// provided URLs, this will identify the available choices. Call
|
||||||
|
// UpdateImport with the selected Import value.
|
||||||
|
ProjectChoices []*Import `json:"project_choices,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i Import) String() string {
|
||||||
|
return Stringify(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SourceImportAuthor identifies an author imported from a source repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-commit-authors
|
||||||
|
type SourceImportAuthor struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
RemoteID *string `json:"remote_id,omitempty"`
|
||||||
|
RemoteName *string `json:"remote_name,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
ImportURL *string `json:"import_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a SourceImportAuthor) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LargeFile identifies a file larger than 100MB found during a repository import.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-large-files
|
||||||
|
type LargeFile struct {
|
||||||
|
RefName *string `json:"ref_name,omitempty"`
|
||||||
|
Path *string `json:"path,omitempty"`
|
||||||
|
OID *string `json:"oid,omitempty"`
|
||||||
|
Size *int `json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f LargeFile) String() string {
|
||||||
|
return Stringify(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartImport initiates a repository import.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#start-an-import
|
||||||
|
func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, in)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := new(Import)
|
||||||
|
resp, err := s.client.Do(ctx, req, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImportProgress queries for the status and progress of an ongoing repository import.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-an-import-status
|
||||||
|
func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := new(Import)
|
||||||
|
resp, err := s.client.Do(ctx, req, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateImport initiates a repository import.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-an-import
|
||||||
|
func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, in)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := new(Import)
|
||||||
|
resp, err := s.client.Do(ctx, req, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommitAuthors gets the authors mapped from the original repository.
|
||||||
|
//
|
||||||
|
// Each type of source control system represents authors in a different way.
|
||||||
|
// For example, a Git commit author has a display name and an email address,
|
||||||
|
// but a Subversion commit author just has a username. The GitHub Importer will
|
||||||
|
// make the author information valid, but the author might not be correct. For
|
||||||
|
// example, it will change the bare Subversion username "hubot" into something
|
||||||
|
// like "hubot <hubot@12341234-abab-fefe-8787-fedcba987654>".
|
||||||
|
//
|
||||||
|
// This method and MapCommitAuthor allow you to provide correct Git author
|
||||||
|
// information.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-commit-authors
|
||||||
|
func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var authors []*SourceImportAuthor
|
||||||
|
resp, err := s.client.Do(ctx, req, &authors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return authors, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MapCommitAuthor updates an author's identity for the import. Your
|
||||||
|
// application can continue updating authors any time before you push new
|
||||||
|
// commits to the repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#map-a-commit-author
|
||||||
|
func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo string, id int64, author *SourceImportAuthor) (*SourceImportAuthor, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/authors/%v", owner, repo, id)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, author)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := new(SourceImportAuthor)
|
||||||
|
resp, err := s.client.Do(ctx, req, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLFSPreference sets whether imported repositories should use Git LFS for
|
||||||
|
// files larger than 100MB. Only the UseLFS field on the provided Import is
|
||||||
|
// used.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-git-lfs-preference
|
||||||
|
func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/lfs", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, in)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
out := new(Import)
|
||||||
|
resp, err := s.client.Do(ctx, req, out)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LargeFiles lists files larger than 100MB found during the import.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-large-files
|
||||||
|
func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var files []*LargeFile
|
||||||
|
resp, err := s.client.Do(ctx, req, &files)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return files, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelImport stops an import for a repository.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#cancel-an-import
|
||||||
|
func (s *MigrationService) CancelImport(ctx context.Context, owner, repo string) (*Response, error) {
|
||||||
|
u := fmt.Sprintf("repos/%v/%v/import", owner, repo)
|
||||||
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
218
vendor/github.com/google/go-github/v48/github/migrations_user.go
generated
vendored
Normal file
218
vendor/github.com/google/go-github/v48/github/migrations_user.go
generated
vendored
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
// Copyright 2018 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserMigration represents a GitHub migration (archival).
|
||||||
|
type UserMigration struct {
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
GUID *string `json:"guid,omitempty"`
|
||||||
|
// State is the current state of a migration.
|
||||||
|
// Possible values are:
|
||||||
|
// "pending" which means the migration hasn't started yet,
|
||||||
|
// "exporting" which means the migration is in progress,
|
||||||
|
// "exported" which means the migration finished successfully, or
|
||||||
|
// "failed" which means the migration failed.
|
||||||
|
State *string `json:"state,omitempty"`
|
||||||
|
// LockRepositories indicates whether repositories are locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories *bool `json:"lock_repositories,omitempty"`
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
CreatedAt *string `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *string `json:"updated_at,omitempty"`
|
||||||
|
Repositories []*Repository `json:"repositories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m UserMigration) String() string {
|
||||||
|
return Stringify(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserMigrationOptions specifies the optional parameters to Migration methods.
|
||||||
|
type UserMigrationOptions struct {
|
||||||
|
// LockRepositories indicates whether repositories should be locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories bool
|
||||||
|
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// startUserMigration represents the body of a StartMigration request.
|
||||||
|
type startUserMigration struct {
|
||||||
|
// Repositories is a slice of repository names to migrate.
|
||||||
|
Repositories []string `json:"repositories,omitempty"`
|
||||||
|
|
||||||
|
// LockRepositories indicates whether repositories should be locked (to prevent
|
||||||
|
// manipulation) while migrating data.
|
||||||
|
LockRepositories *bool `json:"lock_repositories,omitempty"`
|
||||||
|
|
||||||
|
// ExcludeAttachments indicates whether attachments should be excluded from
|
||||||
|
// the migration (to reduce migration archive file size).
|
||||||
|
ExcludeAttachments *bool `json:"exclude_attachments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartUserMigration starts the generation of a migration archive.
|
||||||
|
// repos is a slice of repository names to migrate.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#start-a-user-migration
|
||||||
|
func (s *MigrationService) StartUserMigration(ctx context.Context, repos []string, opts *UserMigrationOptions) (*UserMigration, *Response, error) {
|
||||||
|
u := "user/migrations"
|
||||||
|
|
||||||
|
body := &startUserMigration{Repositories: repos}
|
||||||
|
if opts != nil {
|
||||||
|
body.LockRepositories = Bool(opts.LockRepositories)
|
||||||
|
body.ExcludeAttachments = Bool(opts.ExcludeAttachments)
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("POST", u, body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
m := &UserMigration{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListUserMigrations lists the most recent migrations.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#list-user-migrations
|
||||||
|
func (s *MigrationService) ListUserMigrations(ctx context.Context, opts *ListOptions) ([]*UserMigration, *Response, error) {
|
||||||
|
u := "user/migrations"
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
var m []*UserMigration
|
||||||
|
resp, err := s.client.Do(ctx, req, &m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserMigrationStatus gets the status of a specific migration archive.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#get-a-user-migration-status
|
||||||
|
func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (*UserMigration, *Response, error) {
|
||||||
|
u := fmt.Sprintf("user/migrations/%v", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
m := &UserMigration{}
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserMigrationArchiveURL gets the URL for a specific migration archive.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#download-a-user-migration-archive
|
||||||
|
func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) {
|
||||||
|
url := fmt.Sprintf("user/migrations/%v/archive", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
m := &UserMigration{}
|
||||||
|
|
||||||
|
var loc string
|
||||||
|
originalRedirect := s.client.client.CheckRedirect
|
||||||
|
s.client.client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
|
||||||
|
loc = req.URL.String()
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
s.client.client.CheckRedirect = originalRedirect
|
||||||
|
}()
|
||||||
|
resp, err := s.client.Do(ctx, req, m)
|
||||||
|
if err == nil {
|
||||||
|
return "", errors.New("expected redirect, none provided")
|
||||||
|
}
|
||||||
|
loc = resp.Header.Get("Location")
|
||||||
|
return loc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserMigration will delete a previous migration archive.
|
||||||
|
// id is the migration ID.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#delete-a-user-migration-archive
|
||||||
|
func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("user/migrations/%v/archive", id)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnlockUserRepo will unlock a repo that was locked for migration.
|
||||||
|
// id is migration ID.
|
||||||
|
// You should unlock each migrated repository and delete them when the migration
|
||||||
|
// is complete and you no longer need the source data.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#unlock-a-user-repository
|
||||||
|
func (s *MigrationService) UnlockUserRepo(ctx context.Context, id int64, repo string) (*Response, error) {
|
||||||
|
url := fmt.Sprintf("user/migrations/%v/repos/%v/lock", id, repo)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMigrationsPreview)
|
||||||
|
|
||||||
|
return s.client.Do(ctx, req, nil)
|
||||||
|
}
|
||||||
279
vendor/github.com/google/go-github/v48/github/misc.go
generated
vendored
Normal file
279
vendor/github.com/google/go-github/v48/github/misc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,279 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MarkdownOptions specifies optional parameters to the Markdown method.
|
||||||
|
type MarkdownOptions struct {
|
||||||
|
// Mode identifies the rendering mode. Possible values are:
|
||||||
|
// markdown - render a document as plain Markdown, just like
|
||||||
|
// README files are rendered.
|
||||||
|
//
|
||||||
|
// gfm - to render a document as user-content, e.g. like user
|
||||||
|
// comments or issues are rendered. In GFM mode, hard line breaks are
|
||||||
|
// always taken into account, and issue and user mentions are linked
|
||||||
|
// accordingly.
|
||||||
|
//
|
||||||
|
// Default is "markdown".
|
||||||
|
Mode string
|
||||||
|
|
||||||
|
// Context identifies the repository context. Only taken into account
|
||||||
|
// when rendering as "gfm".
|
||||||
|
Context string
|
||||||
|
}
|
||||||
|
|
||||||
|
type markdownRequest struct {
|
||||||
|
Text *string `json:"text,omitempty"`
|
||||||
|
Mode *string `json:"mode,omitempty"`
|
||||||
|
Context *string `json:"context,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Markdown renders an arbitrary Markdown document.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/markdown/
|
||||||
|
func (c *Client) Markdown(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
|
||||||
|
request := &markdownRequest{Text: String(text)}
|
||||||
|
if opts != nil {
|
||||||
|
if opts.Mode != "" {
|
||||||
|
request.Mode = String(opts.Mode)
|
||||||
|
}
|
||||||
|
if opts.Context != "" {
|
||||||
|
request.Context = String(opts.Context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := c.NewRequest("POST", "markdown", request)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
resp, err := c.Do(ctx, req, buf)
|
||||||
|
if err != nil {
|
||||||
|
return "", resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.String(), resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListEmojis returns the emojis available to use on GitHub.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/emojis/
|
||||||
|
func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
|
||||||
|
req, err := c.NewRequest("GET", "emojis", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var emoji map[string]string
|
||||||
|
resp, err := c.Do(ctx, req, &emoji)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return emoji, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CodeOfConduct represents a code of conduct.
|
||||||
|
type CodeOfConduct struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Key *string `json:"key,omitempty"`
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
Body *string `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CodeOfConduct) String() string {
|
||||||
|
return Stringify(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCodesOfConduct returns all codes of conduct.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/codes_of_conduct/#list-all-codes-of-conduct
|
||||||
|
func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
|
||||||
|
req, err := c.NewRequest("GET", "codes_of_conduct", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
|
||||||
|
|
||||||
|
var cs []*CodeOfConduct
|
||||||
|
resp, err := c.Do(ctx, req, &cs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCodeOfConduct returns an individual code of conduct.
|
||||||
|
//
|
||||||
|
// https://docs.github.com/en/rest/codes_of_conduct/#get-an-individual-code-of-conduct
|
||||||
|
func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
|
||||||
|
u := fmt.Sprintf("codes_of_conduct/%s", key)
|
||||||
|
req, err := c.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeCodesOfConductPreview)
|
||||||
|
|
||||||
|
coc := new(CodeOfConduct)
|
||||||
|
resp, err := c.Do(ctx, req, coc)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return coc, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIMeta represents metadata about the GitHub API.
|
||||||
|
type APIMeta struct {
|
||||||
|
// An Array of IP addresses in CIDR format specifying the addresses
|
||||||
|
// that incoming service hooks will originate from on GitHub.com.
|
||||||
|
Hooks []string `json:"hooks,omitempty"`
|
||||||
|
|
||||||
|
// An Array of IP addresses in CIDR format specifying the Git servers
|
||||||
|
// for GitHub.com.
|
||||||
|
Git []string `json:"git,omitempty"`
|
||||||
|
|
||||||
|
// Whether authentication with username and password is supported.
|
||||||
|
// (GitHub Enterprise instances using CAS or OAuth for authentication
|
||||||
|
// will return false. Features like Basic Authentication with a
|
||||||
|
// username and password, sudo mode, and two-factor authentication are
|
||||||
|
// not supported on these servers.)
|
||||||
|
VerifiablePasswordAuthentication *bool `json:"verifiable_password_authentication,omitempty"`
|
||||||
|
|
||||||
|
// An array of IP addresses in CIDR format specifying the addresses
|
||||||
|
// which serve GitHub Pages websites.
|
||||||
|
Pages []string `json:"pages,omitempty"`
|
||||||
|
|
||||||
|
// An Array of IP addresses specifying the addresses that source imports
|
||||||
|
// will originate from on GitHub.com.
|
||||||
|
Importer []string `json:"importer,omitempty"`
|
||||||
|
|
||||||
|
// An array of IP addresses in CIDR format specifying the IP addresses
|
||||||
|
// GitHub Actions will originate from.
|
||||||
|
Actions []string `json:"actions,omitempty"`
|
||||||
|
|
||||||
|
// An array of IP addresses in CIDR format specifying the IP addresses
|
||||||
|
// Dependabot will originate from.
|
||||||
|
Dependabot []string `json:"dependabot,omitempty"`
|
||||||
|
|
||||||
|
// A map of algorithms to SSH key fingerprints.
|
||||||
|
SSHKeyFingerprints map[string]string `json:"ssh_key_fingerprints,omitempty"`
|
||||||
|
|
||||||
|
// An array of SSH keys.
|
||||||
|
SSHKeys []string `json:"ssh_keys,omitempty"`
|
||||||
|
|
||||||
|
// An array of IP addresses in CIDR format specifying the addresses
|
||||||
|
// which serve GitHub websites.
|
||||||
|
Web []string `json:"web,omitempty"`
|
||||||
|
|
||||||
|
// An array of IP addresses in CIDR format specifying the addresses
|
||||||
|
// which serve GitHub APIs.
|
||||||
|
API []string `json:"api,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIMeta returns information about GitHub.com, the service. Or, if you access
|
||||||
|
// this endpoint on your organization’s GitHub Enterprise installation, this
|
||||||
|
// endpoint provides information about that installation.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/meta#get-github-meta-information
|
||||||
|
func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) {
|
||||||
|
req, err := c.NewRequest("GET", "meta", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
meta := new(APIMeta)
|
||||||
|
resp, err := c.Do(ctx, req, meta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Octocat returns an ASCII art octocat with the specified message in a speech
|
||||||
|
// bubble. If message is empty, a random zen phrase is used.
|
||||||
|
func (c *Client) Octocat(ctx context.Context, message string) (string, *Response, error) {
|
||||||
|
u := "octocat"
|
||||||
|
if message != "" {
|
||||||
|
u = fmt.Sprintf("%s?s=%s", u, url.QueryEscape(message))
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := c.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
resp, err := c.Do(ctx, req, buf)
|
||||||
|
if err != nil {
|
||||||
|
return "", resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.String(), resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zen returns a random line from The Zen of GitHub.
|
||||||
|
//
|
||||||
|
// see also: http://warpspire.com/posts/taste/
|
||||||
|
func (c *Client) Zen(ctx context.Context) (string, *Response, error) {
|
||||||
|
req, err := c.NewRequest("GET", "zen", nil)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
resp, err := c.Do(ctx, req, buf)
|
||||||
|
if err != nil {
|
||||||
|
return "", resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.String(), resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceHook represents a hook that has configuration settings, a list of
|
||||||
|
// available events, and default events.
|
||||||
|
type ServiceHook struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Events []string `json:"events,omitempty"`
|
||||||
|
SupportedEvents []string `json:"supported_events,omitempty"`
|
||||||
|
Schema [][]string `json:"schema,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServiceHook) String() string {
|
||||||
|
return Stringify(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListServiceHooks lists all of the available service hooks.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://developer.github.com/webhooks/#services
|
||||||
|
func (c *Client) ListServiceHooks(ctx context.Context) ([]*ServiceHook, *Response, error) {
|
||||||
|
u := "hooks"
|
||||||
|
req, err := c.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var hooks []*ServiceHook
|
||||||
|
resp, err := c.Do(ctx, req, &hooks)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return hooks, resp, nil
|
||||||
|
}
|
||||||
289
vendor/github.com/google/go-github/v48/github/orgs.go
generated
vendored
Normal file
289
vendor/github.com/google/go-github/v48/github/orgs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,289 @@
|
||||||
|
// Copyright 2013 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrganizationsService provides access to the organization related functions
|
||||||
|
// in the GitHub API.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/
|
||||||
|
type OrganizationsService service
|
||||||
|
|
||||||
|
// Organization represents a GitHub organization account.
|
||||||
|
type Organization struct {
|
||||||
|
Login *string `json:"login,omitempty"`
|
||||||
|
ID *int64 `json:"id,omitempty"`
|
||||||
|
NodeID *string `json:"node_id,omitempty"`
|
||||||
|
AvatarURL *string `json:"avatar_url,omitempty"`
|
||||||
|
HTMLURL *string `json:"html_url,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Company *string `json:"company,omitempty"`
|
||||||
|
Blog *string `json:"blog,omitempty"`
|
||||||
|
Location *string `json:"location,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
TwitterUsername *string `json:"twitter_username,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
|
PublicRepos *int `json:"public_repos,omitempty"`
|
||||||
|
PublicGists *int `json:"public_gists,omitempty"`
|
||||||
|
Followers *int `json:"followers,omitempty"`
|
||||||
|
Following *int `json:"following,omitempty"`
|
||||||
|
CreatedAt *time.Time `json:"created_at,omitempty"`
|
||||||
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
||||||
|
TotalPrivateRepos *int `json:"total_private_repos,omitempty"`
|
||||||
|
OwnedPrivateRepos *int `json:"owned_private_repos,omitempty"`
|
||||||
|
PrivateGists *int `json:"private_gists,omitempty"`
|
||||||
|
DiskUsage *int `json:"disk_usage,omitempty"`
|
||||||
|
Collaborators *int `json:"collaborators,omitempty"`
|
||||||
|
BillingEmail *string `json:"billing_email,omitempty"`
|
||||||
|
Type *string `json:"type,omitempty"`
|
||||||
|
Plan *Plan `json:"plan,omitempty"`
|
||||||
|
TwoFactorRequirementEnabled *bool `json:"two_factor_requirement_enabled,omitempty"`
|
||||||
|
IsVerified *bool `json:"is_verified,omitempty"`
|
||||||
|
HasOrganizationProjects *bool `json:"has_organization_projects,omitempty"`
|
||||||
|
HasRepositoryProjects *bool `json:"has_repository_projects,omitempty"`
|
||||||
|
|
||||||
|
// DefaultRepoPermission can be one of: "read", "write", "admin", or "none". (Default: "read").
|
||||||
|
// It is only used in OrganizationsService.Edit.
|
||||||
|
DefaultRepoPermission *string `json:"default_repository_permission,omitempty"`
|
||||||
|
// DefaultRepoSettings can be one of: "read", "write", "admin", or "none". (Default: "read").
|
||||||
|
// It is only used in OrganizationsService.Get.
|
||||||
|
DefaultRepoSettings *string `json:"default_repository_settings,omitempty"`
|
||||||
|
|
||||||
|
// MembersCanCreateRepos default value is true and is only used in Organizations.Edit.
|
||||||
|
MembersCanCreateRepos *bool `json:"members_can_create_repositories,omitempty"`
|
||||||
|
|
||||||
|
// https://developer.github.com/changes/2019-12-03-internal-visibility-changes/#rest-v3-api
|
||||||
|
MembersCanCreatePublicRepos *bool `json:"members_can_create_public_repositories,omitempty"`
|
||||||
|
MembersCanCreatePrivateRepos *bool `json:"members_can_create_private_repositories,omitempty"`
|
||||||
|
MembersCanCreateInternalRepos *bool `json:"members_can_create_internal_repositories,omitempty"`
|
||||||
|
|
||||||
|
// MembersCanForkPrivateRepos toggles whether organization members can fork private organization repositories.
|
||||||
|
MembersCanForkPrivateRepos *bool `json:"members_can_fork_private_repositories,omitempty"`
|
||||||
|
|
||||||
|
// MembersAllowedRepositoryCreationType denotes if organization members can create repositories
|
||||||
|
// and the type of repositories they can create. Possible values are: "all", "private", or "none".
|
||||||
|
//
|
||||||
|
// Deprecated: Use MembersCanCreatePublicRepos, MembersCanCreatePrivateRepos, MembersCanCreateInternalRepos
|
||||||
|
// instead. The new fields overrides the existing MembersAllowedRepositoryCreationType during 'edit'
|
||||||
|
// operation and does not consider 'internal' repositories during 'get' operation
|
||||||
|
MembersAllowedRepositoryCreationType *string `json:"members_allowed_repository_creation_type,omitempty"`
|
||||||
|
|
||||||
|
// MembersCanCreatePages toggles whether organization members can create GitHub Pages sites.
|
||||||
|
MembersCanCreatePages *bool `json:"members_can_create_pages,omitempty"`
|
||||||
|
// MembersCanCreatePublicPages toggles whether organization members can create public GitHub Pages sites.
|
||||||
|
MembersCanCreatePublicPages *bool `json:"members_can_create_public_pages,omitempty"`
|
||||||
|
// MembersCanCreatePrivatePages toggles whether organization members can create private GitHub Pages sites.
|
||||||
|
MembersCanCreatePrivatePages *bool `json:"members_can_create_private_pages,omitempty"`
|
||||||
|
// WebCommitSignoffRequire toggles
|
||||||
|
WebCommitSignoffRequired *bool `json:"web_commit_signoff_required,omitempty"`
|
||||||
|
// AdvancedSecurityAuditLogEnabled toggles whether the advanced security audit log is enabled.
|
||||||
|
AdvancedSecurityEnabledForNewRepos *bool `json:"advanced_security_enabled_for_new_repositories,omitempty"`
|
||||||
|
// DependabotAlertsEnabled toggles whether dependabot alerts are enabled.
|
||||||
|
DependabotAlertsEnabledForNewRepos *bool `json:"dependabot_alerts_enabled_for_new_repositories,omitempty"`
|
||||||
|
// DependabotSecurityUpdatesEnabled toggles whether dependabot security updates are enabled.
|
||||||
|
DependabotSecurityUpdatesEnabledForNewRepos *bool `json:"dependabot_security_updates_enabled_for_new_repositories,omitempty"`
|
||||||
|
// DependabotGraphEnabledForNewRepos toggles whether dependabot graph is enabled on new repositories.
|
||||||
|
DependencyGraphEnabledForNewRepos *bool `json:"dependency_graph_enabled_for_new_repositories,omitempty"`
|
||||||
|
// SecretScanningEnabled toggles whether secret scanning is enabled on new repositories.
|
||||||
|
SecretScanningEnabledForNewRepos *bool `json:"secret_scanning_enabled_for_new_repositories,omitempty"`
|
||||||
|
// SecretScanningPushProtectionEnabledForNewRepos toggles whether secret scanning push protection is enabled on new repositories.
|
||||||
|
SecretScanningPushProtectionEnabledForNewRepos *bool `json:"secret_scanning_push_protection_enabled_for_new_repositories,omitempty"`
|
||||||
|
|
||||||
|
// API URLs
|
||||||
|
URL *string `json:"url,omitempty"`
|
||||||
|
EventsURL *string `json:"events_url,omitempty"`
|
||||||
|
HooksURL *string `json:"hooks_url,omitempty"`
|
||||||
|
IssuesURL *string `json:"issues_url,omitempty"`
|
||||||
|
MembersURL *string `json:"members_url,omitempty"`
|
||||||
|
PublicMembersURL *string `json:"public_members_url,omitempty"`
|
||||||
|
ReposURL *string `json:"repos_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationInstallations represents GitHub app installations for an organization.
|
||||||
|
type OrganizationInstallations struct {
|
||||||
|
TotalCount *int `json:"total_count,omitempty"`
|
||||||
|
Installations []*Installation `json:"installations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o Organization) String() string {
|
||||||
|
return Stringify(o)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
|
||||||
|
type Plan struct {
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
|
Space *int `json:"space,omitempty"`
|
||||||
|
Collaborators *int `json:"collaborators,omitempty"`
|
||||||
|
PrivateRepos *int `json:"private_repos,omitempty"`
|
||||||
|
FilledSeats *int `json:"filled_seats,omitempty"`
|
||||||
|
Seats *int `json:"seats,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p Plan) String() string {
|
||||||
|
return Stringify(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationsListOptions specifies the optional parameters to the
|
||||||
|
// OrganizationsService.ListAll method.
|
||||||
|
type OrganizationsListOptions struct {
|
||||||
|
// Since filters Organizations by ID.
|
||||||
|
Since int64 `url:"since,omitempty"`
|
||||||
|
|
||||||
|
// Note: Pagination is powered exclusively by the Since parameter,
|
||||||
|
// ListOptions.Page has no effect.
|
||||||
|
// ListOptions.PerPage controls an undocumented GitHub API parameter.
|
||||||
|
ListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAll lists all organizations, in the order that they were created on GitHub.
|
||||||
|
//
|
||||||
|
// Note: Pagination is powered exclusively by the since parameter. To continue
|
||||||
|
// listing the next set of organizations, use the ID of the last-returned organization
|
||||||
|
// as the opts.Since parameter for the next call.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations
|
||||||
|
func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error) {
|
||||||
|
u, err := addOptions("organizations", opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
orgs := []*Organization{}
|
||||||
|
resp, err := s.client.Do(ctx, req, &orgs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
return orgs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// List the organizations for a user. Passing the empty string will list
|
||||||
|
// organizations for the authenticated user.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-the-authenticated-user
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-a-user
|
||||||
|
func (s *OrganizationsService) List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error) {
|
||||||
|
var u string
|
||||||
|
if user != "" {
|
||||||
|
u = fmt.Sprintf("users/%v/orgs", user)
|
||||||
|
} else {
|
||||||
|
u = "user/orgs"
|
||||||
|
}
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var orgs []*Organization
|
||||||
|
resp, err := s.client.Do(ctx, req, &orgs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return orgs, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get fetches an organization by name.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#get-an-organization
|
||||||
|
func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v", org)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
|
||||||
|
|
||||||
|
organization := new(Organization)
|
||||||
|
resp, err := s.client.Do(ctx, req, organization)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organization, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID fetches an organization.
|
||||||
|
//
|
||||||
|
// Note: GetByID uses the undocumented GitHub API endpoint /organizations/:id.
|
||||||
|
func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("organizations/%d", id)
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
organization := new(Organization)
|
||||||
|
resp, err := s.client.Do(ctx, req, organization)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return organization, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#update-an-organization
|
||||||
|
func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v", name)
|
||||||
|
req, err := s.client.NewRequest("PATCH", u, org)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: remove custom Accept header when this API fully launches.
|
||||||
|
req.Header.Set("Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
|
||||||
|
|
||||||
|
o := new(Organization)
|
||||||
|
resp, err := s.client.Do(ctx, req, o)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return o, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListInstallations lists installations for an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-app-installations-for-an-organization
|
||||||
|
func (s *OrganizationsService) ListInstallations(ctx context.Context, org string, opts *ListOptions) (*OrganizationInstallations, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/installations", org)
|
||||||
|
|
||||||
|
u, err := addOptions(u, opts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := new(OrganizationInstallations)
|
||||||
|
resp, err := s.client.Do(ctx, req, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, resp, nil
|
||||||
|
}
|
||||||
63
vendor/github.com/google/go-github/v48/github/orgs_actions_allowed.go
generated
vendored
Normal file
63
vendor/github.com/google/go-github/v48/github/orgs_actions_allowed.go
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ActionsAllowed represents selected actions that are allowed.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions
|
||||||
|
type ActionsAllowed struct {
|
||||||
|
GithubOwnedAllowed *bool `json:"github_owned_allowed,omitempty"`
|
||||||
|
VerifiedAllowed *bool `json:"verified_allowed,omitempty"`
|
||||||
|
PatternsAllowed []string `json:"patterns_allowed,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a ActionsAllowed) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsAllowed gets the actions that are allowed in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization
|
||||||
|
func (s *OrganizationsService) GetActionsAllowed(ctx context.Context, org string) (*ActionsAllowed, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
actionsAllowed := new(ActionsAllowed)
|
||||||
|
resp, err := s.client.Do(ctx, req, actionsAllowed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionsAllowed, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditActionsAllowed sets the actions that are allowed in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-organization
|
||||||
|
func (s *OrganizationsService) EditActionsAllowed(ctx context.Context, org string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, actionsAllowed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
p := new(ActionsAllowed)
|
||||||
|
resp, err := s.client.Do(ctx, req, p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p, resp, nil
|
||||||
|
}
|
||||||
63
vendor/github.com/google/go-github/v48/github/orgs_actions_permissions.go
generated
vendored
Normal file
63
vendor/github.com/google/go-github/v48/github/orgs_actions_permissions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
package github
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ActionsPermissions represents a policy for repositories and allowed actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions
|
||||||
|
type ActionsPermissions struct {
|
||||||
|
EnabledRepositories *string `json:"enabled_repositories,omitempty"`
|
||||||
|
AllowedActions *string `json:"allowed_actions,omitempty"`
|
||||||
|
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a ActionsPermissions) String() string {
|
||||||
|
return Stringify(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-github-actions-permissions-for-an-organization
|
||||||
|
func (s *OrganizationsService) GetActionsPermissions(ctx context.Context, org string) (*ActionsPermissions, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions", org)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("GET", u, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
permissions := new(ActionsPermissions)
|
||||||
|
resp, err := s.client.Do(ctx, req, permissions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return permissions, resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditActionsPermissions sets the permissions policy for repositories and allowed actions in an organization.
|
||||||
|
//
|
||||||
|
// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-github-actions-permissions-for-an-organization
|
||||||
|
func (s *OrganizationsService) EditActionsPermissions(ctx context.Context, org string, actionsPermissions ActionsPermissions) (*ActionsPermissions, *Response, error) {
|
||||||
|
u := fmt.Sprintf("orgs/%v/actions/permissions", org)
|
||||||
|
req, err := s.client.NewRequest("PUT", u, actionsPermissions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
p := new(ActionsPermissions)
|
||||||
|
resp, err := s.client.Do(ctx, req, p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p, resp, nil
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue