1
0
mirror of https://github.com/rancher/norman.git synced 2025-07-18 17:31:07 +00:00
Commit Graph

40 Commits

Author SHA1 Message Date
Eric Promislow
aea209ce8e Gengo v2 dropped the args package.
Norman doesn't use any other parts of gengo, so just inline the one
function it uses from gengo v1.
2024-05-05 15:21:27 -07:00
Jiaqi Luo
5d579d3486 bump Go to 1.19 and fix errores golangci-lint reports 2022-12-02 19:55:36 -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
Ricardo Weir
dd482e4939 Add generate package comment 2022-05-18 17:50:03 -07:00
Donnie Adams
eb95d28e82 Stop ignoring id fields for sub-schemas
When generating types, any field with name "id" was being skipped. The intention
here was to skip the "id" field of the embedded types.Resource struct. A type
will have an embedded types.Resource struct when the hasGet function returns
true. Therefore, this hasGet function is also used to skip the id fields as
desired.
2021-11-29 16:19:56 -07: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
Darren Shepherd
31e64b1a62 Updates to generator to improve speed 2020-07-14 12:26:39 -07:00
Darren Shepherd
86ca75f99f Use newer moq that works better with modules 2020-07-11 23:53:16 -07:00
Darren Shepherd
c676030ce4 Updates to make rancher/types move work 2020-07-11 10:01:57 -07:00
Darren Shepherd
4b0a7e6b91 Rebase on lasso 2020-05-16 21:59:53 -07:00
Dan Ramich
01a9966237 Fix file name for mocks 2019-04-11 09:34:19 -07:00
Dan Ramich
67bb53a805 Generate fakes for controllers 2019-04-05 10:24:14 -07:00
Darren Shepherd
49a49464b7 rename field to privateTypes 2018-11-09 10:07:22 -07:00
Darren Shepherd
fa4bdda91b Switch handler return type to runtime.Object 2018-11-06 09:55:18 -07:00
Darren Shepherd
03ab04b638 Generator and build cleanup 2018-10-30 23:01:41 -07:00
Darren Shepherd
c71b5d3258 Delete unused code 2018-10-22 10:51:51 -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
Craig Jellick
df1aea6651 Support for backend types
Allows users to specify "backend" types that will have kubernetes
controllers and clients generated but no Rancher client generated.

The intended use to allow for creating a CRD and the supporting code
without having to expose the CRD in the Rancher API.
2018-06-19 09:38:20 -07:00
zionwu
79b91ea33c Add hostname tag and fix dnsLabel validation issue 2018-05-18 08:27:25 -07:00
Dan Ramich
e6973cb055 Update action generation code
Problem:
Action generation code does not account for a resource action that does not
have an output

Solution:
Update template to output all actions
2018-04-27 09:26:01 -07:00
Dan Ramich
9f2b71df50 Update generator to handle collection as an output 2018-04-02 11:35:50 -07:00
Darren Shepherd
d20a37adbe Update CanList API 2018-03-31 03:25:04 -07:00
Dan Ramich
7edec77619 Add ability to generate collection actions
Problem:
Collections have actions but are not accessable through the types
clients

Solution:
Update template and generator to output actions living on collections
2018-03-31 03:13:13 -07:00
Darren Shepherd
67264fa498 Fix generator for new access control 2018-01-17 01:11:22 +00:00
Darren Shepherd
9ce12b1644 Don't generate the ID field 2018-01-16 05:10:36 +00:00
Darren Shepherd
162f6088af Add intOrString and dnsLabel types 2017-12-29 22:23:14 +00:00
Darren Shepherd
36e9738cde Add base64 type 2017-12-22 23:19:30 -07:00
Darren Shepherd
2550f12a9a Add offspring controller 2017-12-19 21:44:02 -07:00
Darren Shepherd
4044cb0141 Generate scheme objects 2017-12-16 01:30:46 -07:00
Darren Shepherd
18d3f69aa8 Updates 2017-12-05 09:21:47 -07:00
Darren Shepherd
9be32ca0a5 run goimports for native types 2017-11-28 16:10:50 -07:00
Darren Shepherd
389d27b3e5 Updates 2017-11-28 14:28:25 -07:00
Darren Shepherd
38c9c5c6c3 Subcontext and mapping updates 2017-11-21 15:37:22 -07:00
Darren Shepherd
6b05d03f46 Random fixes 2017-11-14 21:34:30 -07:00
Darren Shepherd
c87d1846e2 Don't use internal schema 2017-11-13 15:18:44 -07:00
Darren Shepherd
9cb51e9a46 Generate clients in clientset style 2017-11-13 12:50:25 -07:00
Darren Shepherd
591b663b2d Changes to generator for deepcopygen 2017-11-11 17:07:09 -07:00
Darren Shepherd
e9dea7f5f6 Switch generator to goimports 2017-11-10 22:07:22 -07:00
Darren Shepherd
c8cab3f4f8 More initial dev 2017-11-10 21:46:30 -07:00