Skip to content

Commit e5246f7

Browse files
author
Aaron Schlesinger
committed
doc(pkg): ensure all docs are <= 99 chars wide
Also make a few grammatical fixes to docs. This commit does not make any code changes, even in cases when a line of code expands beyond 99 chars
1 parent 40b4de1 commit e5246f7

21 files changed

Lines changed: 159 additions & 77 deletions

pkg/cleaner/cleaner.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Package cleaner is a background process that compares the kubernetes namespace list with the folders in the local git home directory, deleting what's not in the namespace list
1+
// Package cleaner is a background process that compares the kubernetes namespace list with the
2+
// folders in the local git home directory, deleting what's not in the namespace list
23
package cleaner
34

45
import (
@@ -14,9 +15,11 @@ const (
1415
dotGitSuffix = ".git"
1516
)
1617

17-
// Run starts the deleted app cleaner. This function listens to the Kubernetes event stream for events that indicate namespaces that were `DELETED`.
18+
// Run starts the deleted app cleaner. This function listens to the Kubernetes event stream for
19+
// events that indicate namespaces that were `DELETED`.
1820
// If the namespace name matches a folder on the local filesystem, this func deletes that folder.
19-
// Note that this function blocks until the watcher returned by `nsLister.Watch` is closed, so you should launch it in a goroutine.
21+
// Note that this function blocks until the watcher returned by `nsLister.Watch` is closed, so
22+
// you should launch it in a goroutine.
2023
func Run(gitHome string, nsLister k8s.NamespaceWatcher, fs sys.FS) error {
2124
watcher, err := nsLister.Watch(nil, nil, "")
2225
if err != nil {

pkg/conf/config.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ const (
1111
builderKeyLocation = "/var/run/secrets/api/auth/builder-key"
1212
)
1313

14-
// EnvConfig is a convenience function to process the envconfig (https://github.com/kelseyhightower/envconfig) based configuration environment variables into conf. Additional notes:
14+
// EnvConfig is a convenience function to process the envconfig (
15+
// https://github.com/kelseyhightower/envconfig) based configuration environment variables into
16+
// conf. Additional notes:
1517
//
1618
// - appName will be passed as the first parameter to envconfig.Process
17-
// - conf should be a pointer to an envconfig compatible struct. If you'd like to use struct tags to customize your struct, see https://github.com/kelseyhightower/envconfig#struct-tag-support
19+
// - conf should be a pointer to an envconfig compatible struct. If you'd like to use struct
20+
// tags to customize your struct, see
21+
// https://github.com/kelseyhightower/envconfig#struct-tag-support
1822
func EnvConfig(appName string, conf interface{}) error {
1923
if err := envconfig.Process(appName, conf); err != nil {
2024
return err

pkg/controller/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const (
1818
portEnvName = "DEIS_CONTROLLER_SERVICE_PORT"
1919
)
2020

21-
// UserInfo represent the required information from a user to make a push and interact with the controller
21+
// UserInfo represents the required information from a user to make a push and interact with the
22+
// controller
2223
type UserInfo struct {
2324
Username string
2425
Key string

pkg/git/git.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222
"golang.org/x/crypto/ssh"
2323
)
2424

25-
// prereceiveHookTplStr is the template for a pre-receive hook. The following template variables are passed into it:
25+
// prereceiveHookTplStr is the template for a pre-receive hook. The following template variables
26+
// are passed into it:
2627
//
2728
// .GitHome: the path to Git's home directory.
2829
const preReceiveHookTplStr = `#!/bin/bash

pkg/gitreceive/build.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ func repoCmd(repoDir, first string, others ...string) *exec.Cmd {
2929
return cmd
3030
}
3131

32-
// run prints the command it will execute to the debug log, then runs it and returns the result of run
32+
// run prints the command it will execute to the debug log, then runs it and returns the result
33+
// of run
3334
func run(cmd *exec.Cmd) error {
3435
cmdStr := strings.Join(cmd.Args, " ")
3536
if cmd.Dir != "" {

pkg/gitreceive/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const (
1010
objectStorageTick = 500
1111
)
1212

13-
// Config is the envconfig (http://github.com/kelseyhightower/envconfig) compatible struct for the builder's git-receive hook
13+
// Config is the envconfig (http://github.com/kelseyhightower/envconfig) compatible struct for the
14+
// builder's git-receive hook
1415
type Config struct {
1516
// k8s service discovery env vars
1617
ControllerHost string `envconfig:"DEIS_CONTROLLER_SERVICE_HOST" required:"true"`
@@ -36,7 +37,8 @@ type Config struct {
3637
DockerBuilderImage string `envconfig:"DOCKERBUILDER_IMAGE_NAME" default:"quay.io/deisci/dockerbuilder:v2-beta"`
3738
}
3839

39-
// App returns the application name represented by c. The app name is the same as c.Repository with the last '.' and beyond stripped off
40+
// App returns the application name represented by c. The app name is the same as c.Repository
41+
// with the last '.' and beyond stripped off
4042
func (c Config) App() string {
4143
li := strings.LastIndex(c.Repository, ".")
4244
if li == -1 {

pkg/gitreceive/storage/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ func GetClient(regionStr string, fs sys.FS, env sys.Env) (*Client, error) {
2424
return nil, err
2525
}
2626

27-
// the New function call guesses which signature version to use. Currently, it correctly guesses V2 for GCS and V4 for both AWS S3 and Minio
27+
// the New function call guesses which signature version to use. Currently, it correctly guesses
28+
// V2 for GCS and V4 for both AWS S3 and Minio
2829
s3Client, err := s3.New(endpoint.URLStr, auth.accessKeyID, auth.accessKeySecret, !endpoint.Secure)
2930
if err != nil {
3031
return nil, err

pkg/gitreceive/storage/interfaces.go

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
s3 "github.com/minio/minio-go"
77
)
88

9-
// BucketCreator is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the MakeBucket function. You can use it in your code for easier unit testing without any external dependencies
9+
// BucketCreator is a *(github.com/minio/minio-go).Client compatible interface, restricted to
10+
// just the MakeBucket function. You can use it in your code for easier unit testing without
11+
// any external dependencies
1012
type BucketCreator interface {
1113
MakeBucket(bucketName string, acl s3.BucketACL, location string) error
1214
}
@@ -18,7 +20,8 @@ type FakeMakeBucketCall struct {
1820
Location string
1921
}
2022

21-
// FakeBucketCreator is a mock function that can be swapped in for an BucketCreator, so you can unit test your code
23+
// FakeBucketCreator is a mock function that can be swapped in for an BucketCreator, so you
24+
// can unit test your code
2225
type FakeBucketCreator struct {
2326
Fn func(string, s3.BucketACL, string) error
2427
Calls []FakeMakeBucketCall
@@ -30,7 +33,9 @@ func (f *FakeBucketCreator) MakeBucket(name string, acl s3.BucketACL, location s
3033
return f.Fn(name, acl, location)
3134
}
3235

33-
// ObjectStatter is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the StatObject function. You can use it in your code for easier unit testing without any external dependencies
36+
// ObjectStatter is a *(github.com/minio/minio-go).Client compatible interface, restricted to
37+
// just the StatObject function. You can use it in your code for easier unit testing without
38+
// any external dependencies (like access to S3)
3439
type ObjectStatter interface {
3540
StatObject(bucketName, objectKey string) (s3.ObjectInfo, error)
3641
}
@@ -41,7 +46,8 @@ type FakeStatObjectCall struct {
4146
ObjectKey string
4247
}
4348

44-
// FakeObjectStatter is a mock function that can be swapped in for an ObjectStatter, so you can unit test your code
49+
// FakeObjectStatter is a mock function that can be swapped in for an ObjectStatter, so you can
50+
// unit test your code
4551
type FakeObjectStatter struct {
4652
Fn func(string, string) (s3.ObjectInfo, error)
4753
Calls []FakeStatObjectCall
@@ -53,7 +59,9 @@ func (f *FakeObjectStatter) StatObject(bucketName, objectKey string) (s3.ObjectI
5359
return f.Fn(bucketName, objectKey)
5460
}
5561

56-
// ObjectPutter is a *(github.com/minio/minio-go).Client compatible interface, restricted to just the PutObject function. You can use it in your code for easier unit testing without any external dependencies
62+
// ObjectPutter is a *(github.com/minio/minio-go).Client compatible interface, restricted to just
63+
// the PutObject function. You can use it in your code for easier unit testing without any
64+
// external dependencies
5765
type ObjectPutter interface {
5866
PutObject(bucketName, objectKey string, reader io.Reader, contentType string) (int64, error)
5967
}
@@ -66,7 +74,8 @@ type FakePutObjectCall struct {
6674
ContentType string
6775
}
6876

69-
// FakeObjectPutter is a mock function that can be swapped in for an ObjectPutter, so you can unit test your code
77+
// FakeObjectPutter is a mock function that can be swapped in for an ObjectPutter, so you can
78+
// unit test your code
7079
type FakeObjectPutter struct {
7180
Fn func(bucketName, objectKey string, reader io.Reader, contentType string) (int64, error)
7281
Calls []FakePutObjectCall
@@ -83,25 +92,36 @@ func (f *FakeObjectPutter) PutObject(bucketName, objectKey string, reader io.Rea
8392
return f.Fn(bucketName, objectKey, reader, contentType)
8493
}
8594

86-
// Object is a *(github.com/minio/minio-go).Object compatible interface. Currently, ObjectGetter returns these so that FakeObjectGetters can return mock implementations
95+
// Object is a *(github.com/minio/minio-go).Object compatible interface. Currently, ObjectGetter
96+
// returns these so that FakeObjectGetters can return mock implementations
8797
type Object interface {
88-
// This is called an interface composition - it automatically gives your interface the function in io.Reader (https://godoc.org/io#Reader) and the function in io.Closer (https://godoc.org/io#Closer)
98+
// This is called an interface composition - it automatically gives your interface the function
99+
// in io.Reader (https://godoc.org/io#Reader) and the function in io.Closer
100+
// (https://godoc.org/io#Closer)
89101
io.ReadCloser
90-
// This is also an interface composition. It gives your interface the function in io.Seeker (https://godoc.org/io#Seeker)
102+
// This is also an interface composition. It gives your interface the function in
103+
// io.Seeker (https://godoc.org/io#Seeker)
91104
io.Seeker
92-
// This is also interface composition. It gives your interface the function in io.ReaderAt (https://godoc.org/io#ReaderAt)
105+
// This is also interface composition. It gives your interface the function in
106+
// io.ReaderAt (https://godoc.org/io#ReaderAt)
93107
io.ReaderAt
94-
// This function is the last one we have to add to make this interface have all the same functions as s3.Object
108+
// This function is the last one we have to add to make this interface have all the same
109+
// functions as s3.Object
95110
Stat() (s3.ObjectInfo, error)
96111
}
97112

98-
// ObjectGetter is the interface to get an object from object storage. The minio client doesn't already satisfy this interface, because the GetObject func (https://godoc.org/github.com/minio/minio-go#Client.GetObject) doesn't return an Object. Instead, it returns a *s3.Object. Use the RealObjectGetter below to use the minio client
113+
// ObjectGetter is the interface to get an object from object storage. The minio client doesn't
114+
// already satisfy this interface, because the GetObject func
115+
// (https://godoc.org/github.com/minio/minio-go#Client.GetObject) doesn't return an Object.
116+
// Instead, it returns a *s3.Object. Use the RealObjectGetter below to use the minio client
99117
type ObjectGetter interface {
100-
// GetObject is *almost* the same function as the GetObject func in the minio client, but it returns Object instead of *s3.Object
118+
// GetObject is *almost* the same function as the GetObject func in the minio client, but it
119+
// returns Object instead of *s3.Object
101120
GetObject(string, string) (Object, error)
102121
}
103122

104-
// RealObjectGetter is an adapter to make the *s3.Client GetObject function compatible with the ObjectGetter interface
123+
// RealObjectGetter is an adapter to make the *s3.Client GetObject function compatible with the
124+
// ObjectGetter interface
105125
type RealObjectGetter struct {
106126
Client *s3.Client
107127
}
@@ -113,7 +133,8 @@ func (r *RealObjectGetter) GetObject(bucket, objKey string) (Object, error) {
113133
// you can return nil for an interface
114134
return nil, err
115135
}
116-
// obj is a *s3.Object, but as we said above, it automatically implements our Object interface without any other work
136+
// obj is a *s3.Object, but as we said above, it automatically implements our Object interface
137+
// without any other work
117138
return obj, nil
118139
}
119140

@@ -123,7 +144,8 @@ type FakeGetObjectCall struct {
123144
ObjectKey string
124145
}
125146

126-
// FakeObjectGetter is a mock function that can be swapped in for an ObjectGetter, so you can unit test your code
147+
// FakeObjectGetter is a mock function that can be swapped in for an ObjectGetter, so you can
148+
// unit test your code
127149
type FakeObjectGetter struct {
128150
Fn func(string, string) (Object, error)
129151
Calls []FakeGetObjectCall
@@ -135,7 +157,8 @@ func (f *FakeObjectGetter) GetObject(bucketName, objectKey string) (Object, erro
135157
return f.Fn(bucketName, objectKey)
136158
}
137159

138-
// FakeObject is a mock function that can be swapped in for an *s3.Object, so you can unit test your code
160+
// FakeObject is a mock function that can be swapped in for an *s3.Object, so you can unit test
161+
// your code
139162
type FakeObject struct {
140163
Data string
141164
}

pkg/gitreceive/storage/object.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const (
1616
octetStream = "application/octet-stream"
1717
)
1818

19-
// ObjectExists determines whether the object in ${bucketName}/${objKey} exists, as reported by statter. Returns the following:
19+
// ObjectExists determines whether the object in ${bucketName}/${objKey} exists, as reported by
20+
// statter. Returns the following:
2021
//
2122
// - false, nil if statter succeeded and reported the object doesn't exist
2223
// - false, err with the appropriate error if the statter failed
@@ -39,7 +40,8 @@ func UploadObject(putter ObjectPutter, bucketName, objKey string, reader io.Read
3940
return err
4041
}
4142

42-
// WaitForObject checks statter for the object at ${bucketName}/${objKey} right away, then at every tick, then once when the timeout is up.
43+
// WaitForObject checks statter for the object at ${bucketName}/${objKey} right away, then at
44+
// every tick, then once when the timeout is up.
4345
// Returns nil if it finds the object before or at timeout. Otherwise returns a non-nil error
4446
func WaitForObject(statter ObjectStatter, bucketName, objKey string, tick, timeout time.Duration) error {
4547
noExist := errors.New("object doesn't exist")
@@ -75,7 +77,9 @@ func WaitForObject(statter ObjectStatter, bucketName, objKey string, tick, timeo
7577
}
7678
}
7779

78-
// DownloadObject uses the given getter to download the contents the object at ${bucketName}/${objKey} and returns the object's contents in the given byte slice. Returns nil and the appropriate error if there were problems with the download
80+
// DownloadObject uses the given getter to download the contents the object at
81+
// ${bucketName}/${objKey} and returns the object's contents in the given byte slice.
82+
// Returns nil and the appropriate error if there were problems with the download
7983
func DownloadObject(getter ObjectGetter, bucketName, objKey string) ([]byte, error) {
8084
reader, err := getter.GetObject(bucketName, objKey)
8185
if err != nil {

pkg/gitreceive/storage/slug_builder_info.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const (
1010
slugTGZName = "slug.tgz"
1111
)
1212

13-
// SlugBuilderInfo contains all of the object storage related information needed to pass to a slug builder
13+
// SlugBuilderInfo contains all of the object storage related information needed to pass to a
14+
// slug builder
1415
type SlugBuilderInfo struct {
1516
pushKey string
1617
pushURL string
@@ -21,7 +22,8 @@ type SlugBuilderInfo struct {
2122
// NewSlugBuilderInfo creates and populates a new SlugBuilderInfo based on the given data
2223
func NewSlugBuilderInfo(s3Endpoint *Endpoint, bucket, appName, slugName string, gitSha *git.SHA) *SlugBuilderInfo {
2324
tarKey := fmt.Sprintf("home/%s/tar", slugName)
24-
// this is where the controller tells slugrunner to download the slug from, so we have to tell slugbuilder to upload it to here
25+
// this is where the controller tells slugrunner to download the slug from, so we have to
26+
// tell slugbuilder to upload it to here
2527
pushKey := fmt.Sprintf("home/%s:git-%s/push", appName, gitSha.Short())
2628

2729
return &SlugBuilderInfo{
@@ -32,16 +34,21 @@ func NewSlugBuilderInfo(s3Endpoint *Endpoint, bucket, appName, slugName string,
3234
}
3335
}
3436

35-
// PushKey returns the object storage key that the slug builder will store the slug in. The returned value only contains the path to the folder, not including the final filename.
37+
// PushKey returns the object storage key that the slug builder will store the slug in.
38+
// The returned value only contains the path to the folder, not including the final filename.
3639
func (s SlugBuilderInfo) PushKey() string { return s.pushKey }
3740

38-
// PushURL returns the complete object storage URL that the slug builder will store the slug in. The returned value only contains the URL to the folder, not including the final filename.
41+
// PushURL returns the complete object storage URL that the slug builder will store the slug in.
42+
// The returned value only contains the URL to the folder, not including the final filename.
3943
func (s SlugBuilderInfo) PushURL() string { return s.pushURL }
4044

41-
// TarKey returns the object storage key from which the slug builder will download for the tarball (from which it uses to build the slug). The returned value only contains the path to the folder, not including the final filename.
45+
// TarKey returns the object storage key from which the slug builder will download for the tarball
46+
// (from which it uses to build the slug). The returned value only contains the path to the
47+
// folder, not including the final filename.
4248
func (s SlugBuilderInfo) TarKey() string { return s.tarKey }
4349

44-
// TarURL returns the complete object storage URL that the slug builder will download the tarball from. The returned value only contains the URL to the folder, not including the final filename.
50+
// TarURL returns the complete object storage URL that the slug builder will download the tarball
51+
// from. The returned value only contains the URL to the folder, not including the final filename.
4552
func (s SlugBuilderInfo) TarURL() string { return s.tarURL }
4653

4754
// AbsoluteSlugObjectKey returns the PushKey plus the final filename of the slug

0 commit comments

Comments
 (0)