-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from fluxcd/docs
Add user documentation
- Loading branch information
Showing
12 changed files
with
281 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package github_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/fluxcd/go-git-providers/github" | ||
"github.com/fluxcd/go-git-providers/gitprovider" | ||
gogithub "github.com/google/go-github/v32/github" | ||
) | ||
|
||
// checkErr is used for examples in this repository. | ||
func checkErr(err error) { | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func ExampleOrganizationsClient_Get() { | ||
// Create a new client | ||
ctx := context.Background() | ||
c, err := github.NewClient(ctx) | ||
checkErr(err) | ||
|
||
// Get public information about the fluxcd organization | ||
org, err := c.Organizations().Get(ctx, gitprovider.OrganizationRef{ | ||
Domain: github.DefaultDomain, | ||
Organization: "fluxcd", | ||
}) | ||
checkErr(err) | ||
|
||
// Use .Get() to aquire a high-level gitprovider.OrganizationInfo struct | ||
orgInfo := org.Get() | ||
// Cast the internal object to a *gogithub.Organization to access custom data | ||
internalOrg := org.APIObject().(*gogithub.Organization) | ||
|
||
fmt.Printf("Name: %s. Location: %s.", *orgInfo.Name, internalOrg.GetLocation()) | ||
// Output: Name: Flux project. Location: CNCF sandbox. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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/v32/github" | ||
) | ||
|
||
func ExampleOrgRepositoriesClient_Get() { | ||
// Create a new client | ||
ctx := context.Background() | ||
c, err := github.NewClient(ctx) | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.