Code Monkey home page Code Monkey logo

Comments (4)

seh avatar seh commented on June 12, 2024

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.

sbarzowski avatar sbarzowski commented on June 12, 2024

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.

sbarzowski avatar sbarzowski commented on June 12, 2024

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.

seh avatar seh commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.