Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
221a620a
Commit
221a620a
authored
Oct 03, 2016
by
mbohlool
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Trie to util package
parent
049a0236
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
52 deletions
+72
-52
openapi.go
pkg/genericapiserver/openapi/openapi.go
+2
-1
util.go
pkg/genericapiserver/openapi/util.go
+0
-51
trie.go
pkg/util/trie.go
+70
-0
No files found.
pkg/genericapiserver/openapi/openapi.go
View file @
221a620a
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/genericapiserver/openapi/common"
"k8s.io/kubernetes/pkg/genericapiserver/openapi/common"
"k8s.io/kubernetes/pkg/util/json"
"k8s.io/kubernetes/pkg/util/json"
"k8s.io/kubernetes/pkg/util"
)
)
const
(
const
(
...
@@ -134,7 +135,7 @@ func (o *openAPI) buildDefinitionForType(sample interface{}) (string, error) {
...
@@ -134,7 +135,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
()
error
{
func
(
o
*
openAPI
)
buildPaths
()
error
{
pathsToIgnore
:=
c
reateTrie
(
o
.
config
.
IgnorePrefixes
)
pathsToIgnore
:=
util
.
C
reateTrie
(
o
.
config
.
IgnorePrefixes
)
duplicateOpId
:=
make
(
map
[
string
]
bool
)
duplicateOpId
:=
make
(
map
[
string
]
bool
)
// Find duplicate operation IDs.
// Find duplicate operation IDs.
for
_
,
service
:=
range
o
.
config
.
WebServices
{
for
_
,
service
:=
range
o
.
config
.
WebServices
{
...
...
pkg/genericapiserver/openapi/util.go
View file @
221a620a
...
@@ -59,54 +59,3 @@ func mapKeyFromParam(param *restful.Parameter) interface{} {
...
@@ -59,54 +59,3 @@ func mapKeyFromParam(param *restful.Parameter) interface{} {
Kind
:
param
.
Data
()
.
Kind
,
Kind
:
param
.
Data
()
.
Kind
,
}
}
}
}
// A simple trie implementation with Add an HasPrefix methods only.
type
trie
struct
{
children
map
[
byte
]
*
trie
wordTail
bool
}
func
createTrie
(
list
[]
string
)
trie
{
ret
:=
trie
{
children
:
make
(
map
[
byte
]
*
trie
),
wordTail
:
false
,
}
for
_
,
v
:=
range
list
{
ret
.
Add
(
v
)
}
return
ret
}
func
(
t
*
trie
)
Add
(
v
string
)
{
root
:=
t
for
_
,
b
:=
range
[]
byte
(
v
)
{
child
,
exists
:=
root
.
children
[
b
]
if
!
exists
{
child
=
&
trie
{
children
:
make
(
map
[
byte
]
*
trie
),
wordTail
:
false
,
}
root
.
children
[
b
]
=
child
}
root
=
child
}
root
.
wordTail
=
true
}
func
(
t
*
trie
)
HasPrefix
(
v
string
)
bool
{
root
:=
t
if
root
.
wordTail
{
return
true
}
for
_
,
b
:=
range
[]
byte
(
v
)
{
child
,
exists
:=
root
.
children
[
b
]
if
!
exists
{
return
false
}
if
child
.
wordTail
{
return
true
}
root
=
child
}
return
false
}
pkg/util/trie.go
0 → 100644
View file @
221a620a
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
util
// A simple trie implementation with Add an HasPrefix methods only.
type
Trie
struct
{
children
map
[
byte
]
*
Trie
wordTail
bool
}
func
CreateTrie
(
list
[]
string
)
Trie
{
ret
:=
Trie
{
children
:
make
(
map
[
byte
]
*
Trie
),
wordTail
:
false
,
}
for
_
,
v
:=
range
list
{
ret
.
Add
(
v
)
}
return
ret
}
func
(
t
*
Trie
)
Add
(
v
string
)
{
root
:=
t
for
_
,
b
:=
range
[]
byte
(
v
)
{
child
,
exists
:=
root
.
children
[
b
]
if
!
exists
{
child
=
&
Trie
{
children
:
make
(
map
[
byte
]
*
Trie
),
wordTail
:
false
,
}
root
.
children
[
b
]
=
child
}
root
=
child
}
root
.
wordTail
=
true
}
func
(
t
*
Trie
)
HasPrefix
(
v
string
)
bool
{
root
:=
t
if
root
.
wordTail
{
return
true
}
for
_
,
b
:=
range
[]
byte
(
v
)
{
child
,
exists
:=
root
.
children
[
b
]
if
!
exists
{
return
false
}
if
child
.
wordTail
{
return
true
}
root
=
child
}
return
false
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment