Documentation ¶
Index ¶
- Constants
- func FetchCloudSecret(name string) (string, error)
- func GetProjectID(g *GitlabClient, name string) (string, error)
- type BitbucketClient
- func (b *BitbucketClient) CreateRepository(localName string) (string, error)
- func (b *BitbucketClient) DeleteObsoleteRepos() error
- func (b *BitbucketClient) DeleteRepositories(names ...string) error
- func (b *BitbucketClient) RemoteURL(_ int, name string) string
- func (b *BitbucketClient) SyncURL(name string) string
- func (b *BitbucketClient) Type() string
- type GitProvider
- type GitlabClient
- func (g *GitlabClient) CreateRepository(name string) (string, error)
- func (g *GitlabClient) DeleteObsoleteRepos() error
- func (g *GitlabClient) DeleteRepoByID(ids ...string) error
- func (g *GitlabClient) DeleteRepositories(names ...string) error
- func (g *GitlabClient) GetObsoleteRepos() ([]string, error)
- func (g *GitlabClient) RemoteURL(port int, name string) string
- func (g *GitlabClient) SyncURL(name string) string
- func (g *GitlabClient) Type() string
- type LocalProvider
- func (l *LocalProvider) CreateRepository(name string) (string, error)
- func (l *LocalProvider) DeleteObsoleteRepos() error
- func (l *LocalProvider) DeleteRepositories(...string) error
- func (l *LocalProvider) RemoteURL(port int, name string) string
- func (l *LocalProvider) SyncURL(name string) string
- func (l *LocalProvider) Type() string
Constants ¶
const (
// GitUser is the user for all Git providers.
GitUser = "config-sync-ci-bot"
)
const (
// PrivateSSHKey is secret name of the private SSH key stored in the Cloud Secret Manager.
PrivateSSHKey = "config-sync-ci-ssh-private-key"
)
Variables ¶
This section is empty.
Functions ¶
func FetchCloudSecret ¶
FetchCloudSecret fetches secret from Google Cloud Secret Manager.
func GetProjectID ¶
func GetProjectID(g *GitlabClient, name string) (string, error)
GetProjectID is a helper function for DeleteRepositories since Gitlab API only deletes by id
Types ¶
type BitbucketClient ¶
type BitbucketClient struct {
// contains filtered or unexported fields
}
BitbucketClient is the client that calls the Bitbucket REST APIs.
func (*BitbucketClient) CreateRepository ¶
func (b *BitbucketClient) CreateRepository(localName string) (string, error)
CreateRepository calls the POST API to create a remote repository on Bitbucket. The remote repo name is unique with a prefix of the local name.
func (*BitbucketClient) DeleteObsoleteRepos ¶
func (b *BitbucketClient) DeleteObsoleteRepos() error
DeleteObsoleteRepos deletes all repos that were created more than 24 hours ago.
func (*BitbucketClient) DeleteRepositories ¶
func (b *BitbucketClient) DeleteRepositories(names ...string) error
DeleteRepositories calls the DELETE API to delete all remote repositories on Bitbucket. It deletes multiple repos in a single function in order to reuse the access_token.
func (*BitbucketClient) RemoteURL ¶
func (b *BitbucketClient) RemoteURL(_ int, name string) string
RemoteURL returns the Git URL for the Bitbucket repository. name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync.
func (*BitbucketClient) SyncURL ¶
func (b *BitbucketClient) SyncURL(name string) string
SyncURL returns a URL for Config Sync to sync from. name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync. The Bitbucket Rest API doesn't allow slash in the repository name, so slash has to be replaced with dash in the name.
func (*BitbucketClient) Type ¶
func (b *BitbucketClient) Type() string
Type returns the provider type.
type GitProvider ¶
type GitProvider interface { Type() string // RemoteURL returns remote URL of the repository. // It is used to set the url for the remote origin using `git remote add origin <REMOTE_URL>. // For the testing git-server, RemoteURL uses localhost and forwarded port, while SyncURL uses the DNS. // For other git providers, RemoteURL should be the same as SyncURL. // name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync. RemoteURL(port int, name string) string // SyncURL returns the git repository URL for Config Sync to sync from. // name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync. SyncURL(name string) string CreateRepository(name string) (string, error) DeleteRepositories(names ...string) error DeleteObsoleteRepos() error }
GitProvider is an interface for the remote Git providers.
func NewGitProvider ¶
func NewGitProvider(t testing.NTB, provider string) GitProvider
NewGitProvider creates a GitProvider for the specific provider type.
type GitlabClient ¶
type GitlabClient struct {
// contains filtered or unexported fields
}
GitlabClient is the client that will call Gitlab REST APIs.
func (*GitlabClient) CreateRepository ¶
func (g *GitlabClient) CreateRepository(name string) (string, error)
CreateRepository calls the POST API to create a project/repository on Gitlab. The remote repo name is unique with a prefix of the local name.
func (*GitlabClient) DeleteObsoleteRepos ¶
func (g *GitlabClient) DeleteObsoleteRepos() error
DeleteObsoleteRepos deletes all projects that has been inactive more than 24 hours
func (*GitlabClient) DeleteRepoByID ¶
func (g *GitlabClient) DeleteRepoByID(ids ...string) error
DeleteRepoByID calls the DELETE API to delete the list of project id in Gitlab.
func (*GitlabClient) DeleteRepositories ¶
func (g *GitlabClient) DeleteRepositories(names ...string) error
DeleteRepositories calls the DELETE API to delete the list of project name in Gitlab.
func (*GitlabClient) GetObsoleteRepos ¶
func (g *GitlabClient) GetObsoleteRepos() ([]string, error)
GetObsoleteRepos is a helper function to get all project ids that has been inactive more than 24 hours
func (*GitlabClient) RemoteURL ¶
func (g *GitlabClient) RemoteURL(port int, name string) string
RemoteURL returns the Git URL for the Gitlab project repository.
func (*GitlabClient) SyncURL ¶
func (g *GitlabClient) SyncURL(name string) string
SyncURL returns a URL for Config Sync to sync from.
type LocalProvider ¶
type LocalProvider struct{}
LocalProvider refers to the test git-server running on the same test cluster.
func (*LocalProvider) CreateRepository ¶
func (l *LocalProvider) CreateRepository(name string) (string, error)
CreateRepository returns the local name as the remote repo name. It is a no-op for the test git-server because all repos are initialized at once in git-server.go.
func (*LocalProvider) DeleteObsoleteRepos ¶
func (l *LocalProvider) DeleteObsoleteRepos() error
DeleteObsoleteRepos is a no-op for the test git-server because the git-server will be deleted after the test.
func (*LocalProvider) DeleteRepositories ¶
func (l *LocalProvider) DeleteRepositories(...string) error
DeleteRepositories is a no-op for the test git-server because the git-server will be deleted after the test.
func (*LocalProvider) RemoteURL ¶
func (l *LocalProvider) RemoteURL(port int, name string) string
RemoteURL returns the Git URL for connecting to the test git-server. name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync.
func (*LocalProvider) SyncURL ¶
func (l *LocalProvider) SyncURL(name string) string
SyncURL returns a URL for Config Sync to sync from. name refers to the repo name in the format of <NAMESPACE>/<NAME> of RootSync|RepoSync.