Skip to content

Commit 308ad1c

Browse files
author
ethanluo
committed
init project
1 parent 39478a5 commit 308ad1c

File tree

19 files changed

+2625
-0
lines changed

19 files changed

+2625
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
assets
18+
test

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 codeandcode0x
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

cmd/helmtrans_cmd.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
helmtrans "helmtrans/src"
6+
)
7+
8+
var filePath, outPutPath string
9+
10+
//init
11+
func init() {
12+
//migration data
13+
helmtransYamltoHelmCmd.Flags().StringVarP(&filePath, "path", "p", "", "file path")
14+
helmtransYamltoHelmCmd.Flags().StringVarP(&outPutPath, "outpath", "o", "output", "output file path")
15+
rootCmd.AddCommand(helmtransYamltoHelmCmd)
16+
17+
helmtransHelmtoYamlCmd.Flags().StringVarP(&filePath, "path", "p", "", "file path")
18+
rootCmd.AddCommand(helmtransHelmtoYamlCmd)
19+
20+
helmtransCheckCmd.Flags().StringVarP(&filePath, "path", "p", "", "file path")
21+
rootCmd.AddCommand(helmtransCheckCmd)
22+
}
23+
24+
//register deploy command
25+
var helmtransYamltoHelmCmd = &cobra.Command{
26+
Use: "yamltohelm",
27+
Short: "Transform yaml to helm",
28+
Long: `Transform yaml to helm`,
29+
Run: func(cmd *cobra.Command, args []string) {
30+
//TO-DO
31+
helmtrans.YamltoHelm(filePath, outPutPath)
32+
},
33+
}
34+
35+
//register reset command
36+
var helmtransHelmtoYamlCmd = &cobra.Command{
37+
Use: "helmtoyaml",
38+
Short: "Transform helm to yaml",
39+
Long: `Transform helm to yaml`,
40+
Run: func(cmd *cobra.Command, args []string) {
41+
//TO-DO
42+
},
43+
}
44+
45+
//register analyse command
46+
var helmtransCheckCmd = &cobra.Command{
47+
Use: "check",
48+
Short: "Check helm",
49+
Long: `Check helm`,
50+
Run: func(cmd *cobra.Command, args []string) {
51+
//TO-DO
52+
53+
},
54+
}
55+
56+
57+
58+
59+
60+

cmd/root.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
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+
package cmd
17+
18+
import (
19+
"fmt"
20+
"github.com/spf13/cobra"
21+
"os"
22+
)
23+
24+
var cfgFile string
25+
26+
// rootCmd represents the base command when called without any subcommands
27+
var rootCmd = &cobra.Command{
28+
Use: "helmtrans [command] [options]",
29+
Short: "helmtrans can transform yaml to helm and the other way around",
30+
Long: `
31+
helmtrans is a CLI library for Go that support yaml to helm,
32+
also helm to yaml. You can use it as http request to transform.`,
33+
// Uncomment the following line if your bare application
34+
// has an action associated with it:
35+
// Run: func(cmd *cobra.Command, args []string) { },
36+
}
37+
38+
// Execute adds all child commands to the root command and sets flags appropriately.
39+
// This is called by main.main(). It only needs to happen once to the rootCmd.
40+
func Execute() {
41+
if err := rootCmd.Execute(); err != nil {
42+
fmt.Println(err)
43+
os.Exit(1)
44+
}
45+
}
46+

cmd/version.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func init() {
9+
rootCmd.AddCommand(versionCmd)
10+
}
11+
12+
var versionCmd = &cobra.Command{
13+
Use: "version",
14+
Short: "Print the version number of helmtrans",
15+
Long: `All software has versions. This is helmtrans's`,
16+
Run: func(cmd *cobra.Command, args []string) {
17+
fmt.Println("helmtrans version is v0.1.0")
18+
},
19+
}

doc/.gitignore

Whitespace-only changes.

go.mod

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module helmtrans
2+
3+
go 1.14
4+
5+
require (
6+
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect
7+
github.com/drone/envsubst v1.0.2
8+
github.com/fatih/color v1.9.0 // indirect
9+
github.com/ghodss/yaml v1.0.0
10+
github.com/go-sql-driver/mysql v1.5.0 // indirect
11+
github.com/googleapis/gnostic v0.5.1 // indirect
12+
github.com/imdario/mergo v0.3.11 // indirect
13+
github.com/rs/xid v1.2.1
14+
github.com/spf13/cobra v1.1.1
15+
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
16+
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
17+
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
18+
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
19+
gopkg.in/yaml.v2 v2.3.0
20+
k8s.io/api v0.19.0
21+
k8s.io/apimachinery v0.19.0
22+
k8s.io/client-go v0.19.0
23+
k8s.io/klog v1.0.0 // indirect
24+
k8s.io/utils v0.0.0-20200912215256-4140de9c8800 // indirect
25+
)

0 commit comments

Comments
 (0)