Skip to content

Commit fca238d

Browse files
author
GwonsooLee
committed
add docs
1 parent bda4b4f commit fca238d

File tree

139 files changed

+8694
-605
lines changed

Some content is hidden

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

139 files changed

+8694
-605
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
.idea
33
*.csv
44

5+
out
6+
build
57
hack/bin
68

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright [yyyy] [name of copyright owner]
190+
Copyright 2020 Redhawk Authors
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

Makefile

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2020 The redhawk Authors
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+
115
GOOS ?= $(shell go env GOOS)
216
GOARCH ?= amd64
317
BUILD_DIR ?= ./out
@@ -132,8 +146,12 @@ linters: $(BUILD_DIR)
132146
# utilities for redhawk site - not used anywhere else
133147
.PHONY: preview-docs-draft
134148
preview-docs-draft:
135-
./deploy/docs/preview-docs.sh hugo serve -D --bind=0.0.0.0 --ignoreCache
149+
./deploy/docs/preview-docs.sh hugo server -D --bind=0.0.0.0 --ignoreCache
136150

137151
.PHONY: preview-docs
138152
preview-docs:
139-
./deploy/docs/preview-docs.sh hugo serve --bind=0.0.0.0 --ignoreCache
153+
./deploy/docs/preview-docs.sh hugo server --bind=0.0.0.0 --ignoreCache
154+
155+
.PHONY: generate-schema
156+
generate-schema:
157+
go run ./hack/schemas/main.go

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $ source ~/.bashrc
3838
Opensource cloud resources audit and management tool
3939

4040
checking all resources in cloud provider
41-
scan-resources Scan infrastructure resources in AWS
41+
list Scan infrastructure resources in AWS
4242

4343
Other Commands:
4444
completion Output shell completion for the given shell (bash or zsh)

cmd/redhawk/app/bnx.go

-18
This file was deleted.

cmd/redhawk/app/redhawk.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package app
18+
19+
import (
20+
"context"
21+
"io"
22+
23+
"github.com/DevopsArtFactory/redhawk/cmd/redhawk/cmd"
24+
)
25+
26+
func Run(out, stderr io.Writer) error {
27+
ctx, cancel := context.WithCancel(context.Background())
28+
defer cancel()
29+
30+
catchCtrlC(cancel)
31+
32+
c := cmd.NewRootCommand(out, stderr)
33+
return c.ExecuteContext(ctx)
34+
}

cmd/redhawk/cmd/builder/builder.go

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package builder
218

