Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
flux2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
fluxcd
flux2
Commits
4a872836
Commit
4a872836
authored
4 years ago
by
stefanprodan
Browse files
Options
Downloads
Patches
Plain Diff
Generate tk docs with cobra/doc
parent
38cc918a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+3
-0
3 additions, 0 deletions
Makefile
cmd/tk/main.go
+28
-8
28 additions, 8 deletions
cmd/tk/main.go
go.sum
+3
-0
3 additions, 0 deletions
go.sum
with
34 additions
and
8 deletions
Makefile
+
3
−
0
View file @
4a872836
...
@@ -19,3 +19,6 @@ build:
...
@@ -19,3 +19,6 @@ build:
install
:
install
:
go
install
cmd/tk
go
install
cmd/tk
docs
:
mkdir
-p
./docs/cmd
&&
go run ./cmd/tk/ docgen
This diff is collapsed.
Click to expand it.
cmd/tk/main.go
+
28
−
8
View file @
4a872836
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"time"
"time"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes"
_
"k8s.io/client-go/plugin/pkg/client/auth"
_
"k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd"
...
@@ -18,7 +19,8 @@ var VERSION = "0.0.1"
...
@@ -18,7 +19,8 @@ var VERSION = "0.0.1"
var
rootCmd
=
&
cobra
.
Command
{
var
rootCmd
=
&
cobra
.
Command
{
Use
:
"tk"
,
Use
:
"tk"
,
Short
:
"Kubernetes CD assembler"
,
Short
:
"Command line utility for assembling Kubernetes CD pipelines"
,
Long
:
`Command line utility for assembling Kubernetes CD pipelines.`
,
Version
:
VERSION
,
Version
:
VERSION
,
SilenceUsage
:
true
,
SilenceUsage
:
true
,
SilenceErrors
:
true
,
SilenceErrors
:
true
,
...
@@ -31,13 +33,6 @@ var (
...
@@ -31,13 +33,6 @@ var (
)
)
func
init
()
{
func
init
()
{
if
home
:=
homeDir
();
home
!=
""
{
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
kubeconfig
,
"kubeconfig"
,
""
,
filepath
.
Join
(
home
,
".kube"
,
"config"
),
"path to the kubeconfig file"
)
}
else
{
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
kubeconfig
,
"kubeconfig"
,
""
,
""
,
"absolute path to the kubeconfig file"
)
}
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
namespace
,
"namespace"
,
""
,
"gitops-system"
,
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
namespace
,
"namespace"
,
""
,
"gitops-system"
,
"the namespace scope for this operation"
)
"the namespace scope for this operation"
)
rootCmd
.
PersistentFlags
()
.
DurationVarP
(
&
timeout
,
"timeout"
,
""
,
5
*
time
.
Minute
,
rootCmd
.
PersistentFlags
()
.
DurationVarP
(
&
timeout
,
"timeout"
,
""
,
5
*
time
.
Minute
,
...
@@ -46,6 +41,8 @@ func init() {
...
@@ -46,6 +41,8 @@ func init() {
func
main
()
{
func
main
()
{
log
.
SetFlags
(
0
)
log
.
SetFlags
(
0
)
generateDocs
()
kubeconfigFlag
()
if
err
:=
rootCmd
.
Execute
();
err
!=
nil
{
if
err
:=
rootCmd
.
Execute
();
err
!=
nil
{
logFailure
(
"%v"
,
err
)
logFailure
(
"%v"
,
err
)
os
.
Exit
(
1
)
os
.
Exit
(
1
)
...
@@ -93,3 +90,26 @@ func logSuccess(format string, a ...interface{}) {
...
@@ -93,3 +90,26 @@ func logSuccess(format string, a ...interface{}) {
func
logFailure
(
format
string
,
a
...
interface
{})
{
func
logFailure
(
format
string
,
a
...
interface
{})
{
fmt
.
Println
(
`✗`
,
fmt
.
Sprintf
(
format
,
a
...
))
fmt
.
Println
(
`✗`
,
fmt
.
Sprintf
(
format
,
a
...
))
}
}
func
generateDocs
()
{
args
:=
os
.
Args
[
1
:
]
if
len
(
args
)
>
0
&&
args
[
0
]
==
"docgen"
{
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
kubeconfig
,
"kubeconfig"
,
""
,
"~/.kube/config"
,
"path to the kubeconfig file"
)
err
:=
doc
.
GenMarkdownTree
(
rootCmd
,
"./docs/cmd"
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
os
.
Exit
(
0
)
}
}
func
kubeconfigFlag
()
{
if
home
:=
homeDir
();
home
!=
""
{
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
kubeconfig
,
"kubeconfig"
,
""
,
filepath
.
Join
(
home
,
".kube"
,
"config"
),
"path to the kubeconfig file"
)
}
else
{
rootCmd
.
PersistentFlags
()
.
StringVarP
(
&
kubeconfig
,
"kubeconfig"
,
""
,
""
,
"absolute path to the kubeconfig file"
)
}
}
This diff is collapsed.
Click to expand it.
go.sum
+
3
−
0
View file @
4a872836
...
@@ -41,6 +41,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
...
@@ -41,6 +41,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-semver
v0.2.0/go.mod h1:
nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver
v0.2.0/go.mod h1:
nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd
v0.0.0-20190321100706-95778dfbb74e/go.mod h1:
F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd
v0.0.0-20190321100706-95778dfbb74e/go.mod h1:
F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg
v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:
E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg
v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:
E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2
v2.0.0 h1:
EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2
v2.0.0/go.mod h1:
maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2
v2.0.0/go.mod h1:
maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew
v1.1.1 h1:
vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew
v1.1.1 h1:
vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
...
@@ -171,7 +172,9 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
...
@@ -171,7 +172,9 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs
v0.0.0-20190507164030-5867b95ac084/go.mod h1:
TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs
v0.0.0-20190507164030-5867b95ac084/go.mod h1:
TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb
v0.7.1/go.mod h1:
qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/prometheus/tsdb
v0.7.1/go.mod h1:
qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid
v0.0.0-20150106093220-6724a57986af/go.mod h1:
XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid
v0.0.0-20150106093220-6724a57986af/go.mod h1:
XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2
v2.0.1 h1:
lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2
v2.0.1/go.mod h1:
+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2
v2.0.1/go.mod h1:
+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name
v1.0.0 h1:
PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name
v1.0.0/go.mod h1:
1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/sanitized_anchor_name
v1.0.0/go.mod h1:
1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus
v1.2.0/go.mod h1:
LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus
v1.2.0/go.mod h1:
LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/soheilhy/cmux
v0.1.4/go.mod h1:
IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/soheilhy/cmux
v0.1.4/go.mod h1:
IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment