engine: resources, lang: Set resource fields more accurately

There were some bugs about setting resource fields that were structs
with various fields. This makes things more strict and correct. Now we
check for duplicate field names earlier (duplicates due to identical
aliases) and we also don't try and set private fields, or incorrectly
set partial structs.

Most interestingly, this also cleans up all of the resources and ensures
that each one has nicer docs and a clear struct tag for fields that we
want to use in mcl. These are mandatory now, and if you're missing the
tag, then we will ignore the field.
This commit is contained in:
James Shubin
2023-08-23 00:52:21 -04:00
parent b8d87e2d5a
commit c1850e0e20
24 changed files with 394 additions and 212 deletions

View File

@@ -65,22 +65,27 @@ type DockerContainerRes struct {
traits.Edgeable
// State of the container must be running, stopped, or removed.
State string `yaml:"state"`
State string `lang:"state" yaml:"state"`
// Image is a docker image, or image:tag.
Image string `yaml:"image"`
Image string `lang:"image" yaml:"image"`
// Cmd is a command, or list of commands to run on the container.
Cmd []string `yaml:"cmd"`
Cmd []string `lang:"cmd" yaml:"cmd"`
// Env is a list of environment variables. E.g. ["VAR=val",].
Env []string `yaml:"env"`
Env []string `lang:"env" yaml:"env"`
// Ports is a map of port bindings. E.g. {"tcp" => {80 => 8080},}.
Ports map[string]map[int64]int64 `yaml:"ports"`
Ports map[string]map[int64]int64 `lang:"ports" yaml:"ports"`
// APIVersion allows you to override the host's default client API
// version.
APIVersion string `yaml:"apiversion"`
APIVersion string `lang:"apiversion" yaml:"apiversion"`
// Force, if true, this will destroy and redeploy the container if the
// image is incorrect.
Force bool `yaml:"force"`
Force bool `lang:"force" yaml:"force"`
client *client.Client // docker api client