File: bitbucket_import.go

package info (click to toggle)
golang-gitlab-gitlab-org-api-client-go 0.123.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,356 kB
  • sloc: makefile: 17
file content (50 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

import (
	"log"

	"gitlab.com/gitlab-org/api/client-go"
)

func bitbucketCloudExample() {
	git, err := gitlab.NewClient("yourtokengoeshere")
	if err != nil {
		log.Fatal(err)
	}

	cloudOpt := &gitlab.ImportRepositoryFromBitbucketCloudOptions{
		BitbucketUsername:    gitlab.Ptr("username"),
		BitbucketAppPassword: gitlab.Ptr("password"),
		RepoPath:             gitlab.Ptr("some/repo"),
		TargetNamespace:      gitlab.Ptr("some-group"),
		NewName:              gitlab.Ptr("some-repo"),
	}
	cloudResp, _, err := git.Import.ImportRepositoryFromBitbucketCloud(cloudOpt)
	if err != nil {
		log.Fatal(err)
	}
	log.Print(cloudResp.String())
}

func bitbucketServerExample() {
	git, err := gitlab.NewClient("yourtokengoeshere")
	if err != nil {
		log.Fatal(err)
	}

	serverOpt := &gitlab.ImportRepositoryFromBitbucketServerOptions{
		BitbucketServerUrl:      gitlab.Ptr("https://bitbucket.example.com"),
		BitbucketServerUsername: gitlab.Ptr("username"),
		PersonalAccessToken:     gitlab.Ptr("access-token"),
		BitbucketServerProject:  gitlab.Ptr("some-project"),
		BitbucketServerRepo:     gitlab.Ptr("some-repo"),
		NewName:                 gitlab.Ptr("some-other-repo"),
		NewNamespace:            gitlab.Ptr("some-group"),
		TimeoutStrategy:         gitlab.Ptr("pessimistic"),
	}
	serverResp, _, err := git.Import.ImportRepositoryFromBitbucketServer(serverOpt)
	if err != nil {
		log.Fatal(err)
	}
	log.Print(serverResp.String())
}