Comments (4)
jsonnet fails because the lone argument passed to std.sort
is invalid for use with the default key function; you need to pass a second argument with a key function that can compare two objects.
It's not clear to me how kubecfg could sidestep the invalid call to std.sort
there. That is indeed strange. @sbarzowski, you may be able to comment here.
from kubecfg.
Yeah, Jsonnet, by design, does not provide a default way to sort objects. You need to specify how you want them to be sorted with keyF
.
For example you can sort by name as follows:
std.sort([
{
apiVersion: 'v1',
kind: 'Namespace',
name: 'test',
},
{
apiVersion: 'v1',
kind: 'Namespace',
name: 'test2',
}
], keyF=function(obj) obj.name)
I have no idea how kubecfg
does it. I briefly looked at the vendored code and I didn't notice any modifications to default comparison or the sort. I didn't notice it overwriting any part of std
. Perhaps someone more familiar with kubecfg could tell what's going on.
from kubecfg.
I performed some experiments and I was able to confirm that kubecfg
shows the file. It doesn't seem to actually sort the objects – in all examples I tried, the original order was preserved.
from kubecfg.
Vaguely related, but maybe not at all: #289 (comment).
I know that kubecfg resorts objects in some cases. It also has special handling for v1/List objects. However, I don't see how it would ever even see such an object here without running into the evaluation failure first.
from kubecfg.
Related Issues (20)
- type assertion panic in --diff-strategy=subset
- Allow specifying kubecfg cluster within jsonnet files
- Diff & confirm before apply
- Cuelang Support HOT 4
- Please update to go-sonnet version v0.14.0. HOT 2
- ext-code/tla-code improperly parsed
- Error go getting kubecfg HOT 1
- Generate breadcrumbs
- Non-stable ordering HOT 10
- Validate command didn't report error, but kubctl report error
- Cant' get kubecfg to validate CRD from cert-manager
- kubecfg fails to install with Go v1.16
- Import external json file with --tla-code not working
- extCodeFile support for yaml
- Unstable key order within maps
- Add support for show command to render non-K8s objects
- Add ability to render multiple files from same invocation to kubecfg
- Handle client-go warnings
- diff subcommand should ignore gc tag HOT 2
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 kubecfg.