Skip to content

Commit 4b568cb

Browse files
NikolaySagneum
authored andcommitted
chore(engine): polish Go comments per project style
1 parent 670f927 commit 4b568cb

7 files changed

Lines changed: 25 additions & 25 deletions

File tree

engine/cmd/cli/commands/branch/actions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DataStateAt: {{.DataStateAt | formatDSA }}{{if and (ne .Message "-") (ne .Messag
3232
{{end}}`
3333
)
3434

35-
// Create a new template and parse the letter into it.
35+
// create a new template and parse the letter into it.
3636
var logTemplate = template.Must(template.New("branchLog").Funcs(
3737
template.FuncMap{
3838
"formatDSA": func(dsa string) string {
@@ -86,17 +86,17 @@ func list(cliCtx *cli.Context) error {
8686
return err
8787
}
8888

89-
// Create a new branch.
89+
// create a new branch.
9090
if branchName := cliCtx.Args().First(); branchName != "" {
9191
return create(cliCtx)
9292
}
9393

94-
// Delete branch.
94+
// delete branch.
9595
if branchName := cliCtx.String("delete"); branchName != "" {
9696
return deleteBranch(cliCtx)
9797
}
9898

99-
// List branches.
99+
// list branches.
100100
branches, err := dblabClient.ListBranches(cliCtx.Context)
101101
if err != nil {
102102
return err

engine/cmd/cli/commands/port_forwarding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func BuildTunnel(cliCtx *cli.Context, remoteHost *url.URL) (*portfwd.SSHTunnel,
3737
authMethod,
3838
},
3939
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
40-
// Always accept key.
40+
// always accept key.
4141
return nil
4242
},
4343
}

engine/cmd/cli/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ func main() {
3030
},
3131
Before: loadEnvironmentParams,
3232
Commands: joinCommands(
33-
// Config commands.
33+
// config commands.
3434
global.List(),
3535

36-
// Branching.
36+
// branching.
3737
branch.List(),
3838

3939
// Database Lab API.
@@ -116,7 +116,7 @@ func loadEnvironmentParams(c *cli.Context) error {
116116

117117
cfg, err := config.Load(filename)
118118
if err != nil {
119-
// Failed to load config, skip auto-loading environment keys.
119+
// failed to load config, skip auto-loading environment keys.
120120
return nil
121121
}
122122

@@ -185,7 +185,7 @@ func loadEnvironmentParams(c *cli.Context) error {
185185
}
186186

187187
func joinCommands(cliGroups ...[]*cli.Command) []*cli.Command {
188-
// There are at least len(cliGroups) elements.
188+
// there are at least len(cliGroups) elements.
189189
cliCommands := make([]*cli.Command, 0, len(cliGroups))
190190

191191
for _, cliGroup := range cliGroups {

engine/internal/provision/databases/postgres/postgres_mgmt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func CreateUser(c *resources.AppConfig, user resources.EphemeralUser) error {
9191
}
9292

9393
if user.Restricted {
94-
// Create or alter restricted user.
94+
// create or alter restricted user.
9595
query = restrictedUserQuery(user.Name, user.Password, userExists)
9696
out, err := runSimpleSQL(query, pgConnStr)
9797

@@ -101,7 +101,7 @@ func CreateUser(c *resources.AppConfig, user resources.EphemeralUser) error {
101101

102102
log.Dbg("Restricted user has been created: ", out)
103103

104-
// Change user ownership.
104+
// change user ownership.
105105
query = restrictedUserOwnershipQuery(user.Name, user.Password)
106106
out, err = runSimpleSQL(query, pgConnStr)
107107

@@ -111,7 +111,7 @@ func CreateUser(c *resources.AppConfig, user resources.EphemeralUser) error {
111111

112112
log.Dbg("Database ownership has been changed: ", out)
113113

114-
// Set restricted user as owner for database objects.
114+
// set restricted user as owner for database objects.
115115
databaseList, err := runSQLSelectQuery(selectAllDatabases, pgConnStr)
116116

117117
if err != nil {

engine/internal/provision/docker/docker.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func RunContainer(r runners.Runner, c *resources.AppConfig) error {
5656
log.Dbg(fmt.Sprintf("Host info: %#v", hostInfo))
5757

5858
if hostInfo.VirtualizationRole == "guest" {
59-
// Build custom mounts rely on mounts of the Database Lab instance if it's running inside Docker container.
60-
// We cannot use --volumes-from because it removes the ZFS mount point.
59+
// build custom mounts rely on mounts of the Database Lab instance if it's running inside Docker container.
60+
// we cannot use --volumes-from because it removes the ZFS mount point.
6161
volumes, err = getMountVolumes(r, c, hostInfo.Hostname)
6262
if err != nil {
6363
return errors.Wrap(err, "failed to detect container volumes")
@@ -119,7 +119,7 @@ func publishPorts(provisionHosts string, instancePort string) string {
119119
func createDefaultVolumes(c *resources.AppConfig) (string, []string) {
120120
unixSocketCloneDir := c.Pool.SocketCloneDir(c.CloneName)
121121

122-
// Directly mount PGDATA if Database Lab is running without any virtualization.
122+
// directly mount PGDATA if Database Lab is running without any virtualization.
123123
volumes := []string{
124124
fmt.Sprintf("--volume %s:%s", c.CloneDir(), c.CloneDir()),
125125
fmt.Sprintf("--volume %s:%s", unixSocketCloneDir, unixSocketCloneDir),
@@ -151,15 +151,15 @@ func buildVolumesFromMountPoints(c *resources.AppConfig, mountPoints []container
151151
volumes := make([]string, 0, len(mounts))
152152

153153
for _, mountPoint := range mountPoints {
154-
// Add an extra mount for socket directories.
154+
// add an extra mount for socket directories.
155155
if strings.HasPrefix(unixSocketCloneDir, mountPoint.Destination) {
156156
volumes = append(volumes, buildSocketMount(unixSocketCloneDir, mountPoint.Source, mountPoint.Destination))
157157
break
158158
}
159159
}
160160

161161
for _, mount := range mounts {
162-
// Exclude system and non-data volumes from a clone container.
162+
// exclude system and non-data volumes from a clone container.
163163
if isSystemVolume(mount.Source) || !strings.HasPrefix(mount.Source, c.Pool.MountDir) {
164164
continue
165165
}

engine/internal/provision/runners/runners.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func NewRunnerError(command string, stderr string, e error) error {
5252

5353
case (*exec.ExitError):
5454
// SO: https://stackoverflow.com/questions/10385551/get-exit-code-go.
55-
// The program has exited with an exit code != 0
56-
// This works on both Unix and Windows. Although package
55+
// the program has exited with an exit code != 0.
56+
// this works on both Unix and Windows. Although package
5757
// syscall is generally platform dependent, WaitStatus is
5858
// defined for both Unix and Windows and in both cases has
5959
// an ExitStatus() method with the same signature.
@@ -124,19 +124,19 @@ func (r *LocalRunner) Run(command string, options ...bool) (string, error) {
124124
cmd.Stdout = &out
125125
cmd.Stderr = &stderr
126126

127-
// TODO(anatoly): Remove hot fix of pg_ctl endless wait.
127+
// TODO(anatoly): remove hot fix of pg_ctl endless wait.
128128
if strings.Contains(command, "start") {
129129
cmd.Stdout = os.Stdout
130130
cmd.Stderr = os.Stderr
131131
}
132132

133-
// Psql with the file option returns error response to stderr with
133+
// psql with the file option returns error response to stderr with
134134
// success exit code. In that case err will be nil, but we need
135135
// to treat the case as error and read proper output.
136136
err := cmd.Run()
137137
psqlErr := strings.Contains(command, "psql") && len(stderr.String()) > 0
138138

139-
// TODO(anatoly): Remove hotfix.
139+
// TODO(anatoly): remove hotfix.
140140
psqlErr = psqlErr && !strings.Contains(stderr.String(), "unable to resolve host")
141141

142142
if err != nil || psqlErr {
@@ -158,7 +158,7 @@ func (r *LocalRunner) Run(command string, options ...bool) (string, error) {
158158
return outFormatted, nil
159159
}
160160

161-
// Utils.
161+
// utils.
162162
func parseOptions(options ...bool) bool {
163163
logsEnabled := LogsEnabledDefault
164164
if len(options) > 0 {

engine/internal/retrieval/engine/postgres/tools/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ func processAttachResponse(ctx context.Context, reader io.Reader) ([]byte, error
746746
return bytes.TrimSpace(outBuf.Bytes()), nil
747747
}
748748

749-
// CreateContainerIfMissing create a new container if there is no other container with the same name, if the container
750-
// exits returns existing container id.
749+
// CreateContainerIfMissing creates a new container if no container with the same name exists.
750+
// If a container with the same name already exists, its ID is returned.
751751
func CreateContainerIfMissing(ctx context.Context, docker *client.Client, containerName string,
752752
config *container.Config, hostConfig *container.HostConfig) (string, error) {
753753
containerData, err := docker.ContainerInspect(ctx, containerName)

0 commit comments

Comments
 (0)