Skip to content

Commit

Permalink
feat(update): update
Browse files Browse the repository at this point in the history
update

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Jul 1, 2022
1 parent 2aad046 commit c6d347e
Show file tree
Hide file tree
Showing 27 changed files with 182 additions and 93 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# on:
# push:
# branches:
# - master

# name: Generate a list of contributors

# jobs:
# contrib-readme-en-job:
# runs-on: ubuntu-latest
# name: A job to automate contrib in readme
# steps:
# - name: Contribute List
# uses: akhilmhdh/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Release
Expand Down
13 changes: 13 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ nfpms:
group: notRoot
changelog:
sort: asc
skip: false
use: github
filters:
exclude:
- '^docs:'
Expand All @@ -200,3 +202,14 @@ changelog:
order: 10
- title: Other work
order: 999

release:
# If set to true, will not auto-publish the release.
# Default is false.
draft: false

# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
[![TODOs](https://img.shields.io/endpoint?url=https://api.tickgit.com/badge?repo=github.com/easysoft/qucheng_cli)](https://www.tickgit.com/browse?repo=github.com/easysoft/qucheng_cli)
[![docs](https://img.shields.io/badge/docs-done-green)](https://www.qucheng.com/)


> 中文 | [English](README-EN.md)
使用 `qcadmin`(`q`),您可以轻松、高效、灵活地单独或整体安装渠成平台。
Expand Down Expand Up @@ -113,3 +112,11 @@ q init --podsubnet 10.42.0.0/16 --svcsubnet 10.43.0.0/16
## 相关文档

[版本升级](https://github.com/easysoft/qucheng_cli/wiki/%E7%89%88%E6%9C%AC%E5%8D%87%E7%BA%A7)

## Contributors

<!-- readme: collaborators,contributors -start -->
<!-- readme: collaborators,contributors -end -->
<a href="https://github.com/easysoft/qucheng_cli/graphs/contributors">
<img src="https://contrib.rocks/image?repo=easysoft/qucheng_cli" />
</a>
18 changes: 13 additions & 5 deletions cmd/bug-report.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,33 @@ import (
"runtime/debug"

"github.com/easysoft/qcadmin/common"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/spf13/cobra"
)

func newCmdBugReport() *cobra.Command {
type bugReportCmd struct {
log log.Logger
}

func newCmdBugReport(f factory.Factory) *cobra.Command {
br := bugReportCmd{
log: f.GetLog(),
}
cmd := &cobra.Command{
Use: "bug-report",
Short: "Display system information for bug report",
Long: "this command shares no personally-identifiable information, and is unused unless you share the bug identifier with our team.",
RunE: func(cmd *cobra.Command, args []string) error {
return bugReport()
return br.BugReport()
},
}
return cmd
}

func bugReport() error {
log := log.GetInstance()
log.Info("Issue: 🐛Bug Report: https://github.com/easysoft/qucheng_cli/issues/new?assignees=&labels=&template=bug-report.md")
func (br bugReportCmd) BugReport() error {
bugmsg := "found bug: submit the error message to Github or Gitee\n\t Github: https://github.com/easysoft/qucheng_cli/issues/new?assignees=&labels=&template=bug-report.md\n\t Gitee: https://gitee.com/wwccss/qucheng_cli/issues\n"
br.log.Info(bugmsg)
// TODO 详细信息
sprintf := func(key, val string) string {
return fmt.Sprintf("%-24s%s\n", key, val)
Expand Down
2 changes: 1 addition & 1 deletion cmd/experimental/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ import (

// HelmCommand helm command.
func HelmCommand(f factory.Factory) *cobra.Command {
return helm.EmbedCommand()
return helm.EmbedCommand(f)
}
1 change: 1 addition & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func newCmdInit(f factory.Factory) *cobra.Command {
log.Fatalf("failed to stage files: %s", err)
return
}
cp.SetLog(log)
if name != "incluster" {
if err := cp.PreSystemInit(); err != nil {
log.Fatalf("presystem init err, reason: %s", err)
Expand Down
7 changes: 3 additions & 4 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/easysoft/qcadmin/internal/app/config"
"github.com/easysoft/qcadmin/internal/pkg/providers"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/easysoft/qcadmin/internal/static"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -56,12 +55,12 @@ func newCmdJoin(f factory.Factory) *cobra.Command {
log.Fatal(err)
}
}
joinCmd.AddCommand(newCmdGenJoin())
joinCmd.AddCommand(newCmdGenJoin(f))
return joinCmd
}

func newCmdGenJoin() *cobra.Command {
log := log.GetInstance()
func newCmdGenJoin(f factory.Factory) *cobra.Command {
log := f.GetLog()
genjoin := &cobra.Command{
Use: "gen",
Short: "Generate a join command",
Expand Down
15 changes: 8 additions & 7 deletions cmd/manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@ package cmd

import (
"github.com/easysoft/qcadmin/cmd/manage"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/spf13/cobra"
)

func newCmdManage() *cobra.Command {
func newCmdManage(f factory.Factory) *cobra.Command {
m := &cobra.Command{
Use: "manage",
Short: "Manage qucheng tools",
Aliases: []string{"m", "op"},
}
m.AddCommand(manage.NewCmdPlugin())
m.AddCommand(manage.NewResetPassword())
m.AddCommand(manage.NewUpgradeQucheg())
m.AddCommand(manage.NewCmdPlugin(f))
m.AddCommand(manage.NewResetPassword(f))
m.AddCommand(manage.NewUpgradeQucheg(f))
return m
}

func newCmdManageGet() *cobra.Command {
func newCmdManageGet(f factory.Factory) *cobra.Command {
m := &cobra.Command{
Use: "get",
Short: "Display one or many resources.",
}
m.AddCommand(manage.NewCmdGetNode())
m.AddCommand(manage.NewCmdGetApp())
m.AddCommand(manage.NewCmdGetNode(f))
m.AddCommand(manage.NewCmdGetApp(f))
return m
}
8 changes: 4 additions & 4 deletions cmd/manage/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"os"

qcexec "github.com/easysoft/qcadmin/internal/pkg/util/exec"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/spf13/cobra"
)

func NewCmdGetNode() *cobra.Command {
func NewCmdGetNode(f factory.Factory) *cobra.Command {
node := &cobra.Command{
Use: "node",
Aliases: []string{"no", "nodes"},
Expand All @@ -32,8 +32,8 @@ func NewCmdGetNode() *cobra.Command {
return node
}

func NewCmdGetApp() *cobra.Command {
log := log.GetInstance()
func NewCmdGetApp(f factory.Factory) *cobra.Command {
log := f.GetLog()
app := &cobra.Command{
Use: "app",
Aliases: []string{"apps"},
Expand Down
19 changes: 10 additions & 9 deletions cmd/manage/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/easysoft/qcadmin/common"
"github.com/easysoft/qcadmin/internal/pkg/k8s"
pluginapi "github.com/easysoft/qcadmin/internal/pkg/plugin"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/output"
"github.com/easysoft/qcadmin/internal/static/deploy"
"github.com/gosuri/uitable"
Expand All @@ -21,20 +22,20 @@ import (

var show string

func NewCmdPlugin() *cobra.Command {
func NewCmdPlugin(f factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "plugins",
Short: "manage plugin",
Aliases: []string{"plugin"},
}
cmd.AddCommand(listPluginCmd())
cmd.AddCommand(installPluginCmd())
cmd.AddCommand(unInstallPluginCmd())
cmd.AddCommand(syncPluginFileCmd())
cmd.AddCommand(listPluginCmd(f))
cmd.AddCommand(installPluginCmd(f))
cmd.AddCommand(unInstallPluginCmd(f))
cmd.AddCommand(syncPluginFileCmd(f))
return cmd
}

func syncPluginFileCmd() *cobra.Command {
func syncPluginFileCmd(f factory.Factory) *cobra.Command {
sync := &cobra.Command{
Use: "sync",
Short: "sync plugin file",
Expand All @@ -52,7 +53,7 @@ func syncPluginFileCmd() *cobra.Command {
return sync
}

func listPluginCmd() *cobra.Command {
func listPluginCmd(f factory.Factory) *cobra.Command {
listcmd := &cobra.Command{
Use: "list",
Short: "list plugin",
Expand Down Expand Up @@ -93,7 +94,7 @@ func listPluginCmd() *cobra.Command {
return listcmd
}

func installPluginCmd() *cobra.Command {
func installPluginCmd(f factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "enable",
Short: "install plugin",
Expand All @@ -115,7 +116,7 @@ func installPluginCmd() *cobra.Command {
return cmd
}

func unInstallPluginCmd() *cobra.Command {
func unInstallPluginCmd(f factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "disable",
Short: "uninstall plugin",
Expand Down
6 changes: 3 additions & 3 deletions cmd/manage/resetpassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/easysoft/qcadmin/common"
"github.com/easysoft/qcadmin/internal/pkg/k8s"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/ergoapi/util/color"
"github.com/ergoapi/util/exnet"
"github.com/ergoapi/util/expass"
Expand All @@ -35,8 +35,8 @@ type Body struct {
Password string `json:"password"`
}

func NewResetPassword() *cobra.Command {
log := log.GetInstance()
func NewResetPassword(f factory.Factory) *cobra.Command {
log := f.GetLog()
var password string
rp := &cobra.Command{
Use: "reset-password",
Expand Down
7 changes: 5 additions & 2 deletions cmd/manage/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package manage
import (
"fmt"

"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/easysoft/qcadmin/pkg/qucheng/upgrade"
"github.com/spf13/cobra"
Expand All @@ -20,8 +21,10 @@ type UpgradeCmd struct {
log log.Logger
}

func NewUpgradeQucheg() *cobra.Command {
upcmd := &UpgradeCmd{}
func NewUpgradeQucheg(f factory.Factory) *cobra.Command {
upcmd := &UpgradeCmd{
log: f.GetLog(),
}
up := &cobra.Command{
Use: "upgrade",
Short: "Upgrades the QuCheng to the newest version",
Expand Down
3 changes: 2 additions & 1 deletion cmd/precheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ package cmd

import (
"github.com/easysoft/qcadmin/cmd/precheck"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/spf13/cobra"
)

func newCmdPreCheck() *cobra.Command {
func newCmdPreCheck(f factory.Factory) *cobra.Command {
var pc precheck.PreCheck
cmd := &cobra.Command{
Use: "precheck",
Expand Down
29 changes: 18 additions & 11 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/easysoft/qcadmin/cmd/flags"
"github.com/easysoft/qcadmin/common"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
mcobra "github.com/muesli/mango-cobra"
"github.com/muesli/roff"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -46,6 +47,11 @@ func Execute() {
} else {
f.GetLog().Fatal(err)
}
if !strings.Contains(err.Error(), "unknown command") {
f.GetLog().Info("----------------------------")
bugmsg := "found bug: submit the error message to Github or Gitee\n\t Github: https://github.com/easysoft/qucheng_cli/issues/new?assignees=&labels=&template=bug-report.md\n\t Gitee: https://gitee.com/wwccss/qucheng_cli/issues"
f.GetLog().Info(bugmsg)
}
}
}

Expand All @@ -56,20 +62,20 @@ func BuildRoot(f factory.Factory) *cobra.Command {
persistentFlags := rootCmd.PersistentFlags()
globalFlags = flags.SetGlobalFlags(persistentFlags)
// Add main commands
rootCmd.AddCommand(newCmdVersion())
rootCmd.AddCommand(newCmdPreCheck())
rootCmd.AddCommand(newCmdVersion(f))
rootCmd.AddCommand(newCmdPreCheck(f))
rootCmd.AddCommand(newCmdInit(f))
rootCmd.AddCommand(newCmdJoin(f))
rootCmd.AddCommand(newCmdUninstall())
rootCmd.AddCommand(newCmdStatus())
rootCmd.AddCommand(newCmdUpgrade())
rootCmd.AddCommand(newCmdManage())
rootCmd.AddCommand(newCmdManageGet())
rootCmd.AddCommand(newCmdUninstall(f))
rootCmd.AddCommand(newCmdStatus(f))
rootCmd.AddCommand(newCmdUpgrade(f))
rootCmd.AddCommand(newCmdManage(f))
rootCmd.AddCommand(newCmdManageGet(f))
// Add plugin commands

rootCmd.AddCommand(NewCmdExperimental(f))
rootCmd.AddCommand(newManCmd())
rootCmd.AddCommand(newCmdBugReport())
rootCmd.AddCommand(newCmdBugReport(f))

args := os.Args
if len(args) > 1 {
Expand Down Expand Up @@ -110,13 +116,14 @@ func NewRootCmd(f factory.Factory) *cobra.Command {
if cobraCmd.Annotations != nil {
return nil
}
log := f.GetLog()
qlog := f.GetLog()
if globalFlags.Silent {
log.SetLevel(logrus.FatalLevel)
qlog.SetLevel(logrus.FatalLevel)
} else if globalFlags.Debug {
log.SetLevel(logrus.DebugLevel)
qlog.SetLevel(logrus.DebugLevel)
}

log.StartFileLogging()
// TODO apply extra flags
return nil
},
Expand Down
Loading

0 comments on commit c6d347e

Please sign in to comment.