1
0
mirror of https://github.com/rancher/norman.git synced 2025-06-26 07:23:44 +00:00
Commit Graph

53 Commits

Author SHA1 Message Date
Chad Roberts
489e557d5f
Update to golangci-lint and fix linting errors discovered by the updated version. (#602) 2025-02-18 12:18:36 -08:00
Jiaqi Luo
29dae41a91 remove the checks on some return values, which was added recently by another PR, to make it work when being used in rancher 2022-12-02 20:27:19 -07:00
Steffan Tucker
1e41884a06
Fix golangci-lint issues
As part of updating dapper files, golangci-lint was set to be used. This
caused a lot of lint issues to crop up, which this fixes.
2022-07-26 10:40:30 -06:00
Colleen Murphy
6e4b2bab93 Add norman field attribute "pointer"
Add a new field attribute "pointer" to indicate that the generated
client code for the field must be a pointer. This allows clients to
differentiate between sending nil/leaving the value unset and sending an
empty map or slice.

This change also removes the `nullablestring` norman type introduced in
30f8d18 since schemas that need a pointer to a string can now use this
field attribute. There are no libraries currently using this feature so
it should be safe to remove.

Example usage:

```
Labels map[string]string `json:"labels" norman:"pointer"`
```

Resulting API schema:

```
"labels": {
  "create": true,
  "nullable": true,
  "pointer": true,
  "type": "map[string]",
  "update": true
}
```

Generated client code:

```
Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
```
2021-06-07 16:33:59 -07:00
Colleen Murphy
30f8d1802b Add 'nullablestring' field type
Currently, `*string` fields in Go structs are converted to `{type:
string, nullable: true}` in the API schema, which is right, but then
converted down to just `string` when converted to generated client
structs. Without this patch, there is no way to express that `*string`s
should stay as `*string`s when run through the generator, because the
'nullable' flag is ignored. Compare this to `*bool`s, which become
`boolean` in the schema and then correctly converted back to *bool in
the generator. This patch adds a backwards-compatible way to opt in to
converting `*string`s in the original struct to *strings in the
generated struct.
2021-05-01 16:24:23 -07:00
rmweir
5a269325d1 Differentiate between empty and nil arrays
Prior, empty array were converted to nil. In some cases the
difference between a nil and empty array are not arbitrary.
Now, empty arrays will be converted to empty interface arrays
and nil array will be converted to nil interface arrays.
2020-08-20 15:32:34 -07:00
rmweir
2da1bd2ffc Add enable function and addFeature functions
Added enable function to schemas. This allows filtering of schemas
which is a required part of feature flagging in rancher. Added
addFeature functions to controller template for adding handlers that
can be disabled if their associated feature is disabled.
2019-07-02 12:18:40 -07:00
rmweir
9836657574 Add no pagination option
There is now a recognized option for opting out of pagination.
Prior, passing a limit of -1 would set the pagination limit to
the default, 1000. Now, a value of -1 will set the pagination
limit to the max, likely resulting in a non paginated response.
2019-04-05 16:42:43 -07:00
Alena Prokharchyk
cf3f1e303f MinLength verification bug fix 2019-01-29 13:55:47 -08:00
Aiwantaozi
1883e14f29 add float 2018-11-15 10:09:38 +08:00
Nathan Jenan
915dc06a9d Revert "Revert "Don't strip strings on output""
This reverts commit 4bcc025ae3.
2018-09-10 20:34:17 -07:00
Craig Jellick
4bcc025ae3 Revert "Don't strip strings on output"
This reverts commit 5e344d90cd.
Tested this and it broke more scenarios
2018-08-17 14:28:10 -07:00
Darren Shepherd
5e344d90cd Don't strip strings on output 2018-08-13 10:00:02 -07:00
Darren Shepherd
c29825b3db Rename IsEmpty to IsAPIObjectEmpty 2018-07-19 10:23:17 -07:00
Darren Shepherd
1d4a52cb31 make type conversion and field validation public util methods 2018-07-19 10:23:17 -07:00
Darren Shepherd
51ea2cd7f6 Rename method 2018-07-19 10:23:17 -07:00
Darren Shepherd
6db31068a0 Add edit/export modes and drop default resource fields if empty 2018-07-19 10:23:17 -07:00
Dan Ramich
aecae32b4a Fix pagination
Problem:
Pagination is not showing up

Solution:
Pagination was being created properly but then dropped in favor of an
empty version. Save the pagination on the context so it can be accessed
later and not reset.
2018-06-25 15:34:52 -07:00
Alena Prokharchyk
e03c72e855 DnsLabelRestricted type to validate against RFC 1035
k8s uses restricted format for services

dnsLabelRestricted: dns1035LabelFmt string = "[a-z]([-a-z0-9]*[a-z0-9])?"
dnsLabel:dns1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?"
2018-06-19 09:47:36 -07:00
Daishan Peng
59c4a298e8 add yaml support 2018-06-04 16:44:48 -07:00
zionwu
79b91ea33c Add hostname tag and fix dnsLabel validation issue 2018-05-18 08:27:25 -07:00
Darren Shepherd
4cf9f645cd Refactor access control to return error not bool 2018-03-31 03:13:22 -07:00
Darren Shepherd
cff992b3b4 Ignore for nullable enums 2018-03-26 19:06:15 -07:00
Darren Shepherd
bcb8076caa Allow types that start with cluster or project 2018-03-22 15:55:44 -07:00
Craig Jellick
ba0bb125c9 Use request.PostForm instead of request.Form when
PostForm will ignore URL query parameters and will only look at the
body. This is much more useful for actions, which have a query param
that is the action name, but the a json body.  WIthout this change,
the only "field" found when parsing an action body is the name of the
action.
2018-03-15 09:10:03 -07:00
Craig Jellick
cd5dee7857 User proper type field when converting array
Previously we were passing the name of the field, not the type
2018-03-15 09:10:03 -07:00
Darren Shepherd
e0efa84d62 Forgot to assign value 2018-03-04 22:41:12 -07:00
Darren Shepherd
1f0f16a832 Change defaulting logic 2018-03-04 22:06:50 -07:00
Craig Jellick
d9307fc2f7 Fix url escaping
When parsing URL paths, unescape them so that characters that needed escaped
in order to be placed in the a path segment are returned to their original
form.
2018-03-01 21:44:19 -07:00
Craig Jellick
4bcfb14aba Use escaped path for url parsing 2018-03-01 16:29:49 -07:00
Darren Shepherd
f59a6072cf Default empty strings 2018-03-01 14:29:27 -07:00
Darren Shepherd
27b53dd2b6 If you hit /v3/projects/{ID}/schemas make sure schemas have correct URLs 2018-02-14 10:59:23 -07:00
Darren Shepherd
c814e62e43 Fix a series of url parsing issues 2018-02-13 16:44:25 -07:00
Darren Shepherd
63f413add2 Drop password fields from response 2018-02-09 18:04:03 -07:00
Darren Shepherd
722cedfe01 Major refactor of subcontexts 2018-02-09 13:45:22 -07:00
Darren Shepherd
da40fa7b06 don't validate empty string as DNS name 2018-01-21 06:24:22 +00:00
Alena Prokharchyk
69d780d557 DNS label validation 2018-01-20 04:32:10 +00:00
Darren Shepherd
c970c36427 fix json float parsing 2018-01-20 04:31:39 +00:00
Darren Shepherd
aa2538a874 APIContext constructor 2018-01-20 04:31:39 +00:00
Darren Shepherd
8982c1cc59 write writeOnly fields on create 2018-01-20 04:31:39 +00:00
Daishan Peng
409b391766 don't return nonnullable error if default is set 2018-01-18 00:10:57 +00:00
Darren Shepherd
942bde06d7 Validate subtypes in create/update 2018-01-17 23:37:53 +00:00
Craig Jellick
09d44429d1 return errors where appropriate 2018-01-02 19:20:18 -07:00
Darren Shepherd
162f6088af Add intOrString and dnsLabel types 2017-12-29 22:23:14 +00:00
Darren Shepherd
34c01875c5 Have URLParser parse the query too 2017-12-22 23:19:30 -07:00
Darren Shepherd
36e9738cde Add base64 type 2017-12-22 23:19:30 -07:00
Darren Shepherd
9dcef33943 Generate backreference links 2017-12-13 08:55:24 -07:00
Darren Shepherd
406c0d9999 Many enhancements 2017-12-11 20:58:53 -07:00
Darren Shepherd
18d3f69aa8 Updates 2017-12-05 09:21:47 -07:00
Darren Shepherd
15e105a0ab Refactor types 2017-11-29 14:27:02 -07:00