refactor(v2): upgrade module to github.com/alibaba/higress/v2 (#2922)

Signed-off-by: Xijun Dai <daixijun1990@gmail.com>
This commit is contained in:
Xijun Dai
2025-09-21 14:29:07 +08:00
committed by GitHub
parent cd2082033c
commit 47827ad271
235 changed files with 1077 additions and 1045 deletions

View File

@@ -423,13 +423,11 @@ func (b *Builder) filesHandler() error {
return nil
}
var (
optionalProducts = [][2]string{
{"README_ZH.md", MediaTypeREADME_ZH},
{"README_EN.md", MediaTypeREADME_EN},
{"icon.png", MediaTypeIcon},
}
)
var optionalProducts = [][2]string{
{"README_ZH.md", MediaTypeREADME_ZH},
{"README_EN.md", MediaTypeREADME_EN},
{"icon.png", MediaTypeIcon},
}
// TODO(WeixinX): If the image exists, no push is performed
func (b *Builder) imageHandler() error {
@@ -536,7 +534,7 @@ func (b *Builder) config(f ConfigFunc) (err error) {
if err != nil {
return errors.Wrapf(err, "failed to parse output destination %q", b.Output.Dest)
}
err = os.MkdirAll(b.Output.Dest, 0755)
err = os.MkdirAll(b.Output.Dest, 0o755)
if err != nil && !os.IsExist(err) {
return errors.Wrapf(err, "failed to create output destination %q", b.Output.Dest)
}
@@ -574,7 +572,7 @@ func (b *Builder) config(f ConfigFunc) (err error) {
if err != nil && !os.IsExist(err) {
return errors.Wrap(err, "failed to create the docker entrypoint file")
}
err = dockerEp.Chmod(0777)
err = dockerEp.Chmod(0o777)
if err != nil {
return err
}

View File

@@ -47,11 +47,11 @@ cd {{ .BuildDestDir }}
tar czf plugin.tar.gz plugin.wasm
cmd="{{ .BasicCmd }}"
products=({{ .Products }})
for ((i=0; i<${#products[*]}; i=i+2)); do
for ((i=0; i<${#products[*]}; i=i+2)); do
f=${products[i]}
typ=${products[i+1]}
if [ -e ${f} ]; then
cmd="${cmd} ./${f}:${typ}"
if [ -e ${f} ]; then
cmd="${cmd} ./${f}:${typ}"
fi
done
cmd="${cmd} ./plugin.tar.gz:{{ .MediaTypePlugin }}"
@@ -79,7 +79,7 @@ type ImageTmplFields struct {
}
func genFilesDockerEntrypoint(ft *FilesTmplFields, target string) error {
f, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, 0777)
f, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, 0o777)
if err != nil {
return err
}
@@ -93,7 +93,7 @@ func genFilesDockerEntrypoint(ft *FilesTmplFields, target string) error {
}
func genImageDockerEntrypoint(it *ImageTmplFields, target string) error {
f, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, 0777)
f, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, 0o777)
if err != nil {
return err
}

View File

@@ -49,7 +49,7 @@ func create(w io.Writer, target string) error {
if err != nil {
return errors.Wrap(err, "invalid target path")
}
if err = os.MkdirAll(target, 0755); err != nil {
if err = os.MkdirAll(target, 0o755); err != nil {
return err
}
if err = GenPluginConfYAML(configHelpTmpl, target); err != nil {

View File

@@ -22,7 +22,7 @@ import (
"os"
k8s "github.com/alibaba/higress/hgctl/pkg/kubernetes"
"github.com/alibaba/higress/pkg/cmd/options"
"github.com/alibaba/higress/v2/pkg/cmd/options"
"github.com/pkg/errors"
"github.com/spf13/cobra"

View File

@@ -156,5 +156,4 @@ func (pc *PluginConf) withDefaultValue() {
if pc.Phase == "" {
pc.Phase = string(types.PhaseDefault)
}
}

View File

@@ -63,7 +63,7 @@ func runInit(w io.Writer, target string) (err error) {
return errors.Wrap(err, "invalid target directory")
}
dir := fmt.Sprintf("%s/%s", target, ans.Name)
err = os.MkdirAll(dir, 0755)
err = os.MkdirAll(dir, 0o755)
defer func() {
if err != nil {
os.RemoveAll(dir)

View File

@@ -28,7 +28,7 @@ import (
"github.com/alibaba/higress/hgctl/pkg/plugin/option"
"github.com/alibaba/higress/hgctl/pkg/plugin/types"
"github.com/alibaba/higress/hgctl/pkg/plugin/utils"
"github.com/alibaba/higress/pkg/cmd/options"
"github.com/alibaba/higress/v2/pkg/cmd/options"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/pkg/errors"

View File

@@ -21,7 +21,7 @@ import (
"time"
k8s "github.com/alibaba/higress/hgctl/pkg/kubernetes"
"github.com/alibaba/higress/pkg/cmd/options"
"github.com/alibaba/higress/v2/pkg/cmd/options"
"github.com/pkg/errors"
"github.com/spf13/cobra"

View File

@@ -51,7 +51,7 @@ func newCreateCommand() *cobra.Command {
Example: ` # If the option.yaml file exists in the current path, do the following:
hgctl plugin test create
# Explicitly specify the source of the parameters (directory of the build
# Explicitly specify the source of the parameters (directory of the build
products) and the directory where the test configuration files is stored
hgctl plugin test create -d ./out -t ./test
`,
@@ -139,9 +139,8 @@ func (c *creator) create() (err error) {
fields.Envoy = &Envoy{JSONExample: jsExample}
// 4. generate corresponding test files
if err = os.MkdirAll(target, 0755); err != nil {
if err = os.MkdirAll(target, 0o755); err != nil {
return errors.Wrap(err, "failed to create the test environment")
}
if err = c.genTestConfFiles(fields); err != nil {
return errors.Wrap(err, "failed to create the test environment")

View File

@@ -22,10 +22,12 @@ type TestExStruct struct {
three []bool
}
type ExPointerInt **int
type ExBool bool
type ExSlice []*string
type ExAlias nested.TestNestedStruct
type (
ExPointerInt **int
ExBool bool
ExSlice []*string
ExAlias nested.TestNestedStruct
)
type TestNestedStruct struct {
NestedStruct *nested.TestNestedStruct

View File

@@ -44,11 +44,13 @@ type TestAliasStruct struct {
MyStruct MyStruct
}
type MyString string
type MyPointerInt *int
type MyStruct TestBasicStruct
type NestedAlias ext.ExAlias
type NestedBasicAlias ext.ExBool
type (
MyString string
MyPointerInt *int
MyStruct TestBasicStruct
NestedAlias ext.ExAlias
NestedBasicAlias ext.ExBool
)
type TestExternalStruct struct {
InternalFloat float64
@@ -62,8 +64,7 @@ type TestNestedStruct struct {
NestedStruct *ext.TestNestedStruct
}
type MyInterface interface {
}
type MyInterface interface{}
var MyConst bool

View File

@@ -20,7 +20,7 @@ import (
"io"
k8s "github.com/alibaba/higress/hgctl/pkg/kubernetes"
"github.com/alibaba/higress/pkg/cmd/options"
"github.com/alibaba/higress/v2/pkg/cmd/options"
"github.com/pkg/errors"
"github.com/spf13/cobra"