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
a336ab1f
Commit
a336ab1f
authored
Dec 11, 2015
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address wojtek-t's comment
parent
80a8295b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
16 deletions
+18
-16
client-generator.go
cmd/libs/go2idl/client-gen/generators/client-generator.go
+4
-4
plural_namer.go
cmd/libs/go2idl/namer/plural_namer.go
+12
-10
plural_namer_test.go
cmd/libs/go2idl/namer/plural_namer_test.go
+2
-2
No files found.
cmd/libs/go2idl/client-gen/generators/client-generator.go
View file @
a336ab1f
...
@@ -33,15 +33,15 @@ import (
...
@@ -33,15 +33,15 @@ import (
// NameSystems returns the name system used by the generators in this package.
// NameSystems returns the name system used by the generators in this package.
func
NameSystems
()
namer
.
NameSystems
{
func
NameSystems
()
namer
.
NameSystems
{
pluralExceptions
:=
map
[
string
]
string
{
pluralExceptions
:=
map
[
string
]
string
{
"Endpoints"
:
"
e
ndpoints"
,
"Endpoints"
:
"
E
ndpoints"
,
"ComponentStatus"
:
"
c
omponentStatus"
,
"ComponentStatus"
:
"
C
omponentStatus"
,
}
}
return
namer
.
NameSystems
{
return
namer
.
NameSystems
{
"public"
:
namer
.
NewPublicNamer
(
0
),
"public"
:
namer
.
NewPublicNamer
(
0
),
"private"
:
namer
.
NewPrivateNamer
(
0
),
"private"
:
namer
.
NewPrivateNamer
(
0
),
"raw"
:
namer
.
NewRawNamer
(
""
,
nil
),
"raw"
:
namer
.
NewRawNamer
(
""
,
nil
),
"publicPlural"
:
namer
.
NewP
luralNamer
(
pluralExceptions
,
true
),
"publicPlural"
:
namer
.
NewP
ublicPluralNamer
(
pluralExceptions
),
"privatePlural"
:
namer
.
NewP
luralNamer
(
pluralExceptions
,
false
),
"privatePlural"
:
namer
.
NewP
rivatePluralNamer
(
pluralExceptions
),
}
}
}
}
...
...
cmd/libs/go2idl/namer/plural_namer.go
View file @
a336ab1f
...
@@ -19,20 +19,22 @@ package namer
...
@@ -19,20 +19,22 @@ package namer
import
"k8s.io/kubernetes/cmd/libs/go2idl/types"
import
"k8s.io/kubernetes/cmd/libs/go2idl/types"
type
pluralNamer
struct
{
type
pluralNamer
struct
{
// key is the case-sensitive type name, value is the case-insensitive
// intended output.
exceptions
map
[
string
]
string
exceptions
map
[
string
]
string
finalize
func
(
string
)
string
finalize
func
(
string
)
string
}
}
// NewPluralNamer returns a namer that returns the plural form of the input
// NewP
ublicP
luralNamer returns a namer that returns the plural form of the input
// type's name.
// type's name
, starting with a uppercase letter
.
func
NewP
luralNamer
(
exceptions
map
[
string
]
string
,
public
bool
)
*
pluralNamer
{
func
NewP
ublicPluralNamer
(
exceptions
map
[
string
]
string
)
*
pluralNamer
{
var
finalize
func
(
string
)
string
return
&
pluralNamer
{
exceptions
,
IC
}
if
public
{
}
finalize
=
IC
}
else
{
// NewPrivatePluralNamer returns a namer that returns the plural form of the input
finalize
=
IL
// type's name, starting with a lowercase letter.
}
func
NewPrivatePluralNamer
(
exceptions
map
[
string
]
string
)
*
pluralNamer
{
return
&
pluralNamer
{
exceptions
,
finalize
}
return
&
pluralNamer
{
exceptions
,
IL
}
}
}
// Name returns the plural form of the type's name. If the type's name is found
// Name returns the plural form of the type's name. If the type's name is found
...
...
cmd/libs/go2idl/namer/plural_namer_test.go
View file @
a336ab1f
...
@@ -27,8 +27,8 @@ func TestPluralNamer(t *testing.T) {
...
@@ -27,8 +27,8 @@ func TestPluralNamer(t *testing.T) {
// The type name is already in the plural form
// The type name is already in the plural form
"Endpoints"
:
"endpoints"
,
"Endpoints"
:
"endpoints"
,
}
}
public
:=
NewP
luralNamer
(
exceptions
,
true
)
public
:=
NewP
ublicPluralNamer
(
exceptions
)
private
:=
NewP
luralNamer
(
exceptions
,
false
)
private
:=
NewP
rivatePluralNamer
(
exceptions
)
cases
:=
[]
struct
{
cases
:=
[]
struct
{
typeName
string
typeName
string
...
...
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