Skip to content

Commit 591699f

Browse files
authored
docs: Improve comments in /examples (#4122)
1 parent 88c87d1 commit 591699f

9 files changed

Lines changed: 30 additions & 30 deletions

File tree

example/codespaces/newreposecretwithxcrypto/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,27 @@ func getSecretValue(secretName string) (string, error) {
100100

101101
// addRepoSecret will add a secret to a GitHub repo for use in GitHub Codespaces.
102102
//
103-
// The secretName and secretValue will determine the name of the secret added and it's corresponding value.
103+
// The secretName and secretValue determine the name of the secret added and its corresponding value.
104104
//
105-
// The actual transmission of the secret value to GitHub using the api requires that the secret value is encrypted
105+
// The actual transmission of the secret value to GitHub using the API requires that the secret value is encrypted
106106
// using the public key of the target repo. This encryption is done using x/crypto/nacl/box.
107107
//
108108
// First, the public key of the repo is retrieved. The public key comes base64
109109
// encoded, so it must be decoded prior to use.
110110
//
111-
// Second, the decode key is converted into a fixed size byte array.
111+
// Second, the decoded key is converted into a fixed-size byte array.
112112
//
113113
// Third, the secret value is converted into a slice of bytes.
114114
//
115115
// Fourth, the secret is encrypted with box.SealAnonymous using the repo's decoded public key.
116116
//
117-
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncodedSecret type.
117+
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncryptedSecret type.
118118
//
119-
// Sixth, The other two properties of the github.EncodedSecret type are determined. The name of the secret to be added
119+
// Sixth, the other two properties of the github.EncryptedSecret type are determined: the name of the secret to be added
120120
// (string not base64), and the KeyID of the public key used to encrypt the secret.
121121
// This can be retrieved via the public key's GetKeyID method.
122122
//
123-
// Finally, the github.EncodedSecret is passed into the GitHub client.Codespaces.CreateOrUpdateRepoSecret method to
123+
// Finally, the github.EncryptedSecret is passed into the GitHub client.Codespaces.CreateOrUpdateRepoSecret method to
124124
// populate the secret in the GitHub repo.
125125
func addRepoSecret(ctx context.Context, client *github.Client, owner, repo, secretName, secretValue string) error {
126126
publicKey, _, err := client.Codespaces.GetRepoPublicKey(ctx, owner, repo)

example/codespaces/newusersecretwithxcrypto/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ func getSecretValue(secretName string) (string, error) {
9393

9494
// addUserSecret will add a secret to a GitHub user for use in GitHub Codespaces.
9595
//
96-
// The secretName and secretValue will determine the name of the secret added and it's corresponding value.
96+
// The secretName and secretValue determine the name of the secret added and its corresponding value.
9797
//
98-
// The actual transmission of the secret value to GitHub using the api requires that the secret value is encrypted
98+
// The actual transmission of the secret value to GitHub using the API requires that the secret value is encrypted
9999
// using the public key of the target user. This encryption is done using x/crypto/nacl/box.
100100
//
101101
// First, the public key of the user is retrieved. The public key comes base64
102102
// encoded, so it must be decoded prior to use.
103103
//
104-
// Second, the decode key is converted into a fixed size byte array.
104+
// Second, the decoded key is converted into a fixed-size byte array.
105105
//
106106
// Third, the secret value is converted into a slice of bytes.
107107
//
108108
// Fourth, the secret is encrypted with box.SealAnonymous using the user's decoded public key.
109109
//
110-
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncodedSecret type.
110+
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncryptedSecret type.
111111
//
112-
// Sixth, The other two properties of the github.EncodedSecret type are determined. The name of the secret to be added
112+
// Sixth, the other two properties of the github.EncryptedSecret type are determined: the name of the secret to be added
113113
// (string not base64), and the KeyID of the public key used to encrypt the secret.
114114
// This can be retrieved via the public key's GetKeyID method.
115115
//
116-
// Seventh, the github.EncodedSecret is passed into the GitHub client.Codespaces.CreateOrUpdateUserSecret method to
116+
// Seventh, the github.EncryptedSecret is passed into the GitHub client.Codespaces.CreateOrUpdateUserSecret method to
117117
// populate the secret in the GitHub user.
118118
//
119119
// Finally, if a repo and owner are passed in, it adds the repo to the user secret.

example/listenvironments/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// listenvironments is an example of how to use ListEnvironments method with EnvironmentListOptions.
77
// It's runnable with the following command:
88
//
9-
// export GITHUB_TOKEN=your_token
9+
// export GITHUB_AUTH_TOKEN=your_token
1010
// export GITHUB_REPOSITORY_OWNER=your_owner
1111
// export GITHUB_REPOSITORY_NAME=your_repo
1212
// go run .

example/newfilewithappauth/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// license that can be found in the LICENSE file.
55

66
// newfilewithappauth demonstrates the functionality of GitHub's app authentication
7-
// methods by fetching an installation access token and reauthenticating to GitHub
8-
// with OAuth configurations.
7+
// methods by fetching an installation access token as a GitHub App and then
8+
// using that token to authenticate with the GitHub API.
99
package main
1010

1111
import (

example/newreposecretwithxcrypto/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,27 +100,27 @@ func getSecretValue(secretName string) (string, error) {
100100

101101
// addRepoSecret will add a secret to a GitHub repo for use in GitHub Actions.
102102
//
103-
// The secretName and secretValue will determine the name of the secret added and it's corresponding value.
103+
// The secretName and secretValue determine the name of the secret added and its corresponding value.
104104
//
105-
// The actual transmission of the secret value to GitHub using the api requires that the secret value is encrypted
105+
// The actual transmission of the secret value to GitHub using the API requires that the secret value is encrypted
106106
// using the public key of the target repo. This encryption is done using x/crypto/nacl/box.
107107
//
108108
// First, the public key of the repo is retrieved. The public key comes base64
109109
// encoded, so it must be decoded prior to use.
110110
//
111-
// Second, the decode key is converted into a fixed size byte array.
111+
// Second, the decoded key is converted into a fixed-size byte array.
112112
//
113113
// Third, the secret value is converted into a slice of bytes.
114114
//
115115
// Fourth, the secret is encrypted with box.SealAnonymous using the repo's decoded public key.
116116
//
117-
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncodedSecret type.
117+
// Fifth, the encrypted secret is encoded as a base64 string to be used in a github.EncryptedSecret type.
118118
//
119-
// Sixth, The other two properties of the github.EncodedSecret type are determined. The name of the secret to be added
119+
// Sixth, the other two properties of the github.EncryptedSecret type are determined: the name of the secret to be added
120120
// (string not base64), and the KeyID of the public key used to encrypt the secret.
121121
// This can be retrieved via the public key's GetKeyID method.
122122
//
123-
// Finally, the github.EncodedSecret is passed into the GitHub client.Actions.CreateOrUpdateRepoSecret method to
123+
// Finally, the github.EncryptedSecret is passed into the GitHub client.Actions.CreateOrUpdateRepoSecret method to
124124
// populate the secret in the GitHub repo.
125125
func addRepoSecret(ctx context.Context, client *github.Client, owner, repo, secretName, secretValue string) error {
126126
publicKey, _, err := client.Actions.GetRepoPublicKey(ctx, owner, repo)

example/otel/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func main() {
5656
limits.GetCore().Reset)
5757
}
5858

59-
// Check if we captured attributes in response
59+
// Print the HTTP response status when available.
6060
if resp != nil {
6161
fmt.Printf("Response Status: %v\n", resp.Status)
6262
}

example/ratelimit/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6-
// The ratelimit command demonstrates using the github_ratelimit as well as github_pagination.
7-
// By using the waiter, the client automatically sleeps and retry requests
6+
// The ratelimit command demonstrates using github_ratelimit and github_pagination.
7+
// By using the waiters, the client automatically sleeps and retries requests
88
// when it hits secondary rate limits.
99
// It also prevents the client from abusing the API in case of a primary rate limit.
1010
package main
@@ -39,7 +39,7 @@ func main() {
3939
)
4040
client := github.NewClient(paginator)
4141

42-
// arbitrary usage of the client
42+
// Example usage of the client
4343
repos, _, err := client.Repositories.ListByUser(context.Background(), username, nil)
4444
if err != nil {
4545
fmt.Printf("Error: %v\n", err)

example/topics/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6-
// The simple command demonstrates the functionality that
6+
// The topics command demonstrates the functionality that
77
// prompts the user for a GitHub topic and lists all the entities
88
// that are related to the specified topic or subject.
99
package main

example/verifyartifact/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Use of this source code is governed by a BSD-style
44
// license that can be found in the LICENSE file.
55

6-
// This is a simple example of how to verify an artifact
7-
// attestations hosted on GitHub using the sigstore-go library.
6+
// This is a simple example of how to verify artifact attestations
7+
// hosted on GitHub using the sigstore-go library.
88
// This is a very barebones example drawn from the sigstore-go
99
// library's examples and should not be used in production.
1010
package main
@@ -30,10 +30,10 @@ var (
3030
// compute the digest.
3131
artifactDigest = flag.String("artifact-digest", "", "The digest of the artifact")
3232
// The algorithm used to compute the digest of the artifact.
33-
// Note that the GitHub API only currently support querying
33+
// Note that the GitHub API currently only supports querying
3434
// by sha256 digest.
3535
artifactDigestAlgorithm = flag.String("artifact-digest-algorithm", "sha256", "The algorithm used to compute the digest of the artifact")
36-
// Attestations produced by GitHub Actions use ID token
36+
// Attestations produced by GitHub Actions use ID tokens
3737
// issued by GitHub.
3838
expectedIssuer = flag.String("expected-issuer", "https://token.actions.githubusercontent.com", "Issuer of the OIDC token")
3939
// Subject Alternative Name is set to the calling workflow file.

0 commit comments

Comments
 (0)