Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix imports to the canonical packages #14617

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/auth/userregistry/identitymapper/lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

authapi "github.com/openshift/origin/pkg/auth/api"
"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
mappingregistry "github.com/openshift/origin/pkg/user/registry/useridentitymapping"
Expand Down Expand Up @@ -106,11 +105,11 @@ func TestLookup(t *testing.T) {
for k, tc := range testcases {
actions := []test.Action{}
identityRegistry := &test.IdentityRegistry{
Get: map[string]*api.Identity{},
Get: map[string]*userapi.Identity{},
Actions: &actions,
}
userRegistry := &test.UserRegistry{
Get: map[string]*api.User{},
Get: map[string]*userapi.User{},
Actions: &actions,
}
if tc.ExistingIdentity != nil {
Expand Down
7 changes: 3 additions & 4 deletions pkg/auth/userregistry/identitymapper/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
apirequest "k8s.io/apiserver/pkg/endpoints/request"

authapi "github.com/openshift/origin/pkg/auth/api"
"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
)
Expand All @@ -35,7 +34,7 @@ func (t *testNewIdentityGetter) UserForNewIdentity(ctx apirequest.Context, prefe
}

func TestGetPreferredUsername(t *testing.T) {
identity := &api.Identity{}
identity := &userapi.Identity{}

identity.ProviderUserName = "foo"
if preferred := getPreferredUserName(identity); preferred != "foo" {
Expand Down Expand Up @@ -238,11 +237,11 @@ func TestProvision(t *testing.T) {
for k, tc := range testcases {
actions := []test.Action{}
identityRegistry := &test.IdentityRegistry{
Get: map[string]*api.Identity{},
Get: map[string]*userapi.Identity{},
Actions: &actions,
}
userRegistry := &test.UserRegistry{
Get: map[string]*api.User{},
Get: map[string]*userapi.User{},
Actions: &actions,
}
if tc.ExistingIdentity != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/userregistry/identitymapper/strategy_add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package identitymapper
import (
"testing"

"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
)

Expand All @@ -28,7 +28,7 @@ func TestStrategyAdd(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob")},
UpdateResponse: makeUser("bobUserUID", "bob", "idp:bob"),

ExpectedActions: []test.Action{
Expand All @@ -43,7 +43,7 @@ func TestStrategyAdd(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob", "otheridp:user")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob", "otheridp:user")},
UpdateResponse: makeUser("bobUserUID", "bob", "otheridp:user", "idp:bob"),

ExpectedActions: []test.Action{
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/userregistry/identitymapper/strategy_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package identitymapper
import (
"testing"

"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
)

Expand All @@ -28,7 +28,7 @@ func TestStrategyClaim(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob")},
UpdateResponse: makeUser("bobUserUID", "bob", "idp:bob"),

ExpectedActions: []test.Action{
Expand All @@ -43,7 +43,7 @@ func TestStrategyClaim(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob", "otheridp:user")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob", "otheridp:user")},
UpdateResponse: makeUser("bobUserUID", "bob", "otheridp:user", "idp:bob"),

ExpectedActions: []test.Action{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package identitymapper
import (
"testing"

"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
)

Expand All @@ -28,7 +28,7 @@ func TestStrategyGenerate(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob")},
CreateResponse: makeUser("bob2UserUID", "bob2", "idp:bob"),

ExpectedActions: []test.Action{
Expand All @@ -44,7 +44,7 @@ func TestStrategyGenerate(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{makeUser("bobUserUID", "bob", "otheridp:user")},
ExistingUsers: []*userapi.User{makeUser("bobUserUID", "bob", "otheridp:user")},
CreateResponse: makeUser("bob2UserUID", "bob2", "idp:bob"),

ExpectedActions: []test.Action{
Expand All @@ -60,7 +60,7 @@ func TestStrategyGenerate(t *testing.T) {
PreferredUsername: "bob",
Identity: makeIdentity("", "idp", "bob", "", ""),

ExistingUsers: []*api.User{
ExistingUsers: []*userapi.User{
makeUser("bobUserUID", "bob", "otheridp:user"),
makeUser("bob2UserUID", "bob2", "otheridp:user2"),
},
Expand Down
22 changes: 11 additions & 11 deletions pkg/auth/userregistry/identitymapper/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
kapi "k8s.io/kubernetes/pkg/api"

"github.com/openshift/origin/pkg/user"
"github.com/openshift/origin/pkg/user/api"
userapi "github.com/openshift/origin/pkg/user/api"
"github.com/openshift/origin/pkg/user/registry/test"
userregistry "github.com/openshift/origin/pkg/user/registry/user"
)
Expand All @@ -19,7 +19,7 @@ type testInitializer struct {
called bool
}

func (t *testInitializer) InitializeUser(identity *api.Identity, user *api.User) error {
func (t *testInitializer) InitializeUser(identity *userapi.Identity, user *userapi.User) error {
t.called = true
return nil
}
Expand All @@ -29,12 +29,12 @@ type strategyTestCase struct {

// Inputs
PreferredUsername string
Identity *api.Identity
Identity *userapi.Identity

// User registry setup
ExistingUsers []*api.User
CreateResponse *api.User
UpdateResponse *api.User
ExistingUsers []*userapi.User
CreateResponse *userapi.User
UpdateResponse *userapi.User

// Expectations
ExpectedActions []test.Action
Expand All @@ -43,17 +43,17 @@ type strategyTestCase struct {
ExpectedInitialize bool
}

func makeUser(uid string, name string, identities ...string) *api.User {
return &api.User{
func makeUser(uid string, name string, identities ...string) *userapi.User {
return &userapi.User{
ObjectMeta: metav1.ObjectMeta{
Name: name,
UID: types.UID(uid),
},
Identities: identities,
}
}
func makeIdentity(uid string, providerName string, providerUserName string, userUID string, userName string) *api.Identity {
return &api.Identity{
func makeIdentity(uid string, providerName string, providerUserName string, userUID string, userName string) *userapi.Identity {
return &userapi.Identity{
ObjectMeta: metav1.ObjectMeta{
Name: providerName + ":" + providerUserName,
UID: types.UID(uid),
Expand All @@ -71,7 +71,7 @@ func makeIdentity(uid string, providerName string, providerUserName string, user
func (tc strategyTestCase) run(k string, t *testing.T) {
actions := []test.Action{}
userRegistry := &test.UserRegistry{
Get: map[string]*api.User{},
Get: map[string]*userapi.User{},
Actions: &actions,
}
for _, u := range tc.ExistingUsers {
Expand Down
12 changes: 6 additions & 6 deletions pkg/authorization/api/install/apigroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
kapi "k8s.io/kubernetes/pkg/api"

"github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/authorization/api/v1"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
authorizationapiv1 "github.com/openshift/origin/pkg/authorization/api/v1"
)

func installApiGroup() {
Expand All @@ -19,14 +19,14 @@ func installApiGroup() {
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: api.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
GroupName: authorizationapi.GroupName,
VersionPreferenceOrder: []string{authorizationapiv1.SchemeGroupVersion.Version},
ImportPrefix: importPrefix,
AddInternalObjectsToScheme: api.AddToScheme,
AddInternalObjectsToScheme: authorizationapi.AddToScheme,
RootScopedKinds: sets.NewString("ClusterRole", "ClusterRoleBinding", "ClusterPolicy", "ClusterPolicyBinding"),
},
announced.VersionToSchemeFunc{
v1.SchemeGroupVersion.Version: v1.AddToScheme,
authorizationapiv1.SchemeGroupVersion.Version: authorizationapiv1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
Expand Down
18 changes: 9 additions & 9 deletions pkg/authorization/api/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
kapi "k8s.io/kubernetes/pkg/api"

"github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/authorization/api/v1"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
authorizationapiv1 "github.com/openshift/origin/pkg/authorization/api/v1"
)

const importPrefix = "github.com/openshift/origin/pkg/authorization/api"

var accessor = meta.NewAccessor()

// availableVersions lists all known external versions for this group from most preferred to least preferred
var availableVersions = []schema.GroupVersion{v1.LegacySchemeGroupVersion}
var availableVersions = []schema.GroupVersion{authorizationapiv1.LegacySchemeGroupVersion}

func init() {
kapi.Registry.RegisterVersions(availableVersions)
Expand All @@ -32,7 +32,7 @@ func init() {
}
}
if len(externalVersions) == 0 {
glog.Infof("No version is registered for group %v", api.GroupName)
glog.Infof("No version is registered for group %v", authorizationapi.GroupName)
return
}

Expand Down Expand Up @@ -70,16 +70,16 @@ func enableVersions(externalVersions []schema.GroupVersion) error {

func addVersionsToScheme(externalVersions ...schema.GroupVersion) {
// add the internal version to Scheme
api.AddToSchemeInCoreGroup(kapi.Scheme)
authorizationapi.AddToSchemeInCoreGroup(kapi.Scheme)
// add the enabled external versions to Scheme
for _, v := range externalVersions {
if !kapi.Registry.IsEnabledVersion(v) {
glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v)
continue
}
switch v {
case v1.LegacySchemeGroupVersion:
v1.AddToSchemeInCoreGroup(kapi.Scheme)
case authorizationapiv1.LegacySchemeGroupVersion:
authorizationapiv1.AddToSchemeInCoreGroup(kapi.Scheme)

default:
glog.Errorf("Version %s is not known, so it will not be added to the Scheme.", v)
Expand All @@ -96,14 +96,14 @@ func newRESTMapper(externalVersions []schema.GroupVersion) meta.RESTMapper {

func interfacesFor(version schema.GroupVersion) (*meta.VersionInterfaces, error) {
switch version {
case v1.LegacySchemeGroupVersion:
case authorizationapiv1.LegacySchemeGroupVersion:
return &meta.VersionInterfaces{
ObjectConvertor: kapi.Scheme,
MetadataAccessor: accessor,
}, nil

default:
g, _ := kapi.Registry.Group(api.GroupName)
g, _ := kapi.Registry.Group(authorizationapi.GroupName)
return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions)
}
}
14 changes: 7 additions & 7 deletions pkg/authorization/api/v1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ package v1_test
import (
"testing"

"github.com/openshift/origin/pkg/authorization/api"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
_ "github.com/openshift/origin/pkg/authorization/api/install"
testutil "github.com/openshift/origin/test/util/api"
)

func TestFieldSelectorConversions(t *testing.T) {
testutil.CheckFieldLabelConversions(t, "v1", "ClusterPolicy",
// Ensure all currently returned labels are supported
api.ClusterPolicyToSelectableFields(&api.ClusterPolicy{}),
authorizationapi.ClusterPolicyToSelectableFields(&authorizationapi.ClusterPolicy{}),
)

testutil.CheckFieldLabelConversions(t, "v1", "ClusterPolicyBinding",
// Ensure all currently returned labels are supported
api.ClusterPolicyBindingToSelectableFields(&api.ClusterPolicyBinding{}),
authorizationapi.ClusterPolicyBindingToSelectableFields(&authorizationapi.ClusterPolicyBinding{}),
)

testutil.CheckFieldLabelConversions(t, "v1", "Policy",
// Ensure all currently returned labels are supported
api.PolicyToSelectableFields(&api.Policy{}),
authorizationapi.PolicyToSelectableFields(&authorizationapi.Policy{}),
)

testutil.CheckFieldLabelConversions(t, "v1", "PolicyBinding",
// Ensure all currently returned labels are supported
api.PolicyBindingToSelectableFields(&api.PolicyBinding{}),
authorizationapi.PolicyBindingToSelectableFields(&authorizationapi.PolicyBinding{}),
)

testutil.CheckFieldLabelConversions(t, "v1", "Role",
// Ensure all currently returned labels are supported
api.RoleToSelectableFields(&api.Role{}),
authorizationapi.RoleToSelectableFields(&authorizationapi.Role{}),
)

testutil.CheckFieldLabelConversions(t, "v1", "RoleBinding",
// Ensure all currently returned labels are supported
api.RoleBindingToSelectableFields(&api.RoleBinding{}),
authorizationapi.RoleBindingToSelectableFields(&authorizationapi.RoleBinding{}),
)

}
14 changes: 7 additions & 7 deletions pkg/authorization/api/v1/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import (

kapi "k8s.io/kubernetes/pkg/api"

"github.com/openshift/origin/pkg/authorization/api"
"github.com/openshift/origin/pkg/authorization/api/v1"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
authorizationapiv1 "github.com/openshift/origin/pkg/authorization/api/v1"

// install all APIs
_ "github.com/openshift/origin/pkg/api/install"
)

func TestDefaults(t *testing.T) {
obj := &v1.PolicyRule{
obj := &authorizationapiv1.PolicyRule{
APIGroups: nil,
Verbs: []string{api.VerbAll},
Resources: []string{api.ResourceAll},
Verbs: []string{authorizationapi.VerbAll},
Resources: []string{authorizationapi.ResourceAll},
}
out := &api.PolicyRule{}
out := &authorizationapi.PolicyRule{}
if err := kapi.Scheme.Convert(obj, out, nil); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(out.APIGroups, []string{api.APIGroupAll}) {
if !reflect.DeepEqual(out.APIGroups, []string{authorizationapi.APIGroupAll}) {
t.Errorf("did not default api groups: %#v", out)
}
}
Loading