identifier

package
v0.0.0-...-379c407 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const GitHubNoReplyEmailSuffix = "@users.noreply.github.com"
View Source
const GithubLoginAttrID string = "C-6934211695879389211"
View Source
const LarkCompany = "PingCAP"
View Source
const LarkContactGitHubLoginsCacheKey = "lark-contact-github-logins"

Variables

This section is empty.

Functions

func AutoImportProfile

func AutoImportProfile(
	log *logrus.Entry, ctx *Ctx, db *gorm.DB, dataSource *gorm.DB,
	gc *GitHubClient, locationClient *LocationClient, employeeManager *EmployeeManager, memCache *cache.Cache,
)

AutoImportProfile - Import GitHub user info from devstats and fetch their public profile information.

func EnsureStructure

func EnsureStructure(log *logrus.Entry, db *gorm.DB)

EnsureStructure is used to ensure the table structure existed in the database.

func OutputGitHubUserToJSON

func OutputGitHubUserToJSON(log *logrus.Entry, ctx *Ctx, db *gorm.DB)

Types

type Ctx

type Ctx struct {
	IDDbDialect string // From ID_DB_DIALECT, default "mysql"
	IDDbHost    string // From ID_DB_HOST, default "localhost"
	IDDbPort    int    // From ID_DB_PORT, default "3306"
	IDDbName    string // From ID_DB_NAME, default "sortinghat"
	IDDbUser    string // From ID_DB_USER, default "root"
	IDDbPass    string // From ID_DB_PASS, default "password"
	IDDbSSL     string // From ID_DB_SSL, default "disable"

	SkipBots                 bool // From SKIP_BOTS, default false
	SkipAutoImportProfile    bool // From SKIP_AUTO_IMPORT_PROFILE, default false.
	SkipOutputGitHubUserJSON bool // From SKIP_OUTPUT_GITHUB_USER_JSON, default false.

	GitHubUsersJSONSourcePath string // From ID_GITHUB_USERS_JSON_SOURCE_PATH
	GitHubUsersJSONOutputPath string // From ID_GITHUB_USERS_JSON_OUTPUT_PATH
	CountryCodesFilePath      string // From ID_COUNTRY_CODES_FILE_PATH, default "configs/shared/countries.csv"
	CacheFilePath             string // From ID_CACHE_FILE_PATH, default "~/dump.out"
	OrganizationsFilePath     string // From ID_ORGANIZATION_CONFIG_YAML, default "configs/shared/organizations.yaml"

	GoogleMapAPIKey string // From GOOGLE_MAP_API_KEY

	LarkAPIBaseURL string // From LARK_API_BASE_URL
	LarkAppID      string // From LARK_APP_ID
	LarkAppSecret  string // From LARK_APP_SECRET

	S3UploadGitHubUsersJSON    bool   // From S3_UPLOAD_GITHUB_USERS_JSON
	S3GitHubUsersJSONBucket    string // From S3_GITHUB_USERS_JSON_BUCKET
	S3GitHubUsersJSONBucketKey string // From S3_GITHUB_USERS_JSON_BUCKET_KEY
	AwsAccessKeyID             string // From AWS_ACCESS_KEY_ID
	AwsSecretAccessKey         string // From AWS_SECRET_ACCESS_KEY
	AwsDefaultRegion           string // From AWS_DEFAULT_REGION

	DevstatsAPIBaseURL string // From DEVSTATS_API_BASE_URL

	lib.Ctx
}

func (*Ctx) Init

func (c *Ctx) Init() error

type EmployeeManager

type EmployeeManager struct {
	// contains filtered or unexported fields
}

func (*EmployeeManager) Init

func (m *EmployeeManager) Init(ctx Ctx, log *logrus.Entry, memCache *cache.Cache) error

func (*EmployeeManager) IsEmployeeLogin

func (m *EmployeeManager) IsEmployeeLogin(githubLogin string) bool

IsEmployeeLogin used to determine whether the given GitHub login is the employee's login

func (*EmployeeManager) PrepareGitHubLogins

func (m *EmployeeManager) PrepareGitHubLogins() error

PrepareGitHubLogins - Get GitHub login from Lark contact.

type EnrollmentWithOrg

type EnrollmentWithOrg struct {
	OrgName   string
	StartDate time.Time
	EndDate   time.Time
}

type GitHubClient

type GitHubClient struct {
	// contains filtered or unexported fields
}

func (*GitHubClient) GetRepository

func (c *GitHubClient) GetRepository(owner, repo string) (*github.Repository, *github.Response, error)

func (*GitHubClient) GetUserByID

func (c *GitHubClient) GetUserByID(id int64) (*github.User, *github.Response, error)

func (*GitHubClient) GetUserByLogin

func (c *GitHubClient) GetUserByLogin(login string) (*github.User, *github.Response, error)

func (*GitHubClient) Init

func (c *GitHubClient) Init(ctx *Ctx, log *logrus.Entry, cache *cache.Cache) error

type GitHubGetRepositoryResult

type GitHubGetRepositoryResult struct {
	Repository github.Repository
	Err        string
}

type GitHubGetUserResult

type GitHubGetUserResult struct {
	User github.User
	Err  string
}

type GitHubUserFromJSON

type GitHubUserFromJSON struct {
	Login string `json:"login"`
	// Email use ! instead of @ for email encoding.
	Email string `json:"email"`
	// Affiliation format: "YouTube < 2016-10-01, Google",
	Affiliation string `json:"affiliation,omitempty"`
	// Source valid values: "notfound": -20, "domain": -10, "": 0, "config": 10, "manual": 20, "user_manual": 30, "user": 40
	Source    string   `json:"source"`
	Name      string   `json:"name"`
	CountryID *string  `json:"country_id,omitempty"`
	Sex       *string  `json:"sex,omitempty"`
	SexProb   *float64 `json:"sex_prob,omitempty"`
	Tz        *string  `json:"tz,omitempty"`
	Age       *int     `json:"age,omitempty"`
}

GitHubUserFromJSON - single GitHub user entry from cncf/gitdm `github_users.json` JSON.

type LocationCacheEntry

type LocationCacheEntry struct {
	FormattedAddress string
	CountryName      string
	CountryCode      string
}

type LocationClient

type LocationClient struct {
	// contains filtered or unexported fields
}

LocationClient - used to get formatted location address and country code.

func (*LocationClient) FormattedLocation

func (l *LocationClient) FormattedLocation(location string) (string, string, string, error)

func (*LocationClient) Init

func (l *LocationClient) Init(ctx *Ctx, log *logrus.Entry, memCache *cache.Cache) error

type OrgConfig

type OrgConfig struct {
	OrgMappings []OrgMapping `yaml:"organizations"`
}

OrgConfig is the data structure of organizations.yaml file.

type OrgMapping

type OrgMapping struct {
	Name     string                 `yaml:"name"`
	Fullname string                 `yaml:"fullname"`
	Type     model.OrganizationType `yaml:"type"`
	Website  string                 `yaml:"website"`
	Patterns []string               `yaml:"patterns"`
	Domains  []model.OrgDomain      `yaml:"domains"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL