goscm

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 15 Imported by: 0

README

goscm

Notes

OpenAPI Spec: https://stagex.cloudogu.com/scm/openapi

Tests

In order for tests to run, a valid API key must be supplied via the environment variable SCM_BEARER_TOKEN.

Tests are run utilizing: https://stagex.cloudogu.com/scm

Disclaimer

This go client for SCM-Manager is not complete and therefore does not support all features from SCM-Manager. It simply provides some basic functions which can be used by third party applications.

The client is in a beta stage. It is possible that the API will change.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventNotSpecifiedToParse  = errors.New("no Event specified to parse")
	ErrInvalidHTTPMethod         = errors.New("invalid HTTP Method")
	ErrMissingScmEventHeader     = errors.New("missing X-SCM-PushEvent Header")
	ErrMissingScmSignatureHeader = errors.New("missing X-SCM-Signature Header")
	ErrEventNotFound             = errors.New("event not defined to be parsed")
	ErrParsingPayload            = errors.New("error parsing payload")
	ErrSecretVerification        = errors.New("token verification error")
	ErrHMACVerificationFailed    = errors.New("HMAC verification failed")
)
View Source
var Options = WebhookOptions{}

Functions

func LoginUser

func LoginUser(baseUrl string, username string, password string) error

LoginUser attempts to use the user data to log in. This can be used to initialize a user profile that is authorized to but was never logged in before.

Types

type ArgoCDWebhook

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

func New

func New(options ...Option) (*ArgoCDWebhook, error)

func (ArgoCDWebhook) Parse

func (h ArgoCDWebhook) Parse(r *http.Request, events ...Event) (interface{}, error)

type Author

type Author struct {
	Name string `json:"name"`
	Mail string `json:"mail"`
}

type Branch

type Branch struct {
	Name           string        `json:"name"`
	DefaultBranch  bool          `json:"defaultBranch"`
	Revision       string        `json:"revision"`
	Stale          bool          `json:"stale"`
	LastCommitDate string        `json:"lastCommitDate,omitempty"`
	LastCommitter  LastCommitter `json:"lastCommitter"`
}

type BranchContainer

type BranchContainer struct {
	Embedded struct {
		Branches []Branch `json:"branches"`
	} `json:"_embedded"`
}

type Changeset

type Changeset struct {
	Id          string `json:"id"`
	Description string `json:"description"`
	Date        string `json:"date"`
	Author      Author `json:"author"`
}

type ChangesetContainer

type ChangesetContainer struct {
	Page      int `json:"page"`
	PageTotal int `json:"pageTotal"`
	Embedded  struct {
		Changesets []Changeset `json:"changesets"`
	} `json:"_embedded"`
}

type ChangesetListFilter

type ChangesetListFilter struct {
	Limit int `json:"limit"`
}

type Client

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

func NewClient

func NewClient(baseUrl string, apiKey string) (*Client, error)

func (*Client) AddUserToGroup

func (c *Client) AddUserToGroup(userName string, groupName string) error

func (*Client) CopyGroupMembershipsFromOtherUser

func (c *Client) CopyGroupMembershipsFromOtherUser(userName string, templateUserName string) error

func (*Client) CreateGroup

func (c *Client) CreateGroup(name string, description string) error

func (*Client) CreateRepo

func (c *Client) CreateRepo(repo Repository) (Repository, error)

CreateRepo Create new repository

func (*Client) CreateUser

func (c *Client) CreateUser(userData UserData) error

func (*Client) DeleteGroup

func (c *Client) DeleteGroup(groupName string) error

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(namespace string, name string) error

DeleteRepo Delete repository

func (*Client) DeleteUser

func (c *Client) DeleteUser(name string) error

func (*Client) DeleteUserAndGroupMembership

func (c *Client) DeleteUserAndGroupMembership(name string) error

func (*Client) DeleteUserFromAllGroups

func (c *Client) DeleteUserFromAllGroups(userName string) error

func (*Client) DeleteUserFromGroup

func (c *Client) DeleteUserFromGroup(userName string, groupName string) error

func (*Client) GetChangeset

func (c *Client) GetChangeset(namespace string, name string, id string) (Changeset, error)

GetChangeset Get a single repository changeset by id

func (*Client) GetContent

func (c *Client) GetContent(namespace string, name string, revision string, path string) (string, *http.Response, error)

GetContent Get file content for revision and path

func (*Client) GetContentForDefaultBranch

func (c *Client) GetContentForDefaultBranch(namespace string, name string, path string) (string, *http.Response, error)

GetContentForDefaultBranch Get file content for latest revision on default branch and path

func (*Client) GetDefaultBranch

func (c *Client) GetDefaultBranch(namespace string, name string) (Branch, error)

GetDefaultBranch Get the default branch of the repository

func (*Client) GetGroup

func (c *Client) GetGroup(groupName string) (Group, error)

GetGroup returns the Group with name groupName

func (*Client) GetGroups

func (c *Client) GetGroups() (GroupContainer, error)

GetGroups returns all existing Groups

func (*Client) GetHeadChangesetForBranch

func (c *Client) GetHeadChangesetForBranch(namespace string, name string, branch string) (Changeset, error)

GetHeadChangesetForBranch Get head changeset for repository by branch

func (*Client) GetIndex

func (c *Client) GetIndex() (*Index, error)

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(namespace string, name string, id string) (PullRequest, error)

GetPullRequest Get single pull request for repository

func (*Client) GetRepo

func (c *Client) GetRepo(namespace string, name string) (Repository, error)

GetRepo Get single repository by namespace and name

func (*Client) GetRepoBranch

func (c *Client) GetRepoBranch(namespace string, name string, branchName string) (Branch, error)

GetRepoBranch Get a single branch of the repository by branch name

func (*Client) ListChangesets

func (c *Client) ListChangesets(namespace string, name string, branch string, filter *ChangesetListFilter) (ChangesetContainer, error)

ListChangesets List all changesets for repository by branch

func (*Client) ListPullRequests

func (c *Client) ListPullRequests(namespace string, name string, filter *PullRequestListFilter) (PullRequestContainer, error)

ListPullRequests List all pull requests for repository

func (*Client) ListRepoBranches

func (c *Client) ListRepoBranches(namespace string, name string) (BranchContainer, error)

ListRepoBranches List all branches of the repository

func (*Client) ListRepos

func (c *Client) ListRepos(filter *RepoListFilter) (RepoContainer, error)

ListRepos List all repositories which the user may see

func (*Client) ListReposByNamespace

func (c *Client) ListReposByNamespace(namespace string, filter *RepoListFilter) (RepoContainer, error)

ListReposByNamespace List all repositories which the user may see by namespace

func (*Client) NewChangesetListFilter

func (c *Client) NewChangesetListFilter() *ChangesetListFilter

func (*Client) NewPullRequestListFilter

func (c *Client) NewPullRequestListFilter() *PullRequestListFilter

func (*Client) NewRepoListFilter

func (c *Client) NewRepoListFilter() *RepoListFilter

func (*Client) SetHttpClient

func (c *Client) SetHttpClient(httpClient *http.Client)

type ErrorResponse

type ErrorResponse struct {
	TransactionId string `json:"transactionId,omitempty"`
	ErrorCode     string `json:"errorCode,omitempty"`
	Context       []struct {
		Type string `json:"type,omitempty"`
		Id   string `json:"id,omitempty"`
	} `json:"context,omitempty"`
	Message            string `json:"message,omitempty"`
	AdditionalMessages []struct {
		Key     string `json:"key,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"additionalMessages,omitempty"`
	Violations []struct {
		Path    string `json:"path,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"violations,omitempty"`
	Url string `json:"url,omitempty"`
}

func (*ErrorResponse) String

func (e *ErrorResponse) String() string

type Event

type Event string
const (
	PushEvent Event = "Push"
)

type Group

type Group struct {
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	LastModified string   `json:"lastModified,omitempty"`
	Type         string   `json:"type"`
	Members      []string `json:"members"`
	External     bool     `json:"external"`
}

type GroupContainer

type GroupContainer struct {
	Page      int `json:"page"`
	PageTotal int `json:"pageTotal"`
	Embedded  struct {
		Groups []Group `json:"groups"`
	} `json:"_embedded"`
}

type Index

type Index struct {
	Version        string `json:"version"`
	InstanceId     string `json:"instanceId"`
	Initialization string `json:"initialization"`
	Links          struct {
		Empty bool `json:"empty"`
	} `json:"_links"`
	Embedded struct {
		Empty bool `json:"empty"`
	} `json:"_embedded"`
}

type LastCommitter

type LastCommitter struct {
	Name string `json:"name"`
	Mail string `json:"mail"`
}
type Links struct {
	ProtocolUrl []ProtocolUrl `json:"protocol,omitempty"`
}

type Option

type Option func(*ArgoCDWebhook) error

type ProtocolUrl

type ProtocolUrl struct {
	Name string `json:"name,omitempty"`
	Href string `json:"href,omitempty"`
}

type PullRequest

type PullRequest struct {
	Id           string `json:"id"`
	Title        string `json:"title"`
	Description  string `json:"description"`
	Source       string `json:"source"`
	Target       string `json:"target"`
	Status       string `json:"status"`
	CreationDate string `json:"creationDate,omitempty"`
	CloseDate    string `json:"closeDate,omitempty"`
}

type PullRequestContainer

type PullRequestContainer struct {
	Page      int `json:"page"`
	PageTotal int `json:"pageTotal"`
	Embedded  struct {
		PullRequests []PullRequest `json:"pullRequests"`
	} `json:"_embedded"`
}

type PullRequestListFilter

type PullRequestListFilter struct {
	Status string `json:"status"`
	Limit  int    `json:"limit"`
}

type PushEventPayload

type PushEventPayload struct {
	HTMLURL string `json:"HTMLURL"`
	Branch  Branch `json:"branch"`
}

type RepoContainer

type RepoContainer struct {
	Page      int `json:"page"`
	PageTotal int `json:"pageTotal"`
	Embedded  struct {
		Repositories []Repository `json:"repositories"`
	} `json:"_embedded"`
}

type RepoListFilter

type RepoListFilter struct {
	Limit        int  `json:"limit"`
	ShowArchived bool `json:"showArchived"`
}

type Repository

type Repository struct {
	Namespace    string `json:"namespace"`
	Name         string `json:"name"`
	Type         string `json:"type"`
	Description  string `json:"description"`
	Contact      string `json:"contact"`
	Archived     bool   `json:"archived"`
	LastModified string `json:"lastModified,omitempty"`
	Links        Links  `json:"_links,omitempty"`
}

type UserData

type UserData struct {
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
	Mail        string `json:"mail"`
	External    bool   `json:"external"`
	Password    string `json:"password"`
	Active      bool   `json:"active"`
}

type WebhookOptions

type WebhookOptions struct{}

func (WebhookOptions) Secret

func (WebhookOptions) Secret(secret string) Option

Jump to

Keyboard shortcuts

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