1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-01 07:21:07 +00:00
Commit Graph

94 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
Ricardo Weir
2ab2ab38f4 Add ability to copy controller and add useragent 2022-12-28 18:18:58 -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
Kinara Shah
cba80063e7
Merge pull request #416 from jakefhyde/update-deprecated-message 2022-06-21 10:37:21 -07:00
Jake Hyde
7113b21724 Update Deprecated comment in controller template
Deprecated comments should begin with "Deprecated:" so it is recognized
by modern linters.
2022-06-10 18:30:15 -04:00
Ricardo Weir
dd482e4939 Add generate package comment 2022-05-18 17:50:03 -07:00
Ricardo Weir
777953ddaf Update template to use no change update env var 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
1f8e5372ca Ensure namespaced scoped listers default to the correct namespace 2020-08-26 17:44:45 -07:00
Darren Shepherd
d8c3e21805 Ensure controller is scoped to namespace 2020-08-26 15:33:30 -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
e5c98bf4da Remove unneeded imports in code templates 2020-07-11 10:01:19 -07:00
Darren Shepherd
4b0a7e6b91 Rebase on lasso 2020-05-16 21:59:53 -07:00
rawmind0
1e35d1c396 Fix ListAll function on types_template.go to depaginate results on collection 2020-02-11 14:07:00 +01:00
rawmind0
9035b1ea41 Added ListAll function on types_template.go to depaginate results on collection 2020-02-10 11:26:04 +01:00
Darren Shepherd
fb2d75a6b8 Remove unused interfaces 2020-02-05 21:16:03 -07:00
Darren Shepherd
202dd06a36 Add EnqueueAfter 2020-02-05 21:16:03 -07:00
nanorobocop
8a250ebde2 Add ListNamespaced method for ObjectClient 2019-11-06 11:22:11 +09:00
Dax McDonald
1fff189de5 Remove PutClusterScoped from controllers 2019-08-21 13:45:52 -07:00
Dax McDonald
88a4fa4f24 Add PutClusterScoped to NewLifecycleAdapter & add imports 2019-08-21 13:36:22 -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
dax
f5744043a6 Refactor set of cluster scoped handlers
Problem: Cluster scoped gc was taking significantly longer to complete
than before 7387aa5. This was due to a large number of list calls and
the time needed to iterate over them.

Solution: Instead of requesting every type than Rancher uses, a
seperate map appended to when a cluster scoped handler
is created. The full map of all GroupVersionResources is kept as a
fallback for the use case where user controllers may exist on another
host other than the current leader.
2019-05-28 18:48:15 -07:00
dax
7387aa53a5 Record cluster scoped handlers
Problem: Cluster scoped handlers were not being cleaned up without
manually writing garbage collection functions.

Solution: All cluster scoped handlers will be recorded in a global map
in a generic format so that they can be removed by a generic function.
2019-04-23 12:25:39 -07:00
Dan Ramich
01a9966237 Fix file name for mocks 2019-04-11 09:34:19 -07:00
Darren Shepherd
03b89d4fb7
Merge pull request #268 from dramich/genin
Generate fakes for controllers
2019-04-10 09:44:29 -07:00
Guilhem Lettron
15538392b2
Registers metav1 resource types
More information here: 0d42e742da
2019-04-08 20:59:26 +02:00
Guilhem Lettron
9d7a35cf47
Add json:items to list objects
Fix apimachinery work on list objects

ef51ab1605/pkg/runtime/conversion.go (L46):6
2019-04-08 13:27:10 +02:00
Dan Ramich
67bb53a805 Generate fakes for controllers 2019-04-05 10:24:14 -07:00
Darren Shepherd
4350a8688b Add Interface to Clients 2018-12-17 15:44:50 -07:00
Darren Shepherd
a20e5736da Fix patch to require patchtype parameter 2018-12-17 15:43:21 -07:00
Darren Shepherd
9c8de64358 Add type constructors to make things a bit nicer 2018-12-17 15:43:21 -07:00
Darren Shepherd
f1c772b7f1 Fix bugs in lifecycle 2018-11-26 10:46:27 -07:00
Darren Shepherd
a036721900 New client style 2018-11-26 08:43:27 -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
77869d26b3 Handlers return object and error 2018-10-30 09:57:37 -07:00
Darren Shepherd
e0dbf6c51e Generate factory methods for clients 2018-10-22 10:52:03 -07:00
Darren Shepherd
c71b5d3258 Delete unused code 2018-10-22 10:51:51 -07:00
Darren Shepherd
611d7cb0f1 Add support for k8s 1.12 2018-10-09 19:30:04 -07:00
Darren Shepherd
a5698a8e86 Add method to client to get GenericController 2018-09-24 09:00:20 -07:00
Dan Ramich
12c3f92bed Revert changes to template for controllers 2018-08-23 14:48:08 -07:00
Dan Ramich
0953e9e976 Update template to include created label 2018-07-25 09:31:30 -07:00
Darren Shepherd
58723a866e Formatting change for generated client 2018-07-19 10:23:17 -07:00
Darren Shepherd
23c18792d2 Add replace to client 2018-07-19 10:23:17 -07:00