forked from fluxcd/go-git-providers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_repository_test.go
33 lines (26 loc) · 1019 Bytes
/
example_repository_test.go
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
package github_test
import (
"context"
"fmt"
"github.com/dinosk/go-git-providers/github"
"github.com/dinosk/go-git-providers/gitprovider"
gogithub "github.com/google/go-github/v32/github"
)
func ExampleOrgRepositoriesClient_Get() {
// Create a new client
ctx := context.Background()
c, err := github.NewClient()
checkErr(err)
// Parse the URL into an OrgRepositoryRef
ref, err := gitprovider.ParseOrgRepositoryURL("https://github.com/fluxcd/flux")
checkErr(err)
// Get public information about the flux repository.
repo, err := c.OrgRepositories().Get(ctx, *ref)
checkErr(err)
// Use .Get() to aquire a high-level gitprovider.OrganizationInfo struct
repoInfo := repo.Get()
// Cast the internal object to a *gogithub.Repository to access custom data
internalRepo := repo.APIObject().(*gogithub.Repository)
fmt.Printf("Description: %s. Homepage: %s", *repoInfo.Description, internalRepo.GetHomepage())
// Output: Description: The GitOps Kubernetes operator. Homepage: https://docs.fluxcd.io
}