555 Commits

Author SHA1 Message Date
Jayme Bird
f0a060e259 feat: Add missing linter metadata for std.manifestTomlEx function 2022-03-18 02:05:38 +00:00
Greg Roodt
0d78479d37 Add go_sdk_version parameter 2022-03-18 01:51:10 +00:00
Lucendio
361f0838d9 Bump Go build version to 1.17
Motivation: make darwin_arm64 artifact available as part of the release

The *Installation instructions* already refers to Go v1.17 and above, and
the README.md states:

  *We recommend always using the newest stable release of Go.*

Please note, that is not yet a working change set. It appears that a

  go mod tidy

is needed to make the build step work.
2022-03-05 23:26:50 +00:00
Angus Lees
f699b0ea42 Add numberArrayType linter type
Add `numberArrayType` specialised type for cases where we know we have
an array of numbers.  Use in some stdlib functions and `importbin`.
2022-03-03 22:49:02 +00:00
Angus Lees
856bd58872 Add 'importbin' statement
Add `importbin` statement.  Similar to `importstr` but the result is
an array of numbers (all integers 0-255).
2022-03-03 22:49:02 +00:00
Angus Lees
880ac99e75 Fix incorrect file case 2022-03-03 22:49:02 +00:00
Dave Cunningham
fb6c700f29 Prepare for v0.18.0 v0.18.0 2021-12-21 18:34:50 +00:00
Dave Cunningham
6186bb7667 Release 2021-12-21 16:48:56 +00:00
Dave Cunningham
5c4247b3f4 Equivalent change to https://github.com/google/jsonnet/pull/898 2021-12-21 14:01:05 +00:00
Dave Cunningham
bd9f76165f default to python3 2021-12-21 13:06:57 +00:00
Dave Cunningham
6fdbe3d728 Rest of corresponding change to formatter, see https://github.com/google/jsonnet/pull/937 2021-12-21 12:22:28 +00:00
Dave Cunningham
f60b015405 Corresponding change to formatter, see https://github.com/google/jsonnet/pull/937 2021-12-21 12:17:41 +00:00
Nicklas Frahm
68af6e05bb Document installation for go >= 1.17 2021-12-12 17:12:52 +00:00
Tsuyoshi Hombashi
b10eae7c68
Fix gorelaser configs to properly build darwin packages (#550) 2021-11-01 23:01:00 +00:00
Dave Cunningham
2f2f6d664f Add wasm build 2021-09-09 12:45:53 +01:00
Dave Cunningham
e3c7ddab44 Remove support for go 1.11 2021-09-09 12:45:53 +01:00
Dave Cunningham
c187d5b373
fix bazel rules for formatter (#563) 2021-09-08 11:18:01 +01:00
Bruno Silva
dde866ffbb
Add example usage as library in README (#560)
Add example usage as library in README
2021-08-31 22:34:41 +01:00
Stanisław Barzowski
b00b56c335 Avoid depending on stdlib variable for desugaring.
The fix is easy – we just use "$std" which the user cannot access,
because it's not a valid identifier.
2021-08-09 19:25:33 +01:00
Tsuyoshi Hombashi
51daeb3229
Modify jsonnet-lint to accept multiple input files (#545)
Modify jsonnet-lint to accept multiple input files
2021-07-01 13:10:51 +02:00
Stanisław Barzowski
46d1fceb9c [Linter] Fix super index type and handle "object or string" indexing correctly. 2021-06-06 21:13:19 +02:00
Lucas Servén Marín
12bd29d164 linter: correct the return type for member
This commit corrects return type of the `member` function from the
standard library.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
2021-05-26 13:52:39 +02:00
Stanisław Barzowski
7373f5b606 Add test output overrides for jsonnetfmt. 2021-05-20 14:23:06 +02:00
Greg Roodt
e6a9581713
Adds std.parseYaml (#339)
Add support for std.parseYaml.

Co-authored-by: Stanisław Barzowski <stanislaw.barzowski@gmail.com>
2021-05-20 14:16:23 +02:00
Paul Fischer
ece9c5dc94 updated pre-commit config and readme 2021-05-19 16:01:22 +02:00
Harsimran Singh Maan
1b7cbff4cd Add github actions ci 2021-05-19 16:00:28 +02:00
Stanisław Barzowski
ba5dc76509 Stop depending on nil vs empty slice in a test.
It should not make the difference.
2021-05-19 15:11:08 +02:00
Stanisław Barzowski
5899996502 Make go linter happy again. 2021-05-19 15:10:49 +02:00
Yiannis
ce76155e09
Fix strip definition
Co-authored-by: Tom Fenech <tomjwfenech@gmail.com>
2021-05-19 13:57:47 +02:00
Yiannis
bead95bfa6
Add linter support for std.strip and friends 2021-05-14 17:01:21 +02:00
Simon Let
415d036e5e Put AddPlusObject behind an option, rename FixPlusObject 2021-04-29 22:55:07 +02:00
Simon Let
be7a92aa5c jsonnetfmt: Add plus objects instead of removing them 2021-04-29 22:55:07 +02:00
Stanisław Barzowski
74b3a1b669 [Linter] Support std.member and std.repeat. 2021-03-25 18:35:13 +01:00
Leandro López
eeca44cd27 Allocate resulting slice size instead of dynamically growing it
We know for sure how big the resulting slice will be, so instead of
having Go perform checks and reallocations whenever the slice grows
too small by using `append` we calculate the resulting size earlier
and directly index each element into the output slice. This result in
only two allocations all the time, no matter how big the resulting
slice will be. With it also come big performance improvements:

name                                        old time/op    new time/op    delta
ToOrderedSlice/1_unique_identifiers-8          173ns ±10%     150ns ± 4%  -13.16%  (p=0.000 n=10+9)
ToOrderedSlice/10_unique_identifiers-8        1.24µs ± 6%    0.51µs ± 5%  -58.95%  (p=0.000 n=9+9)
ToOrderedSlice/100_unique_identifiers-8       20.4µs ±20%     4.0µs ± 5%  -80.25%  (p=0.000 n=10+9)
ToOrderedSlice/1000_unique_identifiers-8       253µs ± 9%      40µs ± 5%  -84.19%  (p=0.000 n=10+10)
ToOrderedSlice/10000_unique_identifiers-8     3.44ms ± 9%    0.37ms ± 5%  -89.32%  (p=0.000 n=9+9)
ToOrderedSlice/100000_unique_identifiers-8    48.6ms ±13%     3.6ms ± 4%  -92.49%  (p=0.000 n=10+10)

name                                        old alloc/op   new alloc/op   delta
ToOrderedSlice/1_unique_identifiers-8          40.0B ± 0%     40.0B ± 0%     ~     (all equal)
ToOrderedSlice/10_unique_identifiers-8          520B ± 0%      184B ± 0%  -64.62%  (p=0.000 n=10+10)
ToOrderedSlice/100_unique_identifiers-8       4.10kB ± 0%    1.82kB ± 0%  -55.75%  (p=0.000 n=10+10)
ToOrderedSlice/1000_unique_identifiers-8      32.8kB ± 0%    16.4kB ± 0%  -49.95%  (p=0.000 n=10+10)
ToOrderedSlice/10000_unique_identifiers-8      826kB ± 0%     164kB ± 0%  -80.16%  (p=0.000 n=10+10)
ToOrderedSlice/100000_unique_identifiers-8    9.25MB ± 0%    1.61MB ± 0%  -82.64%  (p=0.000 n=10+10)

name                                        old allocs/op  new allocs/op  delta
ToOrderedSlice/1_unique_identifiers-8           2.00 ± 0%      2.00 ± 0%     ~     (all equal)
ToOrderedSlice/10_unique_identifiers-8          6.00 ± 0%      2.00 ± 0%  -66.67%  (p=0.000 n=10+10)
ToOrderedSlice/100_unique_identifiers-8         9.00 ± 0%      2.00 ± 0%  -77.78%  (p=0.000 n=10+10)
ToOrderedSlice/1000_unique_identifiers-8        12.0 ± 0%       2.0 ± 0%  -83.33%  (p=0.000 n=10+10)
ToOrderedSlice/10000_unique_identifiers-8       21.0 ± 0%       2.0 ± 0%  -90.48%  (p=0.000 n=10+10)
ToOrderedSlice/100000_unique_identifiers-8      31.0 ± 0%       2.0 ± 0%  -93.55%  (p=0.000 n=10+10)

For ToSLice we use the same changes except the sort operation. In this
case the results are even more impressive: allocations are stable at
just 1 per operation, regardless of set size, and performance is
orders of magnitude faster:

name                                 old time/op    new time/op    delta
ToSlice/1_unique_identifiers-8         83.0ns ± 1%    92.4ns ± 0%    +11.37%  (p=0.000 n=9+8)
ToSlice/10_unique_identifiers-8         295ns ± 4%     749ns ± 3%   +154.21%  (p=0.000 n=10+10)
ToSlice/100_unique_identifiers-8       2.33µs ± 2%    4.28µs ± 2%    +83.62%  (p=0.000 n=9+8)
ToSlice/1000_unique_identifiers-8      25.4µs ±10%    34.7µs ± 1%    +36.51%  (p=0.000 n=10+10)
ToSlice/10000_unique_identifiers-8      215µs ± 2%     543µs ± 1%   +152.15%  (p=0.000 n=9+10)
ToSlice/100000_unique_identifiers-8    2.05ms ± 2%    7.17ms ± 1%   +249.53%  (p=0.000 n=9+9)

name                                 old alloc/op   new alloc/op   delta
ToSlice/1_unique_identifiers-8          16.0B ± 0%     16.0B ± 0%       ~     (all equal)
ToSlice/10_unique_identifiers-8          160B ± 0%      496B ± 0%   +210.00%  (p=0.000 n=10+10)
ToSlice/100_unique_identifiers-8       1.79kB ± 0%    4.08kB ± 0%   +127.68%  (p=0.000 n=10+10)
ToSlice/1000_unique_identifiers-8      16.4kB ± 0%    32.8kB ± 0%    +99.90%  (p=0.000 n=10+10)
ToSlice/10000_unique_identifiers-8      164kB ± 0%     826kB ± 0%   +404.12%  (p=0.000 n=8+10)
ToSlice/100000_unique_identifiers-8    1.61MB ± 0%    9.25MB ± 0%   +475.93%  (p=0.000 n=10+10)

name                                 old allocs/op  new allocs/op  delta
ToSlice/1_unique_identifiers-8           1.00 ± 0%      1.00 ± 0%       ~     (all equal)
ToSlice/10_unique_identifiers-8          1.00 ± 0%      5.00 ± 0%   +400.00%  (p=0.000 n=10+10)
ToSlice/100_unique_identifiers-8         1.00 ± 0%      8.00 ± 0%   +700.00%  (p=0.000 n=10+10)
ToSlice/1000_unique_identifiers-8        1.00 ± 0%     11.00 ± 0%  +1000.00%  (p=0.000 n=10+10)
ToSlice/10000_unique_identifiers-8       1.00 ± 0%     20.00 ± 0%  +1900.00%  (p=0.000 n=10+10)
ToSlice/100000_unique_identifiers-8      1.00 ± 0%     30.00 ± 0%  +2900.00%  (p=0.000 n=10+10)

Signed-off-by: Leandro López <leandro.lopez@grafana.com>
2021-03-25 15:44:43 +01:00
Leandro López
067dc391aa Add IdentifierSet.ToOrderedSlice and ToSlice benchmarks
This will be useful later on when implementing the performance
improvements to compare how much we gain.

Signed-off-by: Leandro López <leandro.lopez@grafana.com>
2021-03-25 15:44:43 +01:00
Hanyu Cui
63a452246d
Support different output streams than os.Stderr for std.trace (C API) (#520)
Support different output streams than os.Stderr for std.trace (C API)
2021-03-21 20:03:01 +01:00
Stanisław Barzowski
7d81091149
Linter README – replace unicode asterisks
I think they were an artifact of copying from a LaTeX-generated PDF.
2021-02-21 20:59:24 +01:00
Lucas Servén Marín
9b6cbef4ca testdata: std.manifestJsonEx text cases more types
This commit adds test cases for more types to ensure that
std.manifestJsonEx continues to work with all types that may be given
as the `value` parameter.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
2021-02-15 14:44:08 +01:00
Lucas Servén Marín
9bba8deca0 testdata: add manifestJsonEx array test case
This commit adds a test case to prevent regressions in
std.manifestJsonEx accepting arrays as values.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
2021-02-15 14:44:08 +01:00
Lucas Servén Marín
5d0f3fb5ed builtins.go: fix builtinManifestJSONEx regression
This commit fixes a regression in std.manifestJsonEx that caused the
standard library function to error when the given value was an array.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
2021-02-15 14:44:08 +01:00
Hanyu Cui
f742f2463e
Allow setting a different output stream than os.Stderr for std.trace (#514)
Allow std.trace output to other streams
2021-02-09 14:44:23 +01:00
Kumar Gaurav
4a3144a417 pre-commit hook to format jsonnet files 2021-02-06 14:47:43 +01:00
gotwarlost
6d6c293079 allow initialization of external and TLA code variables from an AST node.
This allows configuration of a VM with an external code variable that has been pre-parsed into an AST node.
This allows a caller to pre-parse a large object into a node and re-use that for multiple VMs. The cost
of converting the object to an ast.Node is incurred only once by the caller as opposed to having this
eagerly incurred (whether or not the object is used) before the eval.
2021-02-04 12:05:09 +01:00
Krishnan Anantheswaran
8a3fcc0302
Allow reset of ext and TLA vars for VM reuse (#509)
Allow reset of ext and TLA vars for VM reuse

Currently ext and TLA vars can be set but not reset. This makes
re-using VMs that have different variables impossible.

Add VM methods to be able to reset ext and TLA vars
2021-02-03 22:55:13 +01:00
Hanyu Cui
cd59751527
Distinguish go-jsonnet from cpp-jsonnet in version message (#497)
Distinguish the Go implementation in the version message
2021-01-13 20:46:15 +01:00
Stanisław Barzowski
31d71aaccd Add missing linter metadata for stdlib.
Fixes #483.
2021-01-01 19:17:40 +01:00
Stanisław Barzowski
6140a2f75a Better stacktrace for manifestation, +: and object assertions.
Fixes #282
2021-01-01 19:17:27 +01:00
Hanyu Cui
7d3bda3911
Add std. manifestJsonMinified (#492)
Pick up std changes in cpp and update builtinManifestJSONEx
2020-12-31 11:20:31 +01:00
Stanisław Barzowski
4beab6633f Prevent keeping files open for too long.
Fixes #485.
2020-12-21 01:14:30 +01:00
Lucendio
fd65a61e87 Fix builds filter ro re-enable darwin builds
I was not able to find any evidences of darwin builds being disabled intentionally. Considering
the [documentation](https://goreleaser.com/customization/build/) I suspect that this was by
mistake. Currently, each list item is applied individually (OR). If I'm wrong, please discard this
PR and share your reasoning.
2020-12-12 23:49:31 +01:00