accountsync

package module
v0.0.0-...-5a5b320 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 13 Imported by: 0

README

account-sync

Syncing your account to .... SOMEWHERE!

💥 🚫 This project does not work (yet) and has many warts 🚫 💥

TODO

  • finish basic functionality for public repos
  • load testing and memory profiling and such
  • plug in logrus
  • plug in [go-metrics](https://github.cocd /var/www/localhost/htdocs/ mkdir -p example cd example echo '' > index.phpm/@rockyspade/go-metrics)
  • tests tests tests tests tests

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EncryptionKeyFlag = &cli.StringFlag{
		Name:   "k, encryption-key",
		Value:  "",
		EnvVar: "TRAVIS_ACCOUNT_SYNC_ENCRYPTION_KEY",
	}
	DatabaseURLFlag = &cli.StringFlag{
		Name:   "d, database-url",
		Value:  "",
		EnvVar: "TRAVIS_ACCOUNT_SYNC_DATABASE_URL",
	}
	GithubUsernamesFlag = &cli.StringSliceFlag{
		Name:   "u, github-usernames",
		Value:  &cli.StringSlice{},
		EnvVar: "TRAVIS_ACCOUNT_SYNC_GITHUB_USERNAMES",
	}
	OrganizationsRepositoriesLimitFlag = &cli.IntFlag{
		Name:   "organizations-repositories-limit",
		Value:  1000,
		EnvVar: "TRAVIS_ACCOUNT_SYNC_ORGANIZATIONS_REPOSITORIES_LIMIT",
	}
	RepositoriesStartPageFlag = &cli.IntFlag{
		Name:   "repositories-start-page",
		Value:  1,
		EnvVar: "TRAVIS_ACCOUNT_SYNC_REPOSITORIES_START_PAGE",
	}
	SyncTypesFlag = &cli.StringSliceFlag{
		Name:   "T, sync-types",
		Value:  &cli.StringSlice{"public"},
		EnvVar: "TRAVIS_ACCOUNT_SYNC_TYPES",
	}
	SyncCacheSizeFlag = &cli.IntFlag{
		Name:   "sync-cache-size",
		Value:  64,
		EnvVar: "TRAVIS_ACCOUNT_SYNC_CACHE_SIZE",
	}

	Flags = []cli.Flag{
		*EncryptionKeyFlag,
		*DatabaseURLFlag,
		*GithubUsernamesFlag,
		*OrganizationsRepositoriesLimitFlag,
		*RepositoriesStartPageFlag,
		*SyncTypesFlag,
		*SyncCacheSizeFlag,
	}
)
View Source
var (
	VersionString = "0.1.0"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	EncryptionKey                  string   `cfg:"encryption-key"` // TODO: do something with these tags
	DatabaseURL                    string   `cfg:"database-url"`
	GithubUsernames                []string `cfg:"github-usernames"`
	OrganizationsRepositoriesLimit int      `cfg:"organizations-repositories-limit"`
	RepositoriesStartPage          int      `cfg:"repositories-start-page"`
	SyncTypes                      []string `cfg:"sync-types"`
	SyncCacheSize                  int      `cfg:"sync-cache-size"`
}

func NewConfig

func NewConfig(c *cli.Context) *Config

func (*Config) Validate

func (cfg *Config) Validate() error

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(databaseURL string, syncCacheSize int) (*DB, error)

func (*DB) FindOrgByGithubID

func (db *DB) FindOrgByGithubID(ghOrgID int) (*Organization, error)

func (*DB) FindUserByGithubID

func (db *DB) FindUserByGithubID(ghUserID int) (*User, error)

type Organization

type Organization struct {
	ID sql.NullInt64 `db:"id"`

	Name      sql.NullString `db:"name"`
	Login     sql.NullString `db:"login"`
	GithubID  sql.NullInt64  `db:"github_id"`
	CreatedAt *time.Time     `db:"created_at"`
	UpdatedAt *time.Time     `db:"updated_at"`
	AvatarURL sql.NullString `db:"avatar_url"`
	Location  sql.NullString `db:"location"`
	Email     sql.NullString `db:"email"`
	Company   sql.NullString `db:"company"`
	Homepage  sql.NullString `db:"homepage"`
}

type OrganizationSyncer

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

func NewOrganizationSyncer

func NewOrganizationSyncer(db *DB, cfg *Config) *OrganizationSyncer

func (*OrganizationSyncer) Sync

