-
Notifications
You must be signed in to change notification settings - Fork 34
/
example_repository_test.go
33 lines (26 loc) · 1.05 KB
/
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/fluxcd/go-git-providers/github"
"github.com/fluxcd/go-git-providers/gitprovider"
gogithub "github.com/google/go-github/v66/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/flux2")
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: Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.. Homepage: https://fluxcd.io
}