319
import (
@@ -18,6 +34,7 @@ type Builder interface {
1834
RunWithNoArgs(action func(context.Context, io.Writer) error) *cobra.Command
1935
RunWithArgs(action func(context.Context, io.Writer, []string) error) *cobra.Command
2036
RunWithArgsAndCmd(action func(context.Context, io.Writer, *cobra.Command, []string) error) *cobra.Command
37+
RunWithCmdAndNoArgs(action func(context.Context, io.Writer, *cobra.Command) error) *cobra.Command
2138
}
2239

2340
type builder struct {
@@ -76,6 +93,14 @@ func (b builder) RunWithArgsAndCmd(function func(context.Context, io.Writer, *co
7693
return &b.cmd
7794
}
7895

96+
// Run command with cmd but no args
97+
func (b builder) RunWithCmdAndNoArgs(function func(context.Context, io.Writer, *cobra.Command) error) *cobra.Command {
98+
b.cmd.RunE = func(_ *cobra.Command, args []string) error {
99+
return returnErrorFromFunction(function(b.cmd.Context(), b.cmd.OutOrStderr(), &b.cmd))
100+
}
101+
return &b.cmd
102+
}
103+
79104
// SetFlags attaches flags to commands
80105
func (b builder) SetFlags() Builder {
81106
SetCommandFlags(&b.cmd)

cmd/redhawk/cmd/builder/flag.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package builder
218

319
import (
@@ -35,23 +51,23 @@ var FlagRegistry = []Flag{
3551
Value: aws.String(constants.EmptyString),
3652
DefValue: constants.EmptyString,
3753
FlagAddMethod: "StringVar",
38-
DefinedOn: []string{"scan-resources"},
54+
DefinedOn: []string{"list"},
3955
},
4056
{
4157
Name: "config",
4258
Usage: "configuration file path for scanning resources",
4359
Value: aws.String(constants.EmptyString),
4460
DefValue: constants.EmptyString,
4561
FlagAddMethod: "StringVar",
46-
DefinedOn: []string{"scan-resources"},
62+
DefinedOn: []string{"list"},
4763
},
4864
{
4965
Name: "detail",
5066
Usage: "detailed options for scanning",
5167
Value: aws.Bool(false),
5268
DefValue: false,
5369
FlagAddMethod: "BoolVar",
54-
DefinedOn: []string{"scan-resources"},
70+
DefinedOn: []string{"list"},
5571
},
5672
{
5773
Name: "all",
@@ -60,15 +76,15 @@ var FlagRegistry = []Flag{
6076
Shorthand: "A",
6177
DefValue: false,
6278
FlagAddMethod: "BoolVar",
63-
DefinedOn: []string{"scan-resources"},
79+
DefinedOn: []string{"list"},
6480
},
6581
{
6682
Name: "resources",
67-
Usage: "Resource list of provider for dynamic search(Delimiter: comma)",
83+
Usage: "[Required]Resource list of provider for dynamic search(Delimiter: comma)",
6884
Value: aws.String(constants.EmptyString),
6985
DefValue: constants.EmptyString,
7086
FlagAddMethod: "StringVar",
71-
DefinedOn: []string{"scan-resources"},
87+
DefinedOn: []string{"list"},
7288
},
7389
{
7490
Name: "output",
@@ -77,7 +93,7 @@ var FlagRegistry = []Flag{
7793
Value: aws.String(constants.DefaultOutputFormat),
7894
DefValue: constants.DefaultOutputFormat,
7995
FlagAddMethod: "StringVar",
80-
DefinedOn: []string{"scan-resources"},
96+
DefinedOn: []string{"list"},
8197
},
8298
}
8399

cmd/redhawk/cmd/cmd.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package cmd
218

319
import (
@@ -40,7 +56,7 @@ func NewRootCommand(out, stderr io.Writer) *cobra.Command {
4056

4157
version := version.Get()
4258

43-
logrus.Infof("redhawk %+v", version)
59+
logrus.Debugf("redhawk %+v", version)
4460
return nil
4561
},
4662
RunE: func(cmd *cobra.Command, args []string) error {
@@ -53,7 +69,7 @@ func NewRootCommand(out, stderr io.Writer) *cobra.Command {
5369
{
5470
Message: "checking all resources in cloud provider",
5571
Commands: []*cobra.Command{
56-
NewCmdScanResources(),
72+
NewCmdList(),
5773
},
5874
},
5975
}

cmd/redhawk/cmd/completion.go

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package cmd
218

319
import (

cmd/redhawk/cmd/list.go

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package cmd
18+
19+
import (
20+
"context"
21+
"io"
22+
23+
"github.com/spf13/cobra"
24+
25+
"github.com/DevopsArtFactory/redhawk/cmd/redhawk/cmd/builder"
26+
"github.com/DevopsArtFactory/redhawk/pkg/executor"
27+
)
28+
29+
// List resources in detail
30+
func NewCmdList() *cobra.Command {
31+
return builder.NewCmd("list").
32+
WithDescription("list infrastructure resources in AWS").
33+
SetFlags().
34+
RunWithCmdAndNoArgs(funcList)
35+
}
36+
37+
// funcList
38+
func funcList(ctx context.Context, out io.Writer, cmd *cobra.Command) error {
39+
return executor.RunExecutor(ctx, func(executor executor.Executor) error {
40+
return executor.Runner.List(out)
41+
})
42+
}

cmd/redhawk/cmd/scan_resources.go

-26
This file was deleted.

cmd/redhawk/cmd/version.go

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
Copyright 2020 The redhawk Authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
117
package cmd
218

319
import (

0 commit comments

Comments
 (0)