func (osync *OrganizationSyncer) Sync(user *User, client *github.Client) error

type Owner

type Owner struct {
	Type         string
	User         *User
	Organization *Organization
}

func (*Owner) Key

func (o *Owner) Key() string

func (*Owner) String

func (o *Owner) String() string

type OwnerRepositoriesSyncer

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

func NewOwnerRepositoriesSyncer

func NewOwnerRepositoriesSyncer(db *DB, cfg *Config) *OwnerRepositoriesSyncer

func (*OwnerRepositoriesSyncer) Sync

func (ors *OwnerRepositoriesSyncer) Sync(user *User, client *github.Client) error

type RepositoriesSyncer

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

func NewRepositoriesSyncer

func NewRepositoriesSyncer(db *DB, cfg *Config) *RepositoriesSyncer

func (*RepositoriesSyncer) Sync

func (rs *RepositoriesSyncer) Sync(owner *Owner, user *User, client *github.Client) ([]*int, error)

type Repository

type Repository struct {
	ID sql.NullInt64 `db:"id"`

	Active              sql.NullBool   `db:"active"`
	CreatedAt           *time.Time     `db:"created_at"`
	DefaultBranch       sql.NullString `db:"default_branch"`
	Description         sql.NullString `db:"description"`
	GithubID            sql.NullInt64  `db:"github_id"`
	GithubLanguage      sql.NullString `db:"github_language"`
	LastBuildDuration   sql.NullInt64  `db:"last_build_duration"`
	LastBuildFinishedAt *time.Time     `db:"last_build_finished_at"`
	LastBuildID         sql.NullInt64  `db:"last_build_id"`
	LastBuildNumber     sql.NullString `db:"last_build_number"`
	LastBuildState      sql.NullString `db:"last_build_state"`
	LastBuildStartedAt  *time.Time     `db:"last_build_started_at"`
	LastSync            *time.Time     `db:"last_sync"`
	Name                sql.NullString `db:"name"`
	NextBuildNumber     sql.NullString `db:"next_build_number"`
	OwnerEmail          sql.NullString `db:"owner_email"`
	OwnerID             sql.NullInt64  `db:"owner_id"`
	OwnerName           sql.NullString `db:"owner_name"`
	OwnerType           sql.NullString `db:"owner_type"`
	Private             sql.NullBool   `db:"private"`
	Settings            sql.NullString `db:"settings"`
	URL                 sql.NullString `db:"url"`
	UpdatedAt           *time.Time     `db:"updated_at"`
}

func (*Repository) UpdateFromGithubRepository

func (repo *Repository) UpdateFromGithubRepository(ghRepo *github.Repository)

type Syncer

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

func NewSyncer

func NewSyncer(cfg *Config) (*Syncer, error)

func (*Syncer) Sync

func (syncer *Syncer) Sync()

type User

type User struct {
	ID sql.NullInt64 `db:"id"`

	CreatedAt        *time.Time     `db:"created_at"`
	Education        sql.NullBool   `db:"education"`
	Email            sql.NullString `db:"email"`
	GithubID         sql.NullInt64  `db:"github_id"`
	GithubOauthToken sql.NullString `db:"github_oauth_token"`
	GithubScopesYAML sql.NullString `db:"github_scopes"`
	GravatarID       sql.NullString `db:"gravatar_id"`
	IsAdmin          sql.NullBool   `db:"is_admin"`
	IsSyncing        sql.NullBool   `db:"is_syncing"`
	Locale           sql.NullString `db:"locale"`
	Login            sql.NullString `db:"login"`
	Name             sql.NullString `db:"name"`
	SyncedAt         *time.Time     `db:"synced_at"`
	UpdatedAt        *time.Time     `db:"updated_at"`

	GithubScopes  []string
	Organizations []*Organization
}

func (*User) Hydrate

func (user *User) Hydrate() error

func (*User) HydrateOrganizations

func (user *User) HydrateOrganizations(db *DB) error

type UserInfoSyncer

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

func NewUserInfoSyncer

func NewUserInfoSyncer(db *DB, cfg *Config) *UserInfoSyncer

func (*UserInfoSyncer) Sync

func (uis *UserInfoSyncer) Sync(user *User, client *github.Client) error

type UserSyncError

type UserSyncError struct {
	TravisLogin    string
	TravisGithubID int64
	GithubLogin    string
	GithubID       int64
}

func (*UserSyncError) Error

func (err *UserSyncError) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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