-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Externalize newapp / newbuild #20645
Externalize newapp / newbuild #20645
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left you some comments and suggestions already :-)
pkg/build/buildapihelpers/helpers.go
Outdated
// TODO(juanvallejo): change internal helper to "GetInputReferenceInternal" once https://github.com/openshift/origin/pull/20532 merges | ||
// GetInputReferenceV1 returns the From ObjectReference associated with the | ||
// BuildStrategy. | ||
func GetInputReferenceV1(strategy buildv1.BuildStrategy) *corev1.ObjectReference { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not like this, see how it's done in https://github.com/openshift/origin/pull/20532/files#diff-5cb0d8a77f515d00d8e768a169ded24c it'll be easier for both of us to have those in sync. Besides never create *V1
versions, rather call the old one *Internal
and let the external version re-use the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably just pick the commit that contains all those fixes from that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do - wanted to do it this way at first, but did not want to overlap changes in that PR. Seeing as how your PR will merge first anyway, I'll go ahead and apply your changes here
pkg/oc/cli/set/env.go
Outdated
@@ -30,9 +28,8 @@ import ( | |||
|
|||
buildv1 "github.com/openshift/api/build/v1" | |||
cmdutil "github.com/openshift/origin/pkg/cmd/util" | |||
"github.com/openshift/origin/pkg/oc/util/clientcmd" | |||
envresolve "github.com/openshift/origin/pkg/oc/lib/env" | |||
utilenv "github.com/openshift/origin/pkg/oc/util/env" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, we have two utils for working with env, we should merge them together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The utils from the Misunderstood, initially thought you were referencing the controller helper and the newly created envresolve
package depend on the ResourceStore in that same package. They are also used by the build controller. Maybe we could duplicate them and have them live in the oc/lib
tree?oc/cli
envresolve file.
Will go ahead and merge these two cli helpers
pkg/oc/cli/set/env.go
Outdated
resolutionErrorsEncountered := false | ||
containers, _ := selectContainers(spec.Containers, o.ContainerSelector) | ||
containers, _ := selectContainersV1(spec.Containers, o.ContainerSelector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectContainers
should work with external versions, selectContainersInternal
with internals.
pkg/oc/cli/set/helper.go
Outdated
@@ -26,6 +27,20 @@ func selectContainers(containers []kapi.Container, spec string) ([]*kapi.Contain | |||
return out, skipped | |||
} | |||
|
|||
// TODO(juanvallejo): remove internal helper once all callers are switched to externals | |||
func selectContainersV1(containers []corev1.Container, spec string) ([]*corev1.Container, []*corev1.Container) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment about naming this.
pkg/oc/lib/env/envresolve.go
Outdated
@@ -0,0 +1,168 @@ | |||
package env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment about this file and package. One of them needs to die, having two will cause confusion and may lead to code duplication.
@@ -13,14 +13,14 @@ import ( | |||
kapi "k8s.io/kubernetes/pkg/apis/core" | |||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions/resource" | |||
|
|||
templatev1 "github.com/openshift/api/template/v1" | |||
templatev1client "github.com/openshift/client-go/template/clientset/versioned/typed/template/v1" | |||
"github.com/openshift/origin/pkg/oc/util/ocscheme" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, figure out what this is used for and if this can be replaced with kubectl's scheme.
} | ||
|
||
// TODO(juanvallejo): we're no longer using an api helper here - but are duplicating logic | ||
// from internal image api helper to make it suitable for the v1 api. Is this okay? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Image controller will eventually need the external versions. Make the helpers in image package in that case. At some point in time when we'll decide to split oc out we'll have to figure something out.
3162dfb
to
b423bc8
Compare
ee8151c
to
a47edb9
Compare
f042e27
to
8231223
Compare
/retest |
9d22c12
to
c00eee8
Compare
@@ -24,7 +24,7 @@ import ( | |||
imageapi "github.com/openshift/origin/pkg/image/apis/image" | |||
imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset" | |||
imagetypedclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" | |||
"github.com/openshift/origin/pkg/oc/util/clientcmd" | |||
"k8s.io/kubernetes/pkg/api/legacyscheme" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the import up.
for _, e := range env.List() { | ||
internal := &kapi.EnvVar{} | ||
err := kapiv1.Convert_v1_EnvVar_To_core_EnvVar(&e, internal, nil) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done
|
||
"encoding/json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this import up to all of golang imports.
pkg/oc/lib/newapp/cmd/newapp.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
objects = append(objects, runtime.RawExtension{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am a bit hesitant about doing this as well. Maybe it is worth leaving QueryResult.List as an internal list, rather than corev1.List
@@ -789,6 +814,24 @@ func (c *AppConfig) validate() (app.Environment, app.Environment, app.Environmen | |||
return env, buildEnv, params, nil | |||
} | |||
|
|||
func templateObjectsToAppObjects(objs []runtime.RawExtension) (app.Objects, error) { | |||
converted := []runtime.Object{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed, as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I needed a way to take all of the raw.Extension objects I receive from building the (now) external templates, and convert them into []runtime.Object
templateclientv1 "github.com/openshift/origin/pkg/template/client/v1" | ||
) | ||
|
||
// TODO: remove this helper once all consumers are switched to external versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
c00eee8
to
eacc705
Compare
81b8f77
to
0da4237
Compare
bd6592f
to
b951eba
Compare
/test end_to_end |
acb2b41
to
f119626
Compare
/retest |
f119626
to
3e4322d
Compare
/test cmd |
87202a1
to
3a5c87b
Compare
/retest |
3a5c87b
to
40f620e
Compare
/test gcp |
@@ -344,7 +344,18 @@ func (o *AppOptions) RunNewApp() error { | |||
} | |||
|
|||
if o.Action.ShouldPrint() { | |||
return o.Printer.PrintObj(result.List, o.Out) | |||
// TODO(juanvallejo): this needs to be fixed by updating QueryResult.List to be of type corev1.List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with @juanvallejo, this will be fixed in a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in #20919
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
config.KubeClient = kclient | ||
|
||
config.KubeClient, err = kubernetes.NewForConfig(clientConfig) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why you're such a fan of empty lines 😜, you put quite a lot of them in your PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes things less claustrophobic? :)
From: &objRef, | ||
}, | ||
}) | ||
source.Images = []buildapi.ImageSource{imgSrc} | ||
source.Images = []buildv1.ImageSource{imgSrc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this was one of your problems. I fixed a similar problem in the generator as well.
Applying the approve label manually, since all the changes are CLI-triggered from new-app/new-build commands switch to externals. |
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: juanvallejo, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Work in progress, does not build yet.It builds! Creates a few TODOs, externalizes "oc set env" as a side-effect :)Decouples more apihelpers.
Depends on #20532cc @soltysh @deads2k