Skip to content

Commit

Permalink
break dep on pkg/oc - generator/generator.go
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Nov 27, 2017
1 parent 33c21b7 commit 9fd5519
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 16 deletions.
26 changes: 23 additions & 3 deletions pkg/build/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion"
"github.com/openshift/origin/pkg/oc/admin/policy"
)

const conflictRetries = 3
Expand Down Expand Up @@ -260,8 +259,8 @@ func (g *BuildGenerator) instantiate(ctx apirequest.Context, request *buildapi.B
// Add labels and annotations from the buildrequest. Existing
// label/annotations will take precedence because we don't want system
// annotations/labels (eg buildname) to get stomped on.
newBuild.Annotations = policy.MergeMaps(request.Annotations, newBuild.Annotations)
newBuild.Labels = policy.MergeMaps(request.Labels, newBuild.Labels)
newBuild.Annotations = mergeMaps(request.Annotations, newBuild.Annotations)
newBuild.Labels = mergeMaps(request.Labels, newBuild.Labels)

// Copy build trigger information and build arguments to the build object.
newBuild.Spec.TriggeredBy = request.TriggeredBy
Expand Down Expand Up @@ -919,3 +918,24 @@ func setBuildAnnotationAndLabel(bcCopy *buildapi.BuildConfig, build *buildapi.Bu
build.Labels[buildapi.BuildConfigLabel] = buildapi.LabelValue(bcCopy.Name)
build.Labels[buildapi.BuildRunPolicyLabel] = string(bcCopy.Spec.RunPolicy)
}

// mergeMaps will merge to map[string]string instances, with
// keys from the second argument overwriting keys from the
// first argument, in case of duplicates.
func mergeMaps(a, b map[string]string) map[string]string {
if a == nil && b == nil {
return nil
}

res := make(map[string]string)

for k, v := range a {
res[k] = v
}

for k, v := range b {
res[k] = v
}

return res
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization"
fakeauthorizationclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset/fake"
"github.com/openshift/origin/pkg/oc/admin/policy"
)

func TestModifyNamedClusterRoleBinding(t *testing.T) {
Expand Down Expand Up @@ -126,11 +125,11 @@ func TestModifyNamedClusterRoleBinding(t *testing.T) {
}
for tcName, tc := range tests {
// Set up modifier options and run AddRole()
o := &policy.RoleModificationOptions{
o := &RoleModificationOptions{
RoleName: tc.inputRole,
RoleBindingName: tc.inputRoleBindingName,
Users: tc.inputSubjects,
RoleBindingAccessor: policy.NewClusterRoleBindingAccessor(fakeauthorizationclient.NewSimpleClientset(tc.existingClusterRoleBindings).Authorization()),
RoleBindingAccessor: NewClusterRoleBindingAccessor(fakeauthorizationclient.NewSimpleClientset(tc.existingClusterRoleBindings).Authorization()),
}

addRoleAndCheck(t, o, tcName, tc.expectedRoleBindingName, tc.expectedSubjects)
Expand Down Expand Up @@ -259,19 +258,19 @@ func TestModifyNamedLocalRoleBinding(t *testing.T) {
}
for tcName, tc := range tests {
// Set up modifier options and run AddRole()
o := &policy.RoleModificationOptions{
o := &RoleModificationOptions{
RoleName: tc.inputRole,
RoleBindingName: tc.inputRoleBindingName,
Users: tc.inputSubjects,
RoleNamespace: metav1.NamespaceDefault,
RoleBindingAccessor: policy.NewLocalRoleBindingAccessor(metav1.NamespaceDefault, fakeauthorizationclient.NewSimpleClientset(tc.existingRoleBindings).Authorization()),
RoleBindingAccessor: NewLocalRoleBindingAccessor(metav1.NamespaceDefault, fakeauthorizationclient.NewSimpleClientset(tc.existingRoleBindings).Authorization()),
}

addRoleAndCheck(t, o, tcName, tc.expectedRoleBindingName, tc.expectedSubjects)
}
}

func addRoleAndCheck(t *testing.T, o *policy.RoleModificationOptions, tcName, expectedName string, expectedSubjects []string) {
func addRoleAndCheck(t *testing.T, o *RoleModificationOptions, tcName, expectedName string, expectedSubjects []string) {
err := o.AddRole()
if err != nil {
t.Errorf("%s: unexpected err %v", tcName, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/bootstrap/docker/openshift/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
kapi "k8s.io/kubernetes/pkg/api"

configcmd "github.com/openshift/origin/pkg/config/cmd"
genappcmd "github.com/openshift/origin/pkg/generate/app/cmd"
"github.com/openshift/origin/pkg/oc/bootstrap/docker/errors"
genappcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
templateinternalclient "github.com/openshift/origin/pkg/template/client/internalversion"
templateclient "github.com/openshift/origin/pkg/template/generated/internalclientset/typed/template/internalversion"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/importer/appjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
configcmd "github.com/openshift/origin/pkg/config/cmd"
"github.com/openshift/origin/pkg/generate/app"
appcmd "github.com/openshift/origin/pkg/generate/app/cmd"
"github.com/openshift/origin/pkg/generate/appjson"
appcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
templateinternalclient "github.com/openshift/origin/pkg/template/client/internalversion"
templateclient "github.com/openshift/origin/pkg/template/generated/internalclientset/typed/template/internalversion"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/newapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ import (
configcmd "github.com/openshift/origin/pkg/config/cmd"
"github.com/openshift/origin/pkg/generate"
newapp "github.com/openshift/origin/pkg/generate/app"
newcmd "github.com/openshift/origin/pkg/generate/app/cmd"
"github.com/openshift/origin/pkg/generate/git"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
newcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
routeapi "github.com/openshift/origin/pkg/route/apis/route"
"github.com/openshift/origin/pkg/util"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/newapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

configcmd "github.com/openshift/origin/pkg/config/cmd"
newcmd "github.com/openshift/origin/pkg/generate/app/cmd"
imageapi "github.com/openshift/origin/pkg/image/apis/image"
imagefake "github.com/openshift/origin/pkg/image/generated/internalclientset/fake"
newcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
templateapi "github.com/openshift/origin/pkg/template/apis/template"
templatefake "github.com/openshift/origin/pkg/template/generated/internalclientset/fake"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/newbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
configcmd "github.com/openshift/origin/pkg/config/cmd"
newapp "github.com/openshift/origin/pkg/generate/app"
newcmd "github.com/openshift/origin/pkg/generate/app/cmd"
newcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
)

// NewBuildRecommendedCommandName is the recommended command name.
Expand Down
2 changes: 1 addition & 1 deletion pkg/oc/cli/cmd/newbuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/MakeNowJust/heredoc"
configcmd "github.com/openshift/origin/pkg/config/cmd"
"github.com/openshift/origin/pkg/generate/app"
newcmd "github.com/openshift/origin/pkg/generate/app/cmd"
imagefake "github.com/openshift/origin/pkg/image/generated/internalclientset/fake"
newcmd "github.com/openshift/origin/pkg/oc/generate/app/cmd"
templatefake "github.com/openshift/origin/pkg/template/generated/internalclientset/fake"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/integration/newapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
buildapi "github.com/openshift/origin/pkg/build/apis/build"
"github.com/openshift/origin/pkg/generate"
"github.com/openshift/origin/pkg/generate/app"
"github.com/openshift/origin/pkg/generate/app/cmd"
apptest "github.com/openshift/origin/pkg/generate/app/test"
"github.com/openshift/origin/pkg/generate/dockerfile"
"github.com/openshift/origin/pkg/generate/git"
Expand All @@ -48,6 +47,7 @@ import (
imageinternalversion "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion"
dockerregistry "github.com/openshift/origin/pkg/image/importer/dockerv1client"
clicmd "github.com/openshift/origin/pkg/oc/cli/cmd"
"github.com/openshift/origin/pkg/oc/generate/app/cmd"
routefake "github.com/openshift/origin/pkg/route/generated/internalclientset/fake"
templateapi "github.com/openshift/origin/pkg/template/apis/template"
templatefake "github.com/openshift/origin/pkg/template/generated/internalclientset/fake"
Expand Down

0 comments on commit 9fd5519

Please sign in to comment.