diff --git a/http/util_stubs_oss.go b/http/util_stubs_oss.go index 23fa205e87..8c395271c2 100644 --- a/http/util_stubs_oss.go +++ b/http/util_stubs_oss.go @@ -5,6 +5,7 @@ package http import ( "net/http" + "github.com/hashicorp/vault/sdk/logical" "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 entAdjustResponse() {} +func entAdjustResponse(core *vault.Core, w http.ResponseWriter, req *logical.Request) { +} diff --git a/tools/stubmaker/main.go b/tools/stubmaker/main.go index 530dcfa768..53676e08b8 100644 --- a/tools/stubmaker/main.go +++ b/tools/stubmaker/main.go @@ -12,11 +12,14 @@ import ( "io" "os" "path/filepath" + "regexp" + "sort" "strings" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/object" + "github.com/google/go-cmp/cmp" "github.com/hashicorp/go-hclog" "golang.org/x/tools/go/packages" ) @@ -225,21 +228,23 @@ func isStubNeeded(funcs []string) (bool, error) { case len(found) == len(funcs): return false, nil 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 } +var funcRE = regexp.MustCompile("^func *(?:[(][^)]+[)])? *([^(]+)") + func getFuncs(inputLines []string) []string { var funcs []string for _, line := range inputLines { - trimmed := strings.TrimSpace(line) - if strings.HasPrefix(trimmed, "func ") { - i := strings.Index(trimmed, "(") - if i != -1 { - funcs = append(funcs, trimmed[5:i]) - } + matches := funcRE.FindStringSubmatch(line) + if len(matches) > 1 { + funcs = append(funcs, matches[1]) } } return funcs diff --git a/vault/core.go b/vault/core.go index 7d3fd79b83..502a1bb3b8 100644 --- a/vault/core.go +++ b/vault/core.go @@ -191,9 +191,9 @@ var ( LicenseAutoloaded = func(*Core) bool { return false } // TODO remove once entCheckLicenseInit is implemented in ENT 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 } - // TODO remove once entReloadLicense is implemented in ENT + // TODO remove once EntReloadLicense is implemented in ENT LicenseReload = func(*Core) error { return nil } ) diff --git a/vault/core_stubs_oss.go b/vault/core_stubs_oss.go index d1230393da..0243eb05f3 100644 --- a/vault/core_stubs_oss.go +++ b/vault/core_stubs_oss.go @@ -22,11 +22,11 @@ func (c *Core) entCheckLicenseInit() error { return nil } -func (c *Core) entGetLicenseState() (*LicenseState, error) { +func (c *Core) EntGetLicenseState() (*LicenseState, error) { return nil, nil } -func (c *Core) entReloadLicense() error { +func (c *Core) EntReloadLicense() error { return nil }