generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3489990
commit 432b6c4
Showing
14 changed files
with
641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package static | ||
|
||
import ( | ||
"github.com/cloudwego/cwgo/pkg/consts" | ||
"github.com/cloudwego/cwgo/tpl" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func dockerFlags() []cli.Flag { | ||
return []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: consts.GoVersion, | ||
Usage: "Specify the go version.", | ||
Aliases: []string{"go"}, | ||
Required: true, | ||
}, | ||
&cli.BoolFlag{ | ||
Name: consts.EnableGoProxy, | ||
Usage: "Enable go proxy.", | ||
DefaultText: "false", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.GoProxy, | ||
Usage: "Specify the go proxy.", | ||
DefaultText: "https://goproxy.cn,direct", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Timezone, | ||
Usage: "Specify the timezone.", | ||
DefaultText: "Asia/Shanghai", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.BaseImage, | ||
Usage: "Specify the base image.", | ||
DefaultText: "scratch", | ||
}, | ||
&cli.IntFlag{ | ||
Name: consts.Port, | ||
Usage: "Specify the port.", | ||
DefaultText: "0", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.GoFileName, | ||
Usage: "Specify the go file name.", | ||
Aliases: []string{"f"}, | ||
Required: true, | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.ExeFileName, | ||
Usage: "Specify the exe file name.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Template, | ||
Usage: "Specify the template path. Currently cwgo supports git templates, such as `--template https://github.com/***/cwgo_template.git`", | ||
Aliases: []string{"t"}, | ||
DefaultText: tpl.DockerDir, | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Branch, | ||
Usage: "Specify the git template's branch, default is main branch.", | ||
}, | ||
&cli.StringSliceFlag{ | ||
Name: consts.RunArgs, | ||
Usage: "Specify the run args.", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package static | ||
|
||
import ( | ||
"github.com/cloudwego/cwgo/pkg/consts" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func kubeFlags() []cli.Flag { | ||
return []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: consts.Name, | ||
Usage: "Specify the name of the service.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Namespace, | ||
Usage: "Specify the namespace.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Image, | ||
Usage: "Specify the image.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Secret, | ||
Usage: "Specify the secret.", | ||
}, | ||
&cli.IntFlag{ | ||
Name: consts.RequestCpu, | ||
Usage: "Specify the request cpu.", | ||
DefaultText: "500", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.RequestMem, | ||
Usage: "Specify the request memory.", | ||
DefaultText: "512", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.LimitCpu, | ||
Usage: "Specify the limit cpu.", | ||
DefaultText: "1000", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.LimitMem, | ||
Usage: "Specify the limit memory.", | ||
DefaultText: "1024", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.Port, | ||
Usage: "Specify the port.", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.MinReplicas, | ||
Usage: "Specify the min replicas.", | ||
DefaultText: "3", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.MaxReplicas, | ||
Usage: "Specify the max replicas.", | ||
DefaultText: "10", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.ImagePullPolicy, | ||
Usage: "Specify the image pull policy. (Always or IfNotPresent or Never)", | ||
}, | ||
&cli.StringFlag{ | ||
Name: consts.ServiceAccount, | ||
Usage: "Specify the service account.", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/cloudwego/cwgo/pkg/consts" | ||
"github.com/urfave/cli/v2" | ||
"strings" | ||
) | ||
|
||
type DockerArgument struct { | ||
GoVersion string // compile image go version | ||
EnableGoProxy bool // enable go proxy | ||
GoProxy string // go proxy url | ||
Timezone string // image timezone | ||
BaseImage string // service run image | ||
Port int // docker image expose port | ||
GoFileName string // go project main file name | ||
ExeFileName string // build exe file name | ||
Template string // specify local or remote template path | ||
Branch string // remote template branch | ||
RunArgs string // ext run args | ||
} | ||
|
||
func NewDockerArgument() *DockerArgument { | ||
return &DockerArgument{} | ||
} | ||
|
||
func (c *DockerArgument) ParseCli(ctx *cli.Context) error { | ||
c.GoVersion = ctx.String(consts.GoVersion) | ||
c.EnableGoProxy = ctx.Bool(consts.EnableGoProxy) | ||
c.GoProxy = ctx.String(consts.GoProxy) | ||
c.Timezone = ctx.String(consts.Timezone) | ||
c.BaseImage = ctx.String(consts.BaseImage) | ||
c.Port = ctx.Int(consts.Port) | ||
c.GoFileName = ctx.String(consts.GoFileName) | ||
c.ExeFileName = ctx.String(consts.ExeFileName) | ||
c.Template = ctx.String(consts.Template) | ||
var builder strings.Builder | ||
for _, arg := range ctx.StringSlice(consts.RunArgs) { | ||
builder.WriteString(`, "` + arg + `"`) | ||
} | ||
c.RunArgs = builder.String() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/cloudwego/cwgo/pkg/consts" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
type KubeArgument struct { | ||
Name string | ||
Namespace string | ||
Image string | ||
Secret string | ||
RequestCpu int | ||
RequestMem string | ||
LimitCpu string | ||
LimitMem string | ||
MinReplicas int | ||
MaxReplicas int | ||
ImagePullPolicy string | ||
ServiceAccount string | ||
} | ||
|
||
func NewKubeArgument() *KubeArgument { | ||
return &KubeArgument{} | ||
} | ||
|
||
func (c *KubeArgument) ParseCli(ctx *cli.Context) error { | ||
c.Name = ctx.String(consts.Name) | ||
c.Namespace = ctx.String(consts.Namespace) | ||
c.Image = ctx.String(consts.Image) | ||
c.Secret = ctx.String(consts.Secret) | ||
c.RequestCpu = ctx.Int(consts.RequestCpu) | ||
c.RequestMem = ctx.String(consts.RequestMem) | ||
c.LimitCpu = ctx.String(consts.LimitCpu) | ||
c.LimitMem = ctx.String(consts.LimitMem) | ||
c.MinReplicas = ctx.Int(consts.MinReplicas) | ||
c.MaxReplicas = ctx.Int(consts.MaxReplicas) | ||
c.ImagePullPolicy = ctx.String(consts.ImagePullPolicy) | ||
c.ServiceAccount = ctx.String(consts.ServiceAccount) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.