mirror of https://github.com/k3s-io/k3s
pkg/util: move Trie to k8s.io/apiserver
parent
ebbf3a9383
commit
3bd00afaf9
|
@ -24,10 +24,10 @@ import (
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
"github.com/emicklei/go-restful"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/apiserver/pkg/util/trie"
|
||||||
)
|
)
|
||||||
|
|
||||||
var verbs = util.CreateTrie([]string{"get", "log", "read", "replace", "patch", "delete", "deletecollection", "watch", "connect", "proxy", "list", "create", "patch"})
|
var verbs = trie.New([]string{"get", "log", "read", "replace", "patch", "delete", "deletecollection", "watch", "connect", "proxy", "list", "create", "patch"})
|
||||||
|
|
||||||
// ToValidOperationID makes an string a valid op ID (e.g. removing punctuations and whitespaces and make it camel case)
|
// ToValidOperationID makes an string a valid op ID (e.g. removing punctuations and whitespaces and make it camel case)
|
||||||
func ToValidOperationID(s string, capitalizeFirstLetter bool) string {
|
func ToValidOperationID(s string, capitalizeFirstLetter bool) string {
|
||||||
|
|
|
@ -27,8 +27,8 @@ import (
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/openapi"
|
"k8s.io/apimachinery/pkg/openapi"
|
||||||
"k8s.io/apimachinery/pkg/util/json"
|
"k8s.io/apimachinery/pkg/util/json"
|
||||||
|
"k8s.io/apiserver/pkg/util/trie"
|
||||||
genericmux "k8s.io/kubernetes/pkg/genericapiserver/server/mux"
|
genericmux "k8s.io/kubernetes/pkg/genericapiserver/server/mux"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -127,7 +127,7 @@ func (o *openAPI) buildDefinitionForType(sample interface{}) (string, error) {
|
||||||
|
|
||||||
// buildPaths builds OpenAPI paths using go-restful's web services.
|
// buildPaths builds OpenAPI paths using go-restful's web services.
|
||||||
func (o *openAPI) buildPaths(webServices []*restful.WebService) error {
|
func (o *openAPI) buildPaths(webServices []*restful.WebService) error {
|
||||||
pathsToIgnore := util.CreateTrie(o.config.IgnorePrefixes)
|
pathsToIgnore := trie.New(o.config.IgnorePrefixes)
|
||||||
duplicateOpId := make(map[string]string)
|
duplicateOpId := make(map[string]string)
|
||||||
for _, w := range webServices {
|
for _, w := range webServices {
|
||||||
rootPath := w.RootPath()
|
rootPath := w.RootPath()
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package util
|
package trie
|
||||||
|
|
||||||
// A simple trie implementation with Add an HasPrefix methods only.
|
// A simple trie implementation with Add an HasPrefix methods only.
|
||||||
type Trie struct {
|
type Trie struct {
|
||||||
|
@ -23,8 +23,8 @@ type Trie struct {
|
||||||
word string
|
word string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTrie creates a Trie and add all strings in the provided list to it.
|
// New creates a Trie and add all strings in the provided list to it.
|
||||||
func CreateTrie(list []string) Trie {
|
func New(list []string) Trie {
|
||||||
ret := Trie{
|
ret := Trie{
|
||||||
children: make(map[byte]*Trie),
|
children: make(map[byte]*Trie),
|
||||||
wordTail: false,
|
wordTail: false,
|
Loading…
Reference in New Issue