Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ddbe00

Browse files
committed
doc: generate command docs
Reorganize commands in the cobra suggested structure to be able to import theirpackages by the generator program.
1 parent83682ac commit1ddbe00

File tree

49 files changed

+7094
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+7094
-124
lines changed

‎cmd/keeper/keeper.gorenamed to‎cmd/keeper/cmd/keeper.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -47,7 +47,7 @@ import (
4747

4848
varlog=slog.S()
4949

50-
varcmdKeeper=&cobra.Command{
50+
varCmdKeeper=&cobra.Command{
5151
Use:"stolon-keeper",
5252
Run:keeper,
5353
Version:cmd.Version,
@@ -98,26 +98,26 @@ func init() {
9898
die("cannot get current user: %v",err)
9999
}
100100

101-
cmd.AddCommonFlags(cmdKeeper,&cfg.CommonConfig,true)
102-
103-
cmdKeeper.PersistentFlags().StringVar(&cfg.uid,"id","","keeper uid (must be unique in the cluster and can contain only lower-case letters, numbers and the underscore character). If not provided a random uid will be generated.")
104-
cmdKeeper.PersistentFlags().StringVar(&cfg.uid,"uid","","keeper uid (must be unique in the cluster and can contain only lower-case letters, numbers and the underscore character). If not provided a random uid will be generated.")
105-
cmdKeeper.PersistentFlags().StringVar(&cfg.dataDir,"data-dir","","data directory")
106-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgListenAddress,"pg-listen-address","","postgresql instance listening address")
107-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgPort,"pg-port","5432","postgresql instance listening port")
108-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgBinPath,"pg-bin-path","","absolute path to postgresql binaries. If empty they will be searched in the current PATH")
109-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgReplAuthMethod,"pg-repl-auth-method","md5","postgres replication user auth method. Default is md5.")
110-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgReplUsername,"pg-repl-username","","postgres replication user name. Required. It'll be created on db initialization. Must be the same for all keepers.")
111-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgReplPassword,"pg-repl-password","","postgres replication user password. Only one of --pg-repl-password or --pg-repl-passwordfile must be provided. Must be the same for all keepers.")
112-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgReplPasswordFile,"pg-repl-passwordfile","","postgres replication user password file. Only one of --pg-repl-password or --pg-repl-passwordfile must be provided. Must be the same for all keepers.")
113-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgSUAuthMethod,"pg-su-auth-method","md5","postgres superuser auth method. Default is md5.")
114-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgSUUsername,"pg-su-username",user,"postgres superuser user name. Used for keeper managed instance access and pg_rewind based synchronization. It'll be created on db initialization. Defaults to the name of the effective user running stolon-keeper. Must be the same for all keepers.")
115-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgSUPassword,"pg-su-password","","postgres superuser password. Only one of --pg-su-password or --pg-su-passwordfile must be provided. Must be the same for all keepers.")
116-
cmdKeeper.PersistentFlags().StringVar(&cfg.pgSUPasswordFile,"pg-su-passwordfile","","postgres superuser password file. Only one of --pg-su-password or --pg-su-passwordfile must be provided. Must be the same for all keepers)")
117-
cmdKeeper.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging")
118-
119-
cmdKeeper.PersistentFlags().MarkDeprecated("id","please use --uid")
120-
cmdKeeper.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
101+
cmd.AddCommonFlags(CmdKeeper,&cfg.CommonConfig,true)
102+
103+
CmdKeeper.PersistentFlags().StringVar(&cfg.uid,"id","","keeper uid (must be unique in the cluster and can contain only lower-case letters, numbers and the underscore character). If not provided a random uid will be generated.")
104+
CmdKeeper.PersistentFlags().StringVar(&cfg.uid,"uid","","keeper uid (must be unique in the cluster and can contain only lower-case letters, numbers and the underscore character). If not provided a random uid will be generated.")
105+
CmdKeeper.PersistentFlags().StringVar(&cfg.dataDir,"data-dir","","data directory")
106+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgListenAddress,"pg-listen-address","","postgresql instance listening address")
107+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgPort,"pg-port","5432","postgresql instance listening port")
108+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgBinPath,"pg-bin-path","","absolute path to postgresql binaries. If empty they will be searched in the current PATH")
109+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgReplAuthMethod,"pg-repl-auth-method","md5","postgres replication user auth method. Default is md5.")
110+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgReplUsername,"pg-repl-username","","postgres replication user name. Required. It'll be created on db initialization. Must be the same for all keepers.")
111+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgReplPassword,"pg-repl-password","","postgres replication user password. Only one of --pg-repl-password or --pg-repl-passwordfile must be provided. Must be the same for all keepers.")
112+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgReplPasswordFile,"pg-repl-passwordfile","","postgres replication user password file. Only one of --pg-repl-password or --pg-repl-passwordfile must be provided. Must be the same for all keepers.")
113+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgSUAuthMethod,"pg-su-auth-method","md5","postgres superuser auth method. Default is md5.")
114+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgSUUsername,"pg-su-username",user,"postgres superuser user name. Used for keeper managed instance access and pg_rewind based synchronization. It'll be created on db initialization. Defaults to the name of the effective user running stolon-keeper. Must be the same for all keepers.")
115+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgSUPassword,"pg-su-password","","postgres superuser password. Only one of --pg-su-password or --pg-su-passwordfile must be provided. Must be the same for all keepers.")
116+
CmdKeeper.PersistentFlags().StringVar(&cfg.pgSUPasswordFile,"pg-su-passwordfile","","postgres superuser password file. Only one of --pg-su-password or --pg-su-passwordfile must be provided. Must be the same for all keepers)")
117+
CmdKeeper.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging")
118+
119+
CmdKeeper.PersistentFlags().MarkDeprecated("id","please use --uid")
120+
CmdKeeper.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
121121
}
122122

