cmd

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2024 F. Hoffmann-La Roche AG

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 F. Hoffmann-La Roche AG

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2024 F. Hoffmann-La Roche AG

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

func GetBranchesAndTagsFromRemote

func GetBranchesAndTagsFromRemote(repository *git.Repository, remoteName string, listOptions *git.ListOptions, sourceRepository string) ([]string, []string, error)

GetBranchesAndTagsFromRemote returns list of branches and tags present in remoteName of repository.

func GetCloneOptions

func GetCloneOptions(source string, sourceAuth Authentication) *git.CloneOptions

GetCloneOptions returns clone options for source repository.

func GetDestinationAuth

func GetDestinationAuth(destAuth Authentication) *githttp.BasicAuth

GetDestionationAuth returns authentication struct for destination git repository.

func GetFetchOptions

func GetFetchOptions(refSpec string, sourceAuth Authentication) *git.FetchOptions

GetFetchOptions returns fetch options for source repository.

func GetListOptions

func GetListOptions(sourceAuth Authentication) *git.ListOptions

GetListOptions returns list options for source repository.

func GitFetchBranches added in v0.0.2

func GitFetchBranches(sourceRemote *git.Remote, sourceAuthentication Authentication, repositoryName string) error

GitFetchBranches fetches all branches and is retried in case of error.

func GitPlainClone added in v0.0.2

func GitPlainClone(gitDirectory string, cloneOptions *git.CloneOptions, repositoryName string) (*git.Repository, error)

GitPlainClone clones git repository and is retried in case of error.

func ListRemote added in v0.0.2

func ListRemote(remote *git.Remote, listOptions *git.ListOptions, repository string) ([]*gitplumbing.Reference, error)

func MirrorRepositories

func MirrorRepositories(repos []RepositoryPair)

MirrorRepositories ensures that branches and tags from source repository are mirrored to the destination repository for each repositoryPair.

func MirrorRepository

func MirrorRepository(messages chan MirrorStatus, source, destination string, sourceAuthentication, destinationAuthentication Authentication)

MirrorRepository mirrors branches and tags from source to destination. Tags and branches no longer present in source are removed from destination.

func ProcessError

func ProcessError(err error, activity string, url string, allErrors *[]string)

ProcessError formats err and appends it to allErrors.

func PushRefs added in v0.0.2

func PushRefs(repository *git.Repository, auth *githttp.BasicAuth, refSpecString string, repositoryName string) error

PushRefs pushes refs defined in refSpecString to destination remote and is retried in case of error.

func SetRepositoryAuth

func SetRepositoryAuth(repositories *[]RepositoryPair, defaultSettings RepositoryPair)

SetRepositoryAuth ensures that repositories for which the authentication settings have not been overridden, use the default authentication settings from config file.

func ValidateRepositories

func ValidateRepositories(repositories []RepositoryPair)

ValidateRepositories checks for common issues with input repository data from config file.

Types

type Authentication

type Authentication struct {
	Method    string `mapstructure:"method"`
	TokenName string `mapstructure:"token_name"`
}

type MirrorStatus

type MirrorStatus struct {
	Errors        []string
	LastCloneEnd  time.Time
	CloneDuration time.Duration
	PushDuration  time.Duration
}

type Repository

type Repository struct {
	RepositoryURL string         `mapstructure:"repo"`
	Auth          Authentication `mapstructure:"auth"`
}

type RepositoryPair

type RepositoryPair struct {
	Source      Repository `mapstructure:"source"`
	Destination Repository `mapstructure:"destination"`
}

Jump to

Keyboard shortcuts

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