Comments (4)
You're right, we meant to add this, but didn't get around to it. I could have sworn there was an issue open to do it, but I guess not.
from ksonnet-lib.
So I think there are a few options here.
- Add a "transformer" to
*Type
. For example,metadataType.toMixin(meta):: __podTemplateMixin({metadata+: meta})
would take a metadata object, and lift it into a mixin that sets themetadata
property in a pod template (as an example). The downside is thatmetadataType
exists in many places, and is supposed to be identical in all places, but this would make it context-specific. This will also be a problem if we transition away from the "embedding*Type
where it exists -- we'll just end up here with the same problem again. - Add a "setter" to the mixin object itself. For example,
mixin.metadata.setProperty(meta):: {metadata+: metadata}
. There are two downsides to this approach. The first is that everything other property in themixin.*
namespace is set with a method that has the name of the property. For example,mixin.metadata.labels
sets thelabels
property.
The second it's a semantic mismatch for how top-level API objects set properties. For example, we would expect something likedeployment.foo
to set thefoo
property, so why should we set themetadata
property with something likedeployment.mixin.metadata.setProperty
? - Have a "setter" next to each mixin. So for example, we have
metadataType
,metadata
, andsetMetadata
.
from ksonnet-lib.
So I'm thinking we probably want to go with (2). I actually think it does make sense after all.
My big complaint before was that it's weird to use deployment.foo
to set the foo
property, but the deployment.mixin.metadata.setProperty
function to set metadata
. There are two things that convinced me that this is not so weird.
First, a function like deployment.mixin.metadata.annotations
calls something semantically identical to setProperty
under the covers anyway, the difference is that instead of mixing in a property, setProperty
mixes in an instance of v1.ObjectMeta
. If we call it something like deployment.mixin.metadata.mixinInstance
, then I think this might be clearer.
Second, the fact that this is semantically similar is underscored when we consider deeper-nested types. For eample, something like deployment.mixin.metadata.initializers.mixinInstance
makes sense, because we're mixing an instance of the initializer into a deployment
object.
from ksonnet-lib.
Another thing to consider is: do we want we want to distinguish between setters and mixins? A function like container.ports
will append to a current list of ports, but completely replacing the array is a bit more manual, because you need to actually write an object literal like {ports: []}
.
As it relates to this discussion, we now have 2 questions:
- Should the semantics of
mixinInstance
set the property, or merge the instance withsuper
? - Should this distinction be made for other methods, too?
from ksonnet-lib.
Related Issues (20)
- Configure ksonnet-lib in travis ci
- k8s version vs lib version HOT 1
- Can't reference ingressRule in ksonnet-lib HOT 5
- volumeMount: RUNTIME ERROR: Field does not exist: withReadOnly HOT 4
- mapContainersWithName: RUNTIME ERROR: Field does not exist: Inter HOT 2
- newConstructor doesn't honor argument order?
- Make `items` optional in `fromConfigMap()` HOT 1
- Some with* missing self +
- Object Field could be a binary
- Field expression doesnโt imply an object comprehension
- ObjectField keys can be any valid Jsonnet expression
- apps.v1.deployment should have mandatory selector argument in constructor
- apps.v1.deployment constructor match pods across deployments
- Update official Docker image
- Cannot use the apiregistraion API
- status is not a var in hidden.
- Support for Kubernetes 1.9
- ksonnet-lib to be supported or not ? HOT 2
- Release v0.1.13
- jb: error: failed to install: stat vendor/k.libsonnet/jsonnetfile.lock.json: not a directory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksonnet-lib.