123123
varmanagedPGParameters= []string{
@@ -1615,10 +1615,10 @@ func sigHandler(sigs chan os.Signal, cancel context.CancelFunc) {
16151615
cancel()
16161616
}
16171617

1618-
funcmain() {
1619-
flagutil.SetFlagsFromEnv(cmdKeeper.PersistentFlags(),"STKEEPER")
1618+
funcExecute() {
1619+
flagutil.SetFlagsFromEnv(CmdKeeper.PersistentFlags(),"STKEEPER")
16201620

1621-
cmdKeeper.Execute()
1621+
CmdKeeper.Execute()
16221622
}
16231623

16241624
funckeeper(c*cobra.Command,args []string) {

‎cmd/keeper/keeper_test.gorenamed to‎cmd/keeper/cmd/keeper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"errors"

‎cmd/keeper/main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 Sorint.lab
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"github.com/sorintlab/stolon/cmd/keeper/cmd"
19+
)
20+
21+
funcmain() {
22+
cmd.Execute()
23+
}

‎cmd/proxy/proxy.gorenamed to‎cmd/proxy/cmd/proxy.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -40,7 +40,7 @@ import (
4040

4141
varlog=slog.S()
4242

43-
varcmdProxy=&cobra.Command{
43+
varCmdProxy=&cobra.Command{
4444
Use:"stolon-proxy",
4545
Run:proxy,
4646
Version:cmd.Version,
@@ -62,17 +62,17 @@ type config struct {
6262
varcfgconfig
6363

6464
funcinit() {
65-
cmd.AddCommonFlags(cmdProxy,&cfg.CommonConfig,true)
65+
cmd.AddCommonFlags(CmdProxy,&cfg.CommonConfig,true)
6666

67-
cmdProxy.PersistentFlags().StringVar(&cfg.listenAddress,"listen-address","127.0.0.1","proxy listening address")
68-
cmdProxy.PersistentFlags().StringVar(&cfg.port,"port","5432","proxy listening port")
69-
cmdProxy.PersistentFlags().BoolVar(&cfg.stopListening,"stop-listening",true,"stop listening on store error")
70-
cmdProxy.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging")
71-
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveIdle,"tcp-keepalive-idle",0,"set tcp keepalive idle (seconds)")
72-
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveCount,"tcp-keepalive-count",0,"set tcp keepalive probe count number")
73-
cmdProxy.PersistentFlags().IntVar(&cfg.keepAliveInterval,"tcp-keepalive-interval",0,"set tcp keepalive interval (seconds)")
67+
CmdProxy.PersistentFlags().StringVar(&cfg.listenAddress,"listen-address","127.0.0.1","proxy listening address")
68+
CmdProxy.PersistentFlags().StringVar(&cfg.port,"port","5432","proxy listening port")
69+
CmdProxy.PersistentFlags().BoolVar(&cfg.stopListening,"stop-listening",true,"stop listening on store error")
70+
CmdProxy.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging")
71+
CmdProxy.PersistentFlags().IntVar(&cfg.keepAliveIdle,"tcp-keepalive-idle",0,"set tcp keepalive idle (seconds)")
72+
CmdProxy.PersistentFlags().IntVar(&cfg.keepAliveCount,"tcp-keepalive-count",0,"set tcp keepalive probe count number")
73+
CmdProxy.PersistentFlags().IntVar(&cfg.keepAliveInterval,"tcp-keepalive-interval",0,"set tcp keepalive interval (seconds)")
7474

75-
cmdProxy.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
75+
CmdProxy.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
7676
}
7777

7878
funcstderr(formatstring,a...interface{}) {
@@ -339,10 +339,10 @@ func (c *ClusterChecker) Start() error {
339339
}
340340
}
341341

342-
funcmain() {
343-
flagutil.SetFlagsFromEnv(cmdProxy.PersistentFlags(),"STPROXY")
342+
funcExecute() {
343+
flagutil.SetFlagsFromEnv(CmdProxy.PersistentFlags(),"STPROXY")
344344

345-
cmdProxy.Execute()
345+
CmdProxy.Execute()
346346
}
347347

348348
funcproxy(c*cobra.Command,args []string) {

‎cmd/proxy/main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 Sorint.lab
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"github.com/sorintlab/stolon/cmd/proxy/cmd"
19+
)
20+
21+
funcmain() {
22+
cmd.Execute()
23+
}

‎cmd/sentinel/sentinel.gorenamed to‎cmd/sentinel/cmd/sentinel.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -52,7 +52,7 @@ const (
5252
fakeStandbyName="stolonfakestandby"
5353
)
5454

55-
varcmdSentinel=&cobra.Command{
55+
varCmdSentinel=&cobra.Command{
5656
Use:"stolon-sentinel",
5757
Run:sentinel,
5858
Version:cmd.Version,
@@ -67,12 +67,12 @@ type config struct {
6767
varcfgconfig
6868

6969
funcinit() {
70-
cmd.AddCommonFlags(cmdSentinel,&cfg.CommonConfig,true)
70+
cmd.AddCommonFlags(CmdSentinel,&cfg.CommonConfig,true)
7171

72-
cmdSentinel.PersistentFlags().StringVar(&cfg.initialClusterSpecFile,"initial-cluster-spec","","a file providing the initial cluster specification, used only at cluster initialization, ignored if cluster is already initialized")
73-
cmdSentinel.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging (deprecated, use log-level instead)")
72+
CmdSentinel.PersistentFlags().StringVar(&cfg.initialClusterSpecFile,"initial-cluster-spec","","a file providing the initial cluster specification, used only at cluster initialization, ignored if cluster is already initialized")
73+
CmdSentinel.PersistentFlags().BoolVar(&cfg.debug,"debug",false,"enable debug logging (deprecated, use log-level instead)")
7474

75-
cmdSentinel.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
75+
CmdSentinel.PersistentFlags().MarkDeprecated("debug","use --log-level=debug instead")
7676
}
7777

7878
funcstderr(formatstring,a...interface{}) {
@@ -1750,10 +1750,10 @@ func sigHandler(sigs chan os.Signal, cancel context.CancelFunc) {
17501750
cancel()
17511751
}
17521752

1753-
funcmain() {
1754-
flagutil.SetFlagsFromEnv(cmdSentinel.PersistentFlags(),"STSENTINEL")
1753+
funcExecute() {
1754+
flagutil.SetFlagsFromEnv(CmdSentinel.PersistentFlags(),"STSENTINEL")
17551755

1756-
cmdSentinel.Execute()
1756+
CmdSentinel.Execute()
17571757
}
17581758

17591759
funcsentinel(c*cobra.Command,args []string) {

‎cmd/sentinel/sentinel_test.gorenamed to‎cmd/sentinel/cmd/sentinel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"fmt"

‎cmd/sentinel/main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 Sorint.lab
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"github.com/sorintlab/stolon/cmd/sentinel/cmd"
19+
)
20+
21+
funcmain() {
22+
cmd.Execute()
23+
}

‎cmd/stolonctl/clusterdata.gorenamed to‎cmd/stolonctl/cmd/clusterdata.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"encoding/json"
@@ -35,7 +35,7 @@ var clusterdataOpts clusterdataOptions
3535
funcinit() {
3636
cmdClusterData.PersistentFlags().BoolVar(&clusterdataOpts.pretty,"pretty",false,"pretty print")
3737

38-
cmdStolonCtl.AddCommand(cmdClusterData)
38+
CmdStolonCtl.AddCommand(cmdClusterData)
3939
}
4040

4141
funcclusterdata(cmd*cobra.Command,args []string) {

‎cmd/stolonctl/init.gorenamed to‎cmd/stolonctl/cmd/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -42,7 +42,7 @@ func init() {
4242
cmdInit.PersistentFlags().StringVarP(&initOpts.file,"file","f","","file contaning the new cluster spec")
4343
cmdInit.PersistentFlags().BoolVarP(&initOpts.forceYes,"yes","y",false,"don't ask for confirmation")
4444

45-
cmdStolonCtl.AddCommand(cmdInit)
45+
CmdStolonCtl.AddCommand(cmdInit)
4646
}
4747

4848
funcinitCluster(cmd*cobra.Command,args []string) {

‎cmd/stolonctl/promote.gorenamed to‎cmd/stolonctl/cmd/promote.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -33,7 +33,7 @@ var cmdPromote = &cobra.Command{
3333
funcinit() {
3434
cmdPromote.PersistentFlags().BoolVarP(&initOpts.forceYes,"yes","y",false,"don't ask for confirmation")
3535

36-
cmdStolonCtl.AddCommand(cmdPromote)
36+
CmdStolonCtl.AddCommand(cmdPromote)
3737
}
3838

3939
funcpromote(cmd*cobra.Command,args []string) {

‎cmd/stolonctl/removekeeper.gorenamed to‎cmd/stolonctl/cmd/removekeeper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -28,7 +28,7 @@ var removeKeeperCmd = &cobra.Command{
2828
}
2929

3030
funcinit() {
31-
cmdStolonCtl.AddCommand(removeKeeperCmd)
31+
CmdStolonCtl.AddCommand(removeKeeperCmd)
3232
}
3333

3434
funcremoveKeeper(cmd*cobra.Command,args []string) {

‎cmd/stolonctl/spec.gorenamed to‎cmd/stolonctl/cmd/spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"encoding/json"
@@ -35,7 +35,7 @@ var specOpts specOptions
3535
funcinit() {
3636
cmdSpec.PersistentFlags().BoolVar(&specOpts.defaults,"defaults",false,"also show default values")
3737

38-
cmdStolonCtl.AddCommand(cmdSpec)
38+
CmdStolonCtl.AddCommand(cmdSpec)
3939
}
4040

4141
funcspec(cmd*cobra.Command,args []string) {

‎cmd/stolonctl/status.gorenamed to‎cmd/stolonctl/cmd/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
packagemain
15+
packagecmd
1616

1717
import (
1818
"context"
@@ -34,7 +34,7 @@ var cmdStatus = &cobra.Command{
3434
}
3535

3636
funcinit() {
37-
cmdStolonCtl.AddCommand(cmdStatus)
37+
CmdStolonCtl.AddCommand(cmdStatus)
3838
}
3939

4040
funcprintTree(dbuidstring,cd*cluster.ClusterData,levelint,prefixstring,tailbool) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp