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
8b2b3251
Commit
8b2b3251
authored
Aug 01, 2014
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #730 from lavalamp/rename
Begin systemizing files in pkg/registry
parents
ee9cec86
7dbb6f02
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
147 additions
and
102 deletions
+147
-102
controllerstorage.go
pkg/registry/controllerstorage.go
+0
-0
controllerstorage_test.go
pkg/registry/controllerstorage_test.go
+0
-0
etcdregistry.go
pkg/registry/etcdregistry.go
+0
-0
etcdregistry_test.go
pkg/registry/etcdregistry_test.go
+0
-0
minionregistry.go
pkg/registry/minionregistry.go
+82
-0
minionregistry_test.go
pkg/registry/minionregistry_test.go
+57
-0
minionstorage.go
pkg/registry/minionstorage.go
+0
-60
minionstorage_test.go
pkg/registry/minionstorage_test.go
+0
-35
podstorage.go
pkg/registry/podstorage.go
+0
-0
podstorage_test.go
pkg/registry/podstorage_test.go
+1
-2
servicestorage.go
pkg/registry/servicestorage.go
+3
-1
servicestorage_test.go
pkg/registry/servicestorage_test.go
+4
-4
No files found.
pkg/registry/controller
_registry
.go
→
pkg/registry/controller
storage
.go
View file @
8b2b3251
File moved
pkg/registry/controller
_registry
_test.go
→
pkg/registry/controller
storage
_test.go
View file @
8b2b3251
File moved
pkg/registry/etcd
_
registry.go
→
pkg/registry/etcdregistry.go
View file @
8b2b3251
File moved
pkg/registry/etcd
_
registry_test.go
→
pkg/registry/etcdregistry_test.go
View file @
8b2b3251
File moved
pkg/registry/minionregistry.go
0 → 100644
View file @
8b2b3251
/*
Copyright 2014 Google Inc. All rights reserved.
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
registry
import
(
"fmt"
"sort"
"sync"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
var
ErrDoesNotExist
=
fmt
.
Errorf
(
"The requested resource does not exist."
)
// Keep track of a set of minions. Safe for concurrent reading/writing.
type
MinionRegistry
interface
{
List
()
(
currentMinions
[]
string
,
err
error
)
Insert
(
minion
string
)
error
Delete
(
minion
string
)
error
Contains
(
minion
string
)
(
bool
,
error
)
}
// Initialize a minion registry with a list of minions.
func
MakeMinionRegistry
(
minions
[]
string
)
MinionRegistry
{
m
:=
&
minionList
{
minions
:
util
.
StringSet
{},
}
for
_
,
minion
:=
range
minions
{
m
.
minions
.
Insert
(
minion
)
}
return
m
}
type
minionList
struct
{
minions
util
.
StringSet
lock
sync
.
Mutex
}
func
(
m
*
minionList
)
List
()
(
currentMinions
[]
string
,
err
error
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
// Convert from map to []string
for
minion
:=
range
m
.
minions
{
currentMinions
=
append
(
currentMinions
,
minion
)
}
sort
.
StringSlice
(
currentMinions
)
.
Sort
()
return
}
func
(
m
*
minionList
)
Insert
(
newMinion
string
)
error
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
minions
.
Insert
(
newMinion
)
return
nil
}
func
(
m
*
minionList
)
Delete
(
minion
string
)
error
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
minions
.
Delete
(
minion
)
return
nil
}
func
(
m
*
minionList
)
Contains
(
minion
string
)
(
bool
,
error
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
return
m
.
minions
.
Has
(
minion
),
nil
}
pkg/registry/minionregistry_test.go
0 → 100644
View file @
8b2b3251
/*
Copyright 2014 Google Inc. All rights reserved.
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
registry
import
(
"reflect"
"testing"
)
func
TestMinionRegistry
(
t
*
testing
.
T
)
{
m
:=
MakeMinionRegistry
([]
string
{
"foo"
,
"bar"
})
if
has
,
err
:=
m
.
Contains
(
"foo"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"missing expected object"
)
}
if
has
,
err
:=
m
.
Contains
(
"bar"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"missing expected object"
)
}
if
has
,
err
:=
m
.
Contains
(
"baz"
);
has
||
err
!=
nil
{
t
.
Errorf
(
"has unexpected object"
)
}
if
err
:=
m
.
Insert
(
"baz"
);
err
!=
nil
{
t
.
Errorf
(
"insert failed"
)
}
if
has
,
err
:=
m
.
Contains
(
"baz"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"insert didn't actually insert"
)
}
if
err
:=
m
.
Delete
(
"bar"
);
err
!=
nil
{
t
.
Errorf
(
"delete failed"
)
}
if
has
,
err
:=
m
.
Contains
(
"bar"
);
has
||
err
!=
nil
{
t
.
Errorf
(
"delete didn't actually delete"
)
}
list
,
err
:=
m
.
List
()
if
err
!=
nil
{
t
.
Errorf
(
"got error calling List"
)
}
if
!
reflect
.
DeepEqual
(
list
,
[]
string
{
"baz"
,
"foo"
})
{
t
.
Errorf
(
"Unexpected list value: %#v"
,
list
)
}
}
pkg/registry/minion
_registry
.go
→
pkg/registry/minion
storage
.go
View file @
8b2b3251
...
...
@@ -18,72 +18,12 @@ package registry
import
(
"fmt"
"sort"
"sync"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
var
ErrDoesNotExist
=
fmt
.
Errorf
(
"The requested resource does not exist."
)
// Keep track of a set of minions. Safe for concurrent reading/writing.
type
MinionRegistry
interface
{
List
()
(
currentMinions
[]
string
,
err
error
)
Insert
(
minion
string
)
error
Delete
(
minion
string
)
error
Contains
(
minion
string
)
(
bool
,
error
)
}
// Initialize a minion registry with a list of minions.
func
MakeMinionRegistry
(
minions
[]
string
)
MinionRegistry
{
m
:=
&
minionList
{
minions
:
util
.
StringSet
{},
}
for
_
,
minion
:=
range
minions
{
m
.
minions
.
Insert
(
minion
)
}
return
m
}
type
minionList
struct
{
minions
util
.
StringSet
lock
sync
.
Mutex
}
func
(
m
*
minionList
)
List
()
(
currentMinions
[]
string
,
err
error
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
// Convert from map to []string
for
minion
:=
range
m
.
minions
{
currentMinions
=
append
(
currentMinions
,
minion
)
}
sort
.
StringSlice
(
currentMinions
)
.
Sort
()
return
}
func
(
m
*
minionList
)
Insert
(
newMinion
string
)
error
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
minions
.
Insert
(
newMinion
)
return
nil
}
func
(
m
*
minionList
)
Delete
(
minion
string
)
error
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
m
.
minions
.
Delete
(
minion
)
return
nil
}
func
(
m
*
minionList
)
Contains
(
minion
string
)
(
bool
,
error
)
{
m
.
lock
.
Lock
()
defer
m
.
lock
.
Unlock
()
return
m
.
minions
.
Has
(
minion
),
nil
}
// MinionRegistryStorage implements the RESTStorage interface, backed by a MinionRegistry.
type
MinionRegistryStorage
struct
{
registry
MinionRegistry
...
...
pkg/registry/minion
_registry
_test.go
→
pkg/registry/minion
storage
_test.go
View file @
8b2b3251
...
...
@@ -24,41 +24,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
)
func
TestMinionRegistry
(
t
*
testing
.
T
)
{
m
:=
MakeMinionRegistry
([]
string
{
"foo"
,
"bar"
})
if
has
,
err
:=
m
.
Contains
(
"foo"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"missing expected object"
)
}
if
has
,
err
:=
m
.
Contains
(
"bar"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"missing expected object"
)
}
if
has
,
err
:=
m
.
Contains
(
"baz"
);
has
||
err
!=
nil
{
t
.
Errorf
(
"has unexpected object"
)
}
if
err
:=
m
.
Insert
(
"baz"
);
err
!=
nil
{
t
.
Errorf
(
"insert failed"
)
}
if
has
,
err
:=
m
.
Contains
(
"baz"
);
!
has
||
err
!=
nil
{
t
.
Errorf
(
"insert didn't actually insert"
)
}
if
err
:=
m
.
Delete
(
"bar"
);
err
!=
nil
{
t
.
Errorf
(
"delete failed"
)
}
if
has
,
err
:=
m
.
Contains
(
"bar"
);
has
||
err
!=
nil
{
t
.
Errorf
(
"delete didn't actually delete"
)
}
list
,
err
:=
m
.
List
()
if
err
!=
nil
{
t
.
Errorf
(
"got error calling List"
)
}
if
!
reflect
.
DeepEqual
(
list
,
[]
string
{
"baz"
,
"foo"
})
{
t
.
Errorf
(
"Unexpected list value: %#v"
,
list
)
}
}
func
TestMinionRegistryStorage
(
t
*
testing
.
T
)
{
m
:=
MakeMinionRegistry
([]
string
{
"foo"
,
"bar"
})
ms
:=
MakeMinionRegistryStorage
(
m
)
...
...
pkg/registry/pod
_registry
.go
→
pkg/registry/pod
storage
.go
View file @
8b2b3251
File moved
pkg/registry/pod
_registry
_test.go
→
pkg/registry/pod
storage
_test.go
View file @
8b2b3251
...
...
@@ -353,7 +353,6 @@ func TestMakePodStatus(t *testing.T) {
}
}
func
TestPodStorageValidatesCreate
(
t
*
testing
.
T
)
{
mockRegistry
:=
&
MockPodStorageRegistry
{
MockPodRegistry
:
MockPodRegistry
{
err
:
fmt
.
Errorf
(
"test error"
)},
...
...
@@ -411,7 +410,7 @@ func TestCreatePod(t *testing.T) {
},
}
pod
:=
api
.
Pod
{
JSONBase
:
api
.
JSONBase
{
ID
:
"foo"
},
JSONBase
:
api
.
JSONBase
{
ID
:
"foo"
},
DesiredState
:
desiredState
,
}
channel
,
err
:=
storage
.
Create
(
pod
)
...
...
pkg/registry/service
_registry
.go
→
pkg/registry/service
storage
.go
View file @
8b2b3251
...
...
@@ -28,12 +28,14 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
// ServiceRegistryStorage adapts a service registry into apiserver's RESTStorage model.
type
ServiceRegistryStorage
struct
{
registry
ServiceRegistry
cloud
cloudprovider
.
Interface
machines
MinionRegistry
}
// MakeServiceRegistryStorage makes a new ServiceRegistryStorage.
func
MakeServiceRegistryStorage
(
registry
ServiceRegistry
,
cloud
cloudprovider
.
Interface
,
machines
MinionRegistry
)
apiserver
.
RESTStorage
{
return
&
ServiceRegistryStorage
{
registry
:
registry
,
...
...
@@ -50,7 +52,7 @@ func makeLinkVariables(service api.Service, machine string) []api.EnvVar {
}
else
{
port
=
strconv
.
Itoa
(
service
.
ContainerPort
.
IntVal
)
}
portPrefix
:=
prefix
+
"_PORT_"
+
strings
.
ToUpper
(
strings
.
Replace
(
port
,
"-"
,
"_"
,
-
1
))
+
"_TCP"
portPrefix
:=
prefix
+
"_PORT_"
+
strings
.
ToUpper
(
strings
.
Replace
(
port
,
"-"
,
"_"
,
-
1
))
+
"_TCP"
return
[]
api
.
EnvVar
{
{
Name
:
prefix
+
"_PORT"
,
...
...
pkg/registry/service
_registry
_test.go
→
pkg/registry/service
storage
_test.go
View file @
8b2b3251
...
...
@@ -219,10 +219,10 @@ func TestServiceRegistryDeleteExternal(t *testing.T) {
}
func
TestServiceRegistryMakeLinkVariables
(
t
*
testing
.
T
)
{
service
:=
api
.
Service
{
JSONBase
:
api
.
JSONBase
{
ID
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
ContainerPort
:
util
.
IntOrString
{
Kind
:
util
.
IntstrString
,
StrVal
:
"a-b-c"
},
service
:=
api
.
Service
{
JSONBase
:
api
.
JSONBase
{
ID
:
"foo"
},
Selector
:
map
[
string
]
string
{
"bar"
:
"baz"
},
ContainerPort
:
util
.
IntOrString
{
Kind
:
util
.
IntstrString
,
StrVal
:
"a-b-c"
},
}
vars
:=
makeLinkVariables
(
service
,
"mars"
)
for
_
,
v
:=
range
vars
{
...
...
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