Res is the minimum interface you need to implement to define a new resource.
| 254 | |
| 255 | // Res is the minimum interface you need to implement to define a new resource. |
| 256 | type Res interface { |
| 257 | fmt.Stringer // String() string |
| 258 | |
| 259 | KindedRes |
| 260 | NamedRes // TODO: consider making this optional in the future |
| 261 | MetaRes // All resources must have meta params. |
| 262 | |
| 263 | // Default returns a struct with sane defaults for this resource. |
| 264 | Default() Res |
| 265 | |
| 266 | // Validate determines if the struct has been defined in a valid state. |
| 267 | Validate() error |
| 268 | |
| 269 | // Init initializes the resource and passes in some external information |
| 270 | // and data from the engine. |
| 271 | Init(*Init) error |
| 272 | |
| 273 | // Cleanup is run by the engine to clean up after the resource is done. |
| 274 | Cleanup() error |
| 275 | |
| 276 | // Watch is run by the engine to monitor for state changes. If it |
| 277 | // detects any, it notifies the engine which will usually run CheckApply |
| 278 | // in response. If the input context cancels, we must shutdown. |
| 279 | Watch(context.Context) error |
| 280 | |
| 281 | // CheckApply determines if the state of the resource is correct and if |
| 282 | // asked to with the `apply` variable, applies the requested state. If |
| 283 | // the input context cancels, we must return as quickly as possible. We |
| 284 | // should never exit immediately if this would cause permanent |
| 285 | // corruption of some sort. However it doesn't mean that a resource was |
| 286 | // taken to the desired state. The input context is not guaranteed to |
| 287 | // cancel when you return from this function. If that's required for |
| 288 | // your code to free memory, make sure to wrap it, cancel it on return |
| 289 | // with a defer, and wait for any workers to exit with a waitgroup. |
| 290 | CheckApply(ctx context.Context, apply bool) (checkOK bool, err error) |
| 291 | |
| 292 | // Cmp compares itself to another resource and returns an error if they |
| 293 | // are not equivalent. This is more strict than the Adapts method of the |
| 294 | // CompatibleRes interface which allows for equivalent differences if |
| 295 | // the have a compatible result in CheckApply. |
| 296 | Cmp(Res) error |
| 297 | } |
| 298 | |
| 299 | // Repr returns a representation of a resource from its kind and name. This is |
| 300 | // used as the definitive format so that it can be changed in one place. |
no outgoing calls
no test coverage detected