Skip to content

Commit 1e56004

Browse files
pull[bot]zzjinfengxsongSignorMercuriocuisongliu
authored
[pull] main from labring:main (#302)
* Update go1.18 to support workspace (labring#1350) * Update go1.18 to support workspace Signed-off-by: zzjin <[email protected]> * fix linter vendor Signed-off-by: zzjin <[email protected]> * update develop guide about workspace. (labring#1352) Signed-off-by: zzjin <[email protected]> * refactor: clean flag of lvscare (labring#1354) * refactor: clean flag of lvscare Signed-off-by: fengxsong <[email protected]> * fix: ci lints Signed-off-by: fengxsong <[email protected]> * docs: remove badges for lvscare (labring#1358) Signed-off-by: Mercurio <[email protected]> * ci: fix sync_code trigger paths (labring#1360) Signed-off-by: Mercurio <[email protected]> * fix(main): delete logger for isLocal (labring#1359) Signed-off-by: cuisongliu <[email protected]> * fix(main): sync is exists (labring#1361) Signed-off-by: cuisongliu <[email protected]> * add & init sealos desktop frontend project (labring#1357) * init frontend project * impl part of dashboard page layout * logger support fulltext color (labring#1362) * support service modules: auth (labring#1347) 1. add first auth service 2. update workspace to support service/auth 3. move soem code to auth pkg and auth service Signed-off-by: zzjin <[email protected]> * feature(main): local ip not ping (labring#1363) Signed-off-by: cuisongliu <[email protected]> * feat: auto create dummy link if needed (labring#1367) * feat: auto create dummy link if needed Signed-off-by: fengxsong <[email protected]> * fix: make iface arg defaults to empty Signed-off-by: fengxsong <[email protected]> * fix(main): unexpected end of file (labring#1372) * update pull request template to supress showing (labring#1371) Signed-off-by: zzjin <[email protected]> * perf: singleton just fine (labring#1374) Signed-off-by: fengxsong <[email protected]> Co-authored-by: zzjin <[email protected]> Co-authored-by: fengxsong <[email protected]> Co-authored-by: Mercurio <[email protected]> Co-authored-by: cuisongliu <[email protected]> Co-authored-by: 马斯洛 <[email protected]> Co-authored-by: xuehaipeng <[email protected]>
1 parent 91a2445 commit 1e56004

Some content is hidden

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

64 files changed

+12128
-381
lines changed

.devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.1/containers/go/.devcontainer/base.Dockerfile
22

33
# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster
4-
ARG VARIANT="1.18-bullseye"
4+
ARG VARIANT="1-bullseye"
55
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
66

77
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10

.github/PULL_REQUEST_TEMPLATE.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// If you are developing a feature, please provide documentation,
2-
// if you are solving a bug, please associate the corresponding issue
3-
// Please standardize the title and introduction information of the PR,
4-
// because it will be placed in the release note
1+
<!--
2+
If you are developing a feature, please provide documentation.
3+
If you are solving a bug, please associate the corresponding issue.
4+
Please standardize the title and introduction information of the PR,
5+
because it will be placed in the release note
6+
-->

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: CI
22

33
env:
44
# Common versions
5-
GO_VERSION: "1.17"
5+
GO_VERSION: "1.18"
66

77
on:
88
push:
9-
branches: main
9+
branches: ["main"]
1010
paths-ignore:
1111
- "docs/**"
1212
- "**/*.md"

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
env:
44
# Common versions
5-
GO_VERSION: "1.17"
5+
GO_VERSION: "1.18"
66

77
on:
88
workflow_dispatch:

.github/workflows/sync_code.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- main
66
paths:
7-
- staging/src/github.com/labring
7+
- staging/src/github.com/labring/**
88
workflow_dispatch:
99
jobs:
1010
sync:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ tools
1616
coverage.out
1717
tmp
1818
./pkg/infra/controller/bin
19+
desktop/.DS_Store

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ run:
88
# default is true. Enables skipping of directories:
99
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
1010
skip-dirs-use-default: true
11-
modules-download-mode: mod
11+
modules-download-mode: readonly
1212

1313
linters:
1414
# please, do not use `enable-all`: it's deprecated and will be removed soon.

DEVELOPGUIDE.md

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ Then test it locally.
2727
All the binaries except `sealos` can be built anywhere since they have `CGO_ENABLED=0`. However, `sealos` needs to support overlay driver when running some subcommands like `images`, which relies on CGO. Therefore CGO is switched on when building `sealos`, making it impossible to build `sealos` binaries on platforms other than Linux.
2828

2929
> Both Makefile and GoReleaser in this project have this setting.
30+
31+
## Notes about go workspace
32+
33+
As sealos is using go1.18's workspace feature, once you add a new module, you need to run `go work usr -r .` at root directry to update the workspace synced.

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM --platform=$BUILDPLATFORM golang:1.17-buster as builder
15+
FROM --platform=$BUILDPLATFORM golang:1-bullseye as builder
1616
ARG GITHUB_TOKEN=$GITHUB_TOKEN
1717
ARG TARGETARCH
1818
ARG ACTION=build-pack

cmd/desktop/cmd/root.go

-42
This file was deleted.

cmd/desktop/main.go

-23
This file was deleted.

cmd/lvscare/cmd/care.go

+11-27
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,34 @@
1515
package cmd
1616

1717
import (
18+
"github.com/spf13/cobra"
19+
1820
"github.com/labring/lvscare/care"
21+
"github.com/labring/sealos/pkg/utils/flags"
1922
"github.com/labring/sealos/pkg/utils/logger"
20-
"github.com/spf13/cobra"
2123
)
2224

2325
// careCmd represents the care command
2426
var careCmd = &cobra.Command{
2527
Use: "care",
2628
Short: "A lightweight LVS baby care, support ipvs health check.",
27-
Run: func(cmd *cobra.Command, args []string) {
28-
care.LVS.VsAndRsCare()
29+
RunE: func(cmd *cobra.Command, args []string) error {
30+
return care.LVS.VsAndRsCare()
2931
},
3032
PreRunE: func(cmd *cobra.Command, args []string) error {
31-
if err := care.SetTargetIP(); err != nil {
33+
flags.PrintFlags(cmd.Flags())
34+
if err := care.LVS.ValidateAndSetDefaults(); err != nil {
3235
return err
3336
}
34-
// if target ip is empty, skip sync router
35-
if care.LVS.TargetIP == nil {
36-
return nil
37+
if !care.LVS.Clean {
38+
return care.LVS.SyncRouter()
3739
}
38-
return care.LVS.SyncRouter()
40+
return nil
3941
},
4042
}
4143

4244
func init() {
4345
cobra.OnInitialize(func() {
44-
//TODO: expose showPath flag?
4546
switch care.LVS.Logger {
4647
case "INFO":
4748
logger.CfgConsoleLogger(false, false)
@@ -51,23 +52,6 @@ func init() {
5152
logger.CfgConsoleLogger(false, false)
5253
}
5354
})
55+
care.LVS.RegisterFlags(careCmd.Flags())
5456
rootCmd.AddCommand(careCmd)
55-
// Here you will define your flags and configuration settings.
56-
57-
// Cobra supports Persistent Flags which will work for this command
58-
// and all subcommands, e.g.:
59-
// careCmd.PersistentFlags().String("foo", "", "A help for foo")
60-
careCmd.Flags().IPVar(&care.LVS.TargetIP, "ip", nil, "target ip")
61-
careCmd.Flags().BoolVar(&care.LVS.RunOnce, "run-once", false, "is run once mode")
62-
careCmd.Flags().StringVar(&care.LVS.VirtualServer, "vs", "", "virtual server like 10.54.0.2:6443")
63-
careCmd.Flags().StringSliceVar(&care.LVS.RealServer, "rs", []string{}, "real server like 192.168.0.2:6443")
64-
careCmd.Flags().StringVar(&care.LVS.Logger, "logger", "INFO", "logger level: DEBG/INFO")
65-
careCmd.Flags().BoolVar(&care.LVS.Clean, "clean", false, "before run clean ipvs rules")
66-
67-
careCmd.Flags().StringVar(&care.LVS.HealthPath, "health-path", "/healthz", "health check path")
68-
careCmd.Flags().StringVar(&care.LVS.HealthSchem, "health-schem", "https", "health check schem")
69-
careCmd.Flags().Int32Var(&care.LVS.Interval, "interval", 5, "health check interval, unit is sec.")
70-
// Cobra supports local flags which will only run when this command
71-
// is called directly, e.g.:
72-
// careCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
7357
}

cmd/sealctl/cmd/ipvs.go

+8-48
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,31 @@
1515
package cmd
1616

1717
import (
18-
"net"
19-
20-
"github.com/labring/lvscare/pkg/route"
21-
22-
"github.com/labring/lvscare/care"
2318
"github.com/spf13/cobra"
2419

25-
"github.com/labring/sealos/pkg/constants"
20+
"github.com/labring/lvscare/care"
2621
"github.com/labring/sealos/pkg/utils/flags"
27-
"github.com/labring/sealos/pkg/utils/hosts"
28-
"github.com/labring/sealos/pkg/utils/iputils"
29-
"github.com/labring/sealos/pkg/utils/logger"
3022
)
3123

3224
func newIPVSCmd() *cobra.Command {
33-
var clean bool
34-
var vip string
3525
var ipvsCmd = &cobra.Command{
3626
Use: "ipvs",
3727
Short: "sealos create or care local ipvs lb",
3828
RunE: func(cmd *cobra.Command, args []string) error {
39-
if clean {
40-
lvs := care.BuildLvscare()
41-
if err := lvs.DeleteVirtualServer(care.LVS.VirtualServer, false); err != nil {
42-
return err
43-
}
44-
logger.Info("lvscare delete vip: %s success", care.LVS.VirtualServer)
45-
routeOperator := route.NewRoute(vip, care.LVS.TargetIP.String())
46-
if err := routeOperator.DelRoute(); err != nil {
47-
return err
48-
}
49-
logger.Info("lvscare delete route: %s success", care.LVS.VirtualServer)
50-
return nil
51-
}
52-
care.LVS.VsAndRsCare()
53-
return nil
29+
return care.LVS.VsAndRsCare()
5430
},
5531
PreRunE: func(cmd *cobra.Command, args []string) error {
5632
flags.PrintFlags(cmd.Flags())
57-
if care.LVS.TargetIP == nil {
58-
hf := &hosts.HostFile{Path: constants.DefaultHostsPath}
59-
if ip, ok := hf.HasDomain(constants.DefaultLvscareDomain); ok {
60-
care.LVS.TargetIP = net.ParseIP(ip)
61-
}
62-
logger.Debug("found target route ip is %s", care.LVS.TargetIP.String())
63-
if !clean {
64-
if err := care.LVS.SyncRouter(); err != nil {
65-
return err
66-
}
67-
}
33+
if err := care.LVS.ValidateAndSetDefaults(); err != nil {
34+
return err
35+
}
36+
if !care.LVS.Clean {
37+
return care.LVS.SyncRouter()
6838
}
69-
care.LVS.Clean = true
70-
vip = iputils.GetHostIP(care.LVS.VirtualServer)
7139
return nil
7240
},
7341
}
74-
ipvsCmd.Flags().BoolVarP(&clean, "clean", "C", false, "clean ipvs and route")
75-
ipvsCmd.Flags().BoolVar(&care.LVS.RunOnce, "run-once", false, "is run once mode")
76-
ipvsCmd.Flags().StringVar(&care.LVS.VirtualServer, "vs", "", "virturl server like 10.54.0.2:6443")
77-
ipvsCmd.Flags().StringSliceVar(&care.LVS.RealServer, "rs", []string{}, "real server like 192.168.0.2:6443")
78-
ipvsCmd.Flags().IPVar(&care.LVS.TargetIP, "ip", nil, "target ip")
79-
80-
ipvsCmd.Flags().StringVar(&care.LVS.HealthPath, "health-path", "/healthz", "health check path")
81-
ipvsCmd.Flags().StringVar(&care.LVS.HealthSchem, "health-schem", "https", "health check schem")
82-
ipvsCmd.Flags().Int32Var(&care.LVS.Interval, "interval", 5, "health check interval, unit is sec.")
42+
care.LVS.RegisterFlags(ipvsCmd.Flags())
8343
return ipvsCmd
8444
}
8545

0 commit comments

Comments
 (0)