mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
Teach stubmaker how to work with methods, not just funcs. (#23634)
Teach stubmaker how to work with methods, not just funcs. Fix some stubs defined in #23557 which either had the wrong signature or needed to be public.
This commit is contained in:
@@ -5,6 +5,7 @@ package http
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/hashicorp/vault/sdk/logical"
|
||||||
"github.com/hashicorp/vault/vault"
|
"github.com/hashicorp/vault/vault"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,4 +19,5 @@ func entWrapGenericHandler(core *vault.Core, in http.Handler, props *vault.Handl
|
|||||||
|
|
||||||
func entAdditionalRoutes(mux *http.ServeMux, core *vault.Core) {}
|
func entAdditionalRoutes(mux *http.ServeMux, core *vault.Core) {}
|
||||||
|
|
||||||
func entAdjustResponse() {}
|
func entAdjustResponse(core *vault.Core, w http.ResponseWriter, req *logical.Request) {
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,11 +12,14 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/hashicorp/go-hclog"
|
"github.com/hashicorp/go-hclog"
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
)
|
)
|
||||||
@@ -225,21 +228,23 @@ func isStubNeeded(funcs []string) (bool, error) {
|
|||||||
case len(found) == len(funcs):
|
case len(found) == len(funcs):
|
||||||
return false, nil
|
return false, nil
|
||||||
case len(found) != 0:
|
case len(found) != 0:
|
||||||
return false, fmt.Errorf("funcs partially defined: need=%v, found=%v", funcs, found)
|
sort.Strings(found)
|
||||||
|
sort.Strings(funcs)
|
||||||
|
delta := cmp.Diff(found, funcs)
|
||||||
|
return false, fmt.Errorf("funcs partially defined, delta=%s", delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var funcRE = regexp.MustCompile("^func *(?:[(][^)]+[)])? *([^(]+)")
|
||||||
|
|
||||||
func getFuncs(inputLines []string) []string {
|
func getFuncs(inputLines []string) []string {
|
||||||
var funcs []string
|
var funcs []string
|
||||||
for _, line := range inputLines {
|
for _, line := range inputLines {
|
||||||
trimmed := strings.TrimSpace(line)
|
matches := funcRE.FindStringSubmatch(line)
|
||||||
if strings.HasPrefix(trimmed, "func ") {
|
if len(matches) > 1 {
|
||||||
i := strings.Index(trimmed, "(")
|
funcs = append(funcs, matches[1])
|
||||||
if i != -1 {
|
|
||||||
funcs = append(funcs, trimmed[5:i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return funcs
|
return funcs
|
||||||
|
|||||||
@@ -191,9 +191,9 @@ var (
|
|||||||
LicenseAutoloaded = func(*Core) bool { return false }
|
LicenseAutoloaded = func(*Core) bool { return false }
|
||||||
// TODO remove once entCheckLicenseInit is implemented in ENT
|
// TODO remove once entCheckLicenseInit is implemented in ENT
|
||||||
LicenseInitCheck = func(*Core) error { return nil }
|
LicenseInitCheck = func(*Core) error { return nil }
|
||||||
// TODO remove once entGetLicenseState is implemented in ENT
|
// TODO remove once EntGetLicenseState is implemented in ENT
|
||||||
LicenseSummary = func(*Core) (*LicenseState, error) { return nil, nil }
|
LicenseSummary = func(*Core) (*LicenseState, error) { return nil, nil }
|
||||||
// TODO remove once entReloadLicense is implemented in ENT
|
// TODO remove once EntReloadLicense is implemented in ENT
|
||||||
LicenseReload = func(*Core) error { return nil }
|
LicenseReload = func(*Core) error { return nil }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ func (c *Core) entCheckLicenseInit() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) entGetLicenseState() (*LicenseState, error) {
|
func (c *Core) EntGetLicenseState() (*LicenseState, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Core) entReloadLicense() error {
|
func (c *Core) EntReloadLicense() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user