-
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
Perform template processing on external values #1959
Conversation
2288ed4
to
3de701d
Compare
[test] |
Upstream is kubernetes/kubernetes#7490 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_openshift3/1931/) |
@smarterclayton this looks awesome, thanks! LGTM |
// objects still have functioning TypeMeta features-- kind, version, etc. | ||
// TODO: Make this object have easy access to field based accessors and settors for | ||
// metadata and field mutatation. | ||
type Unstructured struct { |
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.
Why would we keep both Unknown
and Unstructured
? Seems like Unstructured
is a more convenient form that is equivalent in power.
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.
Unknown is much less expensive and is essentially "an opaque blob". Not everyone who wants to use objects needs the processing Unstructured has.
----- Original Message -----
@@ -116,3 +116,17 @@ type Unknown struct {
}func (*Unknown) IsAnAPIObject() {}
+
+// Unstructured allows objects that do not have Golang structs registered
to be manipulated
+// generically. This can be used to deal with the API objects from a
plug-in. Unstructured
+// objects still have functioning TypeMeta features-- kind, version, etc.
+// TODO: Make this object have easy access to field based accessors and
settors for
+// metadata and field mutatation.
+type Unstructured struct {Why would we keep both
Unknown
andUnstructured
? Seems like
Unstructured
is a more convenient form that is equivalent in power.
Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1959/files#r29328825
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.
Unknown is much less expensive
That's not obvious to me. Don't you have to parse the json anyway, effectively creating the map, until you find hits for the kind
and version
regardless?
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.
json.Decoder has a token scanner that it uses to identify fields. You perform O(N) less object creation. Decode time and memory use is linear with number of fields in your destination structure.
----- Original Message -----
@@ -116,3 +116,17 @@ type Unknown struct {
}func (*Unknown) IsAnAPIObject() {}
+
+// Unstructured allows objects that do not have Golang structs registered
to be manipulated
+// generically. This can be used to deal with the API objects from a
plug-in. Unstructured
+// objects still have functioning TypeMeta features-- kind, version, etc.
+// TODO: Make this object have easy access to field based accessors and
settors for
+// metadata and field mutatation.
+type Unstructured struct {Unknown is much less expensive
That's not obvious to me. Don't you have to parse the json anyway,
effectively creating the map, until you find hits for thekind
and
version
regardless?
Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1959/files#r29335924
Oh, ooops. Just realized that I've been commenting in the wrong repo. Should I move them? |
@@ -138,6 +139,7 @@ func OverwriteBootstrapPolicy(etcdHelper tools.EtcdHelper, masterNamespace, poli | |||
if !ok { | |||
return errors.New("policy must be contained in a template. One can be created with '" + createBootstrapPolicyCommand + "'.") | |||
} | |||
runtime.DecodeList(template.Objects, kapi.Scheme) |
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.
Unnecessary. Given the danger, we only whitelist types.
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.
Necessary, nothing is converted otherwise.
Treat []runtime.Object with more care, require user intervention to transform values
Allow templates to handle map[string]interface{}
3de701d
to
705f0b6
Compare
lgtm. Merge at will (not sure if you want to wait for upstream comments). |
Will grab those in rebase. [merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_openshift3/1718/) (Image: devenv-fedora_1393) |
Evaluated for origin up to 5576aae |
Merged by openshift-bot
Templates currently perform a conversion, which populates default
values and also runs afoul of rules in conversion which may delete/alter/validate
the values we want to templatize.
This change alters the behavior of api.List to deserialize objects into
runtime.Unknown rather than performing the full conversion. It also adds
a new runtime.Unstructured type that can be manipulated directly.