vcsprovider

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: May 4, 2025 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package vcsprovider is responsible for VCS providers

templ: version: v0.3.865

Index

Constants

View Source
const (
	GithubAPIURL  = "https://api.github.com"
	GithubHTTPURL = "https://github.com"
)

Variables

This section is empty.

Functions

func RepoURL added in v0.3.19

func RepoURL(provider *VCSProvider, repo string) templ.SafeURL

func VCSIcon added in v0.3.19

func VCSIcon(provider *VCSProvider) templ.Component

Types

type CreateOptions

type CreateOptions struct {
	Organization organization.Name
	Name         string
	Kind         *vcs.Kind

	// Specify either token or github app install ID
	Token              *string
	GithubAppInstallID *int64
}

type ListOptions added in v0.3.17

type ListOptions struct {
	resource.PageOptions
	Organization organization.Name `schema:"organization_name"`
}

type Options

type Options struct {
	*internal.HostnameService
	*sql.DB
	*tfeapi.Responder
	logr.Logger
	vcs.Subscriber

	GithubAppService    *github.Service
	GithubHostname      string
	GitlabHostname      string
	SkipTLSVerification bool
	Authorizer          *authz.Authorizer
}

type Service

type Service struct {
	logr.Logger
	*authz.Authorizer

	*internal.HostnameService
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

func (a *Service) AddHandlers(r *mux.Router)

func (*Service) BeforeDeleteVCSProvider added in v0.1.8

func (a *Service) BeforeDeleteVCSProvider(hook func(context.Context, *VCSProvider) error)

func (*Service) Create added in v0.2.2

func (a *Service) Create(ctx context.Context, opts CreateOptions) (*VCSProvider, error)

func (*Service) Delete added in v0.2.2

func (a *Service) Delete(ctx context.Context, id resource.TfeID) (*VCSProvider, error)

func (*Service) Get added in v0.2.2

func (a *Service) Get(ctx context.Context, id resource.TfeID) (*VCSProvider, error)

func (*Service) GetVCSClient

func (a *Service) GetVCSClient(ctx context.Context, providerID resource.TfeID) (vcs.Client, error)

func (*Service) List added in v0.2.2

func (a *Service) List(ctx context.Context, organization organization.Name) ([]*VCSProvider, error)

func (*Service) ListAllVCSProviders added in v0.0.53

func (a *Service) ListAllVCSProviders(ctx context.Context) ([]*VCSProvider, error)

func (*Service) ListVCSProvidersByGithubAppInstall added in v0.1.14

func (a *Service) ListVCSProvidersByGithubAppInstall(ctx context.Context, installID int64) ([]*VCSProvider, error)

ListVCSProvidersByGithubAppInstall is unauthenticated: only for internal use.

func (*Service) Update added in v0.2.2

func (a *Service) Update(ctx context.Context, id resource.TfeID, opts UpdateOptions) (*VCSProvider, error)

type TFEOAuthClient added in v0.3.17

type TFEOAuthClient struct {
	ID                  resource.TfeID         `jsonapi:"primary,oauth-clients"`
	APIURL              string                 `jsonapi:"attribute" json:"api-url"`
	CallbackURL         string                 `jsonapi:"attribute" json:"callback-url"`
	ConnectPath         string                 `jsonapi:"attribute" json:"connect-path"`
	CreatedAt           time.Time              `jsonapi:"attribute" json:"created-at"`
	HTTPURL             string                 `jsonapi:"attribute" json:"http-url"`
	Key                 string                 `jsonapi:"attribute" json:"key"`
	RSAPublicKey        string                 `jsonapi:"attribute" json:"rsa-public-key"`
	Name                *string                `jsonapi:"attribute" json:"name"`
	Secret              string                 `jsonapi:"attribute" json:"secret"`
	ServiceProvider     TFEServiceProviderType `jsonapi:"attribute" json:"service-provider"`
	ServiceProviderName string                 `jsonapi:"attribute" json:"service-provider-display-name"`

	// Relations
	Organization *organization.TFEOrganization `jsonapi:"relationship" json:"organization"`
	OAuthTokens  []*TFEOAuthToken              `jsonapi:"relationship" json:"oauth-tokens"`
}

TFEOAuthClient represents a connection between an organization and a VCS provider.

type TFEOAuthClientCreateOptions added in v0.3.17

type TFEOAuthClientCreateOptions struct {
	// Type is a public field utilized by JSON:API to
	// set the resource type via the field tag.
	// It is not a user-defined value and does not need to be set.
	// https://jsonapi.org/format/#crud-creating
	Type string `jsonapi:"primary,oauth-clients"`

	// A display name for the OAuth Client.
	Name *string `jsonapi:"attribute" json:"name"`

	// Required: The base URL of your VCS provider's API.
	APIURL *string `jsonapi:"attribute" json:"api-url"`

	// Required: The homepage of your VCS provider.
	HTTPURL *string `jsonapi:"attribute" json:"http-url"`

	// Optional: The OAuth Client key.
	Key *string `jsonapi:"attribute" json:"key,omitempty"`

	// Optional: The token string you were given by your VCS provider.
	OAuthToken *string `jsonapi:"attribute" json:"oauth-token-string,omitempty"`

	// Optional: Private key associated with this vcs provider - only available for ado_server
	PrivateKey *string `jsonapi:"attribute" json:"private-key,omitempty"`

	// Optional: Secret key associated with this vcs provider - only available for ado_server
	Secret *string `jsonapi:"attribute" json:"secret,omitempty"`

	// Optional: RSAPublicKey the text of the SSH public key associated with your BitBucket
	// Server Application Link.
	RSAPublicKey *string `jsonapi:"attribute" json:"rsa-public-key,omitempty"`

	// Required: The VCS provider being connected with.
	ServiceProvider *TFEServiceProviderType `jsonapi:"attribute" json:"service-provider"`
}

TFEOAuthClientCreateOptions represents the options for creating an OAuth client.

type TFEOAuthToken added in v0.3.17

type TFEOAuthToken struct {
	ID                  resource.TfeID `jsonapi:"primary,oauth-tokens"`
	UID                 resource.TfeID `jsonapi:"attribute" json:"uid"`
	CreatedAt           time.Time      `jsonapi:"attribute" json:"created-at"`
	HasSSHKey           bool           `jsonapi:"attribute" json:"has-ssh-key"`
	ServiceProviderUser string         `jsonapi:"attribute" json:"service-provider-user"`

	// Relations
	OAuthClient *TFEOAuthClient `jsonapi:"relationship" json:"oauth-client"`
}

TFEOAuthToken represents a VCS configuration including the associated OAuth token

type TFEServiceProviderType added in v0.3.17

type TFEServiceProviderType string

TFEServiceProviderType represents a VCS type.

const (
	ServiceProviderAzureDevOpsServer   TFEServiceProviderType = "ado_server"
	ServiceProviderAzureDevOpsServices TFEServiceProviderType = "ado_services"
	ServiceProviderBitbucket           TFEServiceProviderType = "bitbucket_hosted"
	// Bitbucket Server v5.4.0 and above
	ServiceProviderBitbucketServer TFEServiceProviderType = "bitbucket_server"
	// Bitbucket Server v5.3.0 and below
	ServiceProviderBitbucketServerLegacy TFEServiceProviderType = "bitbucket_server_legacy"
	ServiceProviderGithub                TFEServiceProviderType = "github"
	ServiceProviderGithubEE              TFEServiceProviderType = "github_enterprise"
	ServiceProviderGitlab                TFEServiceProviderType = "gitlab_hosted"
	ServiceProviderGitlabCE              TFEServiceProviderType = "gitlab_community_edition"
	ServiceProviderGitlabEE              TFEServiceProviderType = "gitlab_enterprise_edition"
)

List of available VCS types.

type Table added in v0.3.17

type Table struct {
	Actions func(vcsProviderID resource.TfeID) templ.Component
}

func (Table) Header added in v0.3.17

func (t Table) Header() templ.Component

func (Table) Row added in v0.3.17

func (t Table) Row(provider *VCSProvider) templ.Component

type UpdateOptions added in v0.1.11

type UpdateOptions struct {
	Token *string
	Name  string
}

type VCSProvider

type VCSProvider struct {
	ID           resource.TfeID
	Name         string
	CreatedAt    time.Time
	Organization organization.Name // name of OTF organization
	Hostname     string            // hostname of github/gitlab etc

	Kind  vcs.Kind // github/gitlab etc. Not necessary if GithubApp is non-nil.
	Token *string  // personal access token.

	GithubApp *github.InstallCredentials // mutually exclusive with Token.
	// contains filtered or unexported fields
}

VCSProvider provides authenticated access to a VCS.

func (*VCSProvider) LogValue

func (t *VCSProvider) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (*VCSProvider) NewClient

func (t *VCSProvider) NewClient() (vcs.Client, error)

func (*VCSProvider) String

func (t *VCSProvider) String() string

String provides a human meaningful description of the vcs provider, using the name if set; otherwise a name is constructed using both the underlying cloud kind and the auth kind.

func (*VCSProvider) Update added in v0.1.11

func (t *VCSProvider) Update(opts UpdateOptions) error

Jump to

Keyboard shortcuts

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