Commit Graph

49 Commits

Author SHA1 Message Date
Ed Overton
985835f96f perf: limit initSchema calls from openapi.IsNamespaceScoped (#5076)
* test: add openapi.IsNamespaceScoped benchmark

Add a benchmark test for IsNamespaceScoped performance when the default
schema is in use.

* perf: limit initSchema calls from openapi.IsNamespaceScoped

Avoid calling initSchema from openapi.IsNamespaceScoped when possible.
Work done in #4152 introduced a precomputed namespace scope map based on
the default built-in schema. This commit extends that work by avoiding
calls to initSchema when a resource is not found in the precomputed map
and the default built-in schema is in use. In those cases, there is no
benefit to calling initSchema since the precomputed map is exactly what
will be calculated by parsing the default built-in schema.

* fix: delay parsing of default built-in schema

When namespace scope can be determined by the precomputed map but the
type is not present in the precomputed map, delay the parsing of the
default built-in schema.

If the schema to be initialized is the default built-in schema and the
type is not in the precomputed map, then the type will not be found in
the default built-in schema. There is no need to parse the default
built-in schema for that answer; its parsing may be delayed until it
is needed for some other purpose.

In cases where the schema is used solely for namespace scope checks, the
schema might not ever be parsed. Skipping the parsing reduces both
execution time and memory use.

* fix: correct openapi.go's schemaNotParsed value

openapiData initializes with defaultBuiltInSchemaParseStatus set to 0,
so schemaNotParsed should have 0 as its value.
2023-09-08 12:34:30 -07:00
Jefftree
e1ab8c79c1 Replace gnostic with gnostic-models 2023-05-31 18:14:33 +00:00
Patryk Małek
f7c3fce6a5 fix(kyaml): add lock for schema related globals 2023-01-27 09:40:47 +01:00
Brian Pursley
ace8132edc Improve panic error message to include the parse error. 2023-01-18 21:37:13 -05:00
Kubernetes Prow Robot
588da7e392 Merge pull request #4852 from pacoxu/psp-cleanup
remove PSP as v1.25 remove it
2022-11-30 08:44:55 -08:00
Paco Xu
37ad9b1d4e remove PSP as v1.25 remove it 2022-11-30 10:16:39 +08:00
Oscar Utbult
88cf251ef7 grammar: replace all occurrences of "the the" with "the" 2022-09-17 22:28:56 +02:00
Katrina Verey
f6b72077c8 Stop using deprecated ioutil functions 2022-08-10 18:22:46 -04:00
Natasha Sarkar
1b0fe2a078 update openapi scripts to fetch protobuffer schemas (#4582)
* update openapi scripts to fetch protobuffer schema

* code review

* code review

* restore makeOpenApiInfoDotGo.sh

* code review
2022-08-05 15:00:32 -07:00
Natasha Sarkar
cf89eae804 openapi parsing performance improvement with protobuffer (#4568)
* update necessary dependencies

* update openapi test structure

* remove old swagger files and generate new ones

* use protobuffer to parse openapi for performance improvement
2022-04-18 11:10:43 -07:00
Katrina Verey
b0d2e4bdcd Enable more linters for new code 2022-03-31 11:37:26 -04:00
Katrina Verey
71bf0d5d14 Update full linter list and enable some easily resolved new ones 2022-03-31 11:37:26 -04:00
natasha41575
11e19a3d0f separate custom openapi test from the others 2021-10-04 18:48:54 -07:00
natasha41575
0d8c107362 fix issue with openapi schema from components 2021-09-27 17:00:14 -07:00
Kubernetes Prow Robot
c1ae234a64 Merge pull request #4163 from natasha41575/multipleGvksInOpenApi
support multiple gvks in custom openapi schema
2021-09-16 12:59:26 -07:00
Natasha Sarkar
02cb395ec2 support multiple gvks in custom openapi schema 2021-09-16 12:43:18 -07:00
John Howard
402f6ca72b Precompute IsNamespaceScoped to avoid expensive schema reads (#4152)
* Precompute IsNamespaceScoped to avoid expensive schema reads

See https://github.com/GoogleContainerTools/kpt/issues/2469

For the `gcr.io/kpt-fn/set-namespace:v0.1` function, over 50% of CPU
time is spent on IsNamespaceScoped. Instead of unmarshalling 100k lines
of JSON to determine this, instead just precompute it. We can ensure
this never is inaccurate as the test verifies the precomputed result is
up to date.

In real world kpt pipelines this cuts execution of set-namespace (and
similar functions, just an example of a trivial function) from 2.0s to
1.0s. Because these functions are run in long pipelines over many
resources, this adds up a lot.

* Add documentation
2021-09-09 10:08:11 -07:00
Natasha Sarkar
0537b59f27 support yaml formatted openapi schema (#4017)
* support yaml formatted openapi schema

* suggested changes
2021-07-15 14:11:02 -07:00
monopole
660847225d Simplify gvk, speed up cluster-scoped checks. 2021-05-02 13:17:33 -07:00
Gautier Delorme
a2871181fe remove go-openapi/spec,validate,strfmt from kyaml/
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com>
2021-04-25 16:57:39 +02:00
Natasha Sarkar
a513c56d88 parse custom schema only once when necessary 2021-03-10 13:45:53 -08:00
Natasha Sarkar
48e4cad72e kustomization openapi data should be parsed for custom schema 2021-02-24 15:27:50 -08:00
Natasha Sarkar
5a0e193002 moved common resource definitions to separate function 2021-02-23 17:21:16 -08:00
Natasha Sarkar
7dd0ade0f9 add openapi/path field to use custom openapi schema document 2021-02-19 14:19:22 -08:00
Natasha Sarkar
659a7de8f9 edited kyaml libraries to use the openapi field from the kustomization file 2021-01-22 16:07:18 -08:00
Phani Teja Marupaka
b6a4dd446a Refactor openAPI
Refactor global openapi
2020-11-16 23:03:56 -08:00
Kubernetes Prow Robot
9569ca93d9 Merge pull request #3220 from natasha41575/OpenApiVersionField
Add multiple versions of OpenAPI schema to kyaml
2020-11-13 10:39:05 -08:00
Natasha Sarkar
4d7600d4ef updated comments and readme 2020-11-12 18:02:11 -08:00
Phani Teja Marupaka
2278e01b7f Delete v1 setters code 2020-11-12 15:29:07 -08:00
Natasha Sarkar
b61a115e76 added support for multiple kubernetes openapi schemas 2020-11-11 18:09:41 -08:00
Natasha Sarkar
df0576a270 use merge key tuple instead of single merge key 2020-11-09 11:34:31 -08:00
Phani Teja Marupaka
ec2cc2d421 Defer openAPI cleanup 2020-11-05 13:49:43 -08:00
Natasha Sarkar
c1c2725360 regenerated swagger.go files and updated asset name 2020-10-19 13:04:56 -07:00
Phani Teja Marupaka
eba9edd7a6 Sync openAPI setter values with schema 2020-09-22 14:05:05 -07:00
Morten Torkildsen
d083c7f1d0 Determine namespaceability of resources from openapi schema 2020-09-12 15:01:42 -07:00
Phani Teja Marupaka
f432f4d75e Setters with subpackages 2020-09-01 10:54:08 -07:00
jregan
0e13eadd7a IsFieldEmpty renamed to MapNode.IsNilOrEmpty 2020-08-10 10:24:02 -07:00
jregan
31c59bd7f2 Drop all calls to IsEmpty. 2020-08-09 10:47:06 -07:00
Phillip Wittrock
09894d3022 Support merging primitive lists 2020-06-23 12:39:51 -07:00
Phani Teja Marupaka
f81d766584 Kustomization openapi 2020-04-13 23:21:17 -07:00
Phillip Wittrock
370502ed4b Setters: support for setting string list fields 2020-03-07 13:53:24 -08:00
Phillip Wittrock
5d1a0346b5 Use OpenAPI when merging (3way) resources
- When merging (3way) resources use the patch strategy from the openAPI if the definition exists for the field
- Allow disabling of guessing patch strategy merge keys when no definition exists
- Support defining strategy and key directly on configuration fields through line and header coments
- Support attaching schema to parent fields of lists, and propagating -- e.g. that a field is a PodTemplate
2020-03-02 20:56:53 -08:00
Phillip Wittrock
b7bef5dc44 openapi support for loading definitions from a file 2020-02-19 08:13:26 -08:00
Kubernetes Prow Robot
3fc359043a Merge pull request #2199 from phanimarupaka/Setters2ReadAndWrite
Setter Definitions read and write
2020-02-12 10:14:51 -08:00
Phillip Wittrock
7097013426 setters 2.0 2020-02-11 11:00:58 -08:00
Phani Teja Marupaka
29fbc564e3 Setter Definitions read and write 2020-02-11 10:45:39 -08:00
Phillip Wittrock
073a11f3f1 Support loading openapi from []bytes 2020-02-05 08:43:11 -08:00
Phillip Wittrock
8a2c886ab2 update kyaml go.mod and go.sum
also update cmd/config,cmd/kubectl,cmd/resource
2020-01-09 08:50:11 -08:00
Phillip Wittrock
abeab51cae Library for getting Resource and field Schema from OpenAPI 2020-01-08 10:47:11 -08:00