Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Settings Models to the Settings SDK #41

Merged
merged 466 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
466 commits
Select commit Hold shift + click to select a range
b216d6c
settings: Add DNS configurability via `settings.dns`
zmrow Aug 16, 2022
a61a6db
Merge pull request #2298 from mchaker/mchaker-2022-07-fromstr
mchaker Sep 20, 2022
fb52235
Revert "modeled_types: Use FromStr instead of TryFrom"
mchaker Sep 20, 2022
a9a7de5
models: add reboot-to-reconcile boot setting
markusboehme Aug 29, 2022
42d65d8
kubelet: Add setting to change log level
stmcginnis Sep 26, 2022
cce17cb
host-containers: update admin container to v0.9.2
jpculp Sep 30, 2022
2929c2c
kubernetes: fix API model
arnaldo2792 Oct 1, 2022
4626d8b
Merge pull request #2471 from jpculp/admin-container-v0.9.2
jpculp Oct 5, 2022
3dd6d52
host-containers: control container to v0.6.3
ecpullen Oct 3, 2022
d69cd24
sources,variants: add aws-k8s-1.24 variant
arnaldo2792 Oct 7, 2022
8334c45
sources,variants: add aws-k8s-1.24-nvidia variant
arnaldo2792 Oct 7, 2022
dfcba90
sources,variants: add vmware-k8s-1.24 variant
arnaldo2792 Sep 19, 2022
808974b
sources,variants: add metal-k8s-1.24 variant
arnaldo2792 Sep 19, 2022
5d62c39
sources: add symlink for aws-k8s-1.23 variant
arnaldo2792 Sep 19, 2022
d54cc15
sources: add symlink for aws-k8s-1.23-nvidia variant
arnaldo2792 Sep 30, 2022
e1a5d26
sources: add symlink for vmware-k8s-1.23 variant
arnaldo2792 Sep 19, 2022
2194f18
sources: add symlink for metal-k8s-1.23 variant
arnaldo2792 Sep 19, 2022
aa7d4be
Merge pull request #2437 from arnaldo2792/k8s-1.24
arnaldo2792 Oct 7, 2022
92333b7
settings: Add container-runtime settings
stmcginnis Oct 14, 2022
06698c8
Remove kubernetes 1.20 variants
jpmcb Sep 15, 2022
880dad7
trivial: format imports and fix comment
stmcginnis Oct 20, 2022
caf2497
variants: add boot settings for dev builds
bcressey Oct 16, 2022
13ede84
packages: Add AWS config
stmcginnis Oct 7, 2022
c43e350
Merge pull request #2505 from bcressey/secureboot-foundations
bcressey Nov 2, 2022
b031735
Merge pull request #2542 from stmcginnis/cred-prov-aws-config
stmcginnis Nov 3, 2022
70bff17
kubelet: add image credential provider settings
stmcginnis Sep 1, 2022
5cff5fa
feature: Enable configuration of Kubelet TLS certs
stmcginnis Oct 29, 2022
0cb5c0e
kubelet: enable credential provider support
stmcginnis Sep 22, 2022
304947a
ecs: add additional API configurations
arnaldo2792 Oct 26, 2022
ee92c7d
Merge pull request #2527 from arnaldo2792/new-ecs-settings
arnaldo2792 Nov 4, 2022
858ef8b
host-containers: Update admin container to v0.9.3
jpculp Nov 12, 2022
3f97880
host-containers: Update control container to v0.6.4
jpculp Nov 12, 2022
790612a
models: create scalar derive macro
webern Nov 7, 2022
194eb61
Fix various minor formatting issues, mostly in the documentation.
stefansundin Nov 12, 2022
e9ecbc1
scalar-derive: add enum support
webern Nov 21, 2022
b7247b1
models: eliminate enum wrappers for ecs
webern Nov 21, 2022
c10df63
scalar and scalar-derive: fix typos
webern Dec 5, 2022
02f9f7c
kubelet: Restrict access to tls private key
stmcginnis Dec 6, 2022
f4d5a2a
models: fix clippy lints
webern Dec 10, 2022
512af43
sources: update rust dependencies
jpculp Dec 20, 2022
1ca1491
Merge pull request #2639 from stmcginnis/k8s-pki
stmcginnis Jan 4, 2023
be651cb
models: add autoscaling.should-wait setting for k8s variants
gthao313 Oct 12, 2022
e952bf1
models: update ecs variants to use aws-autoscaling.toml
gthao313 Jan 8, 2023
eeddd32
containerd: add OCI default spec and settings
mchaker Jan 6, 2023
c7d3f7f
Add k8s 1.25 variants
stmcginnis Jan 5, 2023
b1d83e6
host-containers: update admin container to v0.9.4
jpculp Jan 18, 2023
f1775b1
host-containers: update control container to v0.7.0
jpculp Jan 18, 2023
5f959bc
Merge pull request #2739 from jpculp/admin-0.9.4-control-0.7.0
jpculp Jan 18, 2023
9356ab4
sources: fix clippy warnings
bcressey Jan 22, 2023
7845788
Removes k8s.gcr.io in favor of registry.k8s.io
jpmcb Feb 8, 2023
42fce0a
sources: Update rust dependencies
jpculp Feb 18, 2023
edfd8ef
Remove kubernetes 1.21 variants
stmcginnis Jan 5, 2023
54e04d3
Update rust edition to 2021
stmcginnis Feb 27, 2023
63000cd
models: change pause container imageref to public-ECR-hosted image
etungsten Mar 6, 2023
01fb2df
add k8s 1.26 variants
gthao313 Feb 1, 2023
5619062
host-containers: update admin container to v0.10.0
markusboehme Mar 6, 2023
642e19a
host-containers: update control container to v0.7.1
markusboehme Mar 6, 2023
3b4a9ee
Merge pull request #2771 from gthao313/k8s-1.26
gthao313 Mar 8, 2023
c443610
Merge pull request #2864 from markusboehme/feature/host-container-upd…
markusboehme Mar 8, 2023
65bbeb7
Fix `sources/models` README from generated content
stmcginnis Mar 14, 2023
84f1a2d
Fix aws.profile rendering in cred-provider template
stmcginnis Mar 17, 2023
ab1954b
modeled_types: allow numbers for k8s gc percent
webern Mar 23, 2023
58d93d5
build: update SDK to 0.31.0
jpculp Mar 29, 2023
65f96fc
kubelet: Enable env variables for cred providers
stmcginnis Mar 23, 2023
0376dbb
Merge pull request #2953 from jpculp/bump-sdk-v0.31.0
jpculp Apr 10, 2023
29af5f1
models: generate 'provider-id' for aws-k8s variants
etungsten Apr 15, 2023
ef84dd1
models,packages: add 'hostname-override' for kubelet, add kubelet option
etungsten Apr 18, 2023
0cf7f2a
models: generate 'hostname-override' and set cp to external in aws-k8…
etungsten Apr 19, 2023
08f46d1
kubelet: Enable setting cpuManagerPolicyOptions
stmcginnis Apr 6, 2023
071cec0
hardening: Enable setting templated file permissions
stmcginnis Mar 21, 2023
2553cc0
kubelet: Add `cpu-cfs-quota-enforced` setting
stmcginnis Mar 22, 2023
f0ec545
kubelet: Add shutdown grace period settings
stmcginnis Mar 22, 2023
0f088ca
kubelet: Add soft eviction settings
stmcginnis Mar 22, 2023
5baf67f
settings: Enabling constraining i32 to non-negative value
stmcginnis Mar 22, 2023
bd203e7
kubelet: Add reserved memory settings
stmcginnis Apr 5, 2023
38ed3ee
kubelet: Add aliases for ValidCpuManagerPolicy
stmcginnis May 4, 2023
225a4ac
Add kubernetes-1.27 package and variants
stmcginnis Apr 20, 2023
30084e7
host-containers: update admin container to v0.10.1
markusboehme May 4, 2023
6d7131d
host-containers: update control container to v0.7.2
markusboehme May 4, 2023
c90328a
Merge pull request #3090 from markusboehme/feature/host-container-upd…
markusboehme May 8, 2023
c0cb567
k8s 1.27: Fix China ECR url pattern
stmcginnis May 9, 2023
ba4a386
Drop Kubernetes 1.22 variants
stmcginnis Apr 7, 2023
999ad33
cleanup: Remove dockershim containerd config files
stmcginnis May 22, 2023
9e20101
sources: fix clippy lints for rust 1.70.0
bcressey Jun 20, 2023
685deab
ecs: add settings to clean up container images
arnaldo2792 Jun 19, 2023
300fef0
Merge pull request #3215 from arnaldo2792/additional-ecs-settings
arnaldo2792 Jun 27, 2023
ee830e1
apiserver: Add /report endpoint for CIS reporting
stmcginnis Mar 14, 2023
7deb9a1
Merge pull request #3135 from stmcginnis/dockershim
stmcginnis Jul 10, 2023
425bd45
Merge pull request #3219 from stmcginnis/cis-agent-apiserver
stmcginnis Jul 11, 2023
79793e1
model-derive: Remove indirect dependencies
stmcginnis Jul 21, 2023
34c2f21
models: add missing ECS NVIDIA variant
arnaldo2792 Jul 19, 2023
167c9cd
variants: add aws-ecs-2
arnaldo2792 Jul 19, 2023
bc06ba1
variants: add aws-ecs-2-nvidia
arnaldo2792 Jul 19, 2023
62f1b73
host-containers: update admin container to v0.10.2
markusboehme Jul 31, 2023
e9cba23
host-containers: update control container to v0.7.3
markusboehme Jul 31, 2023
141bb6e
containerd: add all resource-limit settings for oci default
vyaghras Jun 16, 2023
1faa179
kubelet: Add support for SeccompDefault setting for k8s 1.25+
cartrius-a Aug 7, 2023
2143047
models: Set 'kubernetes.seccomp-default' to false for k8s 1.25+
jpculp Aug 11, 2023
bbe018d
api: enable setting rlimits and capabilities for ecs
vyaghras Jul 12, 2023
b9e6caf
sources, variants: add aws-k8s-1.28 variant
etungsten Aug 1, 2023
f366a6e
sources, variants: add aws-k8s-1.28-nvidia variant
etungsten Aug 1, 2023
5380a54
sources, variants: add vmware-k8s-1.28 variant
etungsten Aug 1, 2023
255ed93
sources, variants: add metal-k8s-1.28 variant
etungsten Aug 1, 2023
d4ecb6b
sources: fix 1.72.0 clippy warnings
etungsten Aug 25, 2023
473a5f0
host-containers: update admin container to v0.11.0
zmrow Aug 27, 2023
a010f45
host-containers: update control container to v0.7.4
zmrow Aug 27, 2023
5491009
Merge pull request #3368 from zmrow/host-container-update
yeazelm Aug 30, 2023
2434ecb
Merge pull request #3329 from etungsten/k8s-1.28
etungsten Aug 31, 2023
22ac025
api: adjust settings for log4j-hotpatch-enabled
arnaldo2792 Sep 1, 2023
d971419
models: add new setting to auto-load kernel modules
foersleo Sep 15, 2023
9079f54
Migrate setting-generators to schnauzer v2
cbgbt Aug 2, 2023
4abf668
Drop K8s 1.23 metal and VMware variants
stmcginnis Oct 16, 2023
87de4ce
sources: update x509-parser
jpculp Oct 16, 2023
a4ea70c
Merge pull request #3532 from jpculp/1.16.0-dependency-updates
jpculp Oct 18, 2023
040acfa
host-containers: update admin container to v0.11.1
cbgbt Oct 24, 2023
1bdac29
host-containers: update control container to v0.7.5
cbgbt Oct 24, 2023
3873c89
sources: update to darling 0.20, syn 2
cbgbt Oct 30, 2023
68864ba
models: move string_impls_for to its own crate
cbgbt Oct 31, 2023
59efbf3
settings: add motd settings extension
cbgbt Oct 30, 2023
45c024e
settings: use motd settings extension in models
cbgbt Oct 30, 2023
6e62807
models: move modeled_types to its own crate
cbgbt Nov 2, 2023
dd09e0c
models: improve hygienics of model-derive macro
cbgbt Nov 3, 2023
d30ce62
shared-defaults: add missing updog to list of network-affected services
etungsten Nov 7, 2023
ff0a096
settings: add ntp settings extension
sam-berning Nov 3, 2023
7fe9ee3
settings: use ntp settings extension in models
sam-berning Nov 9, 2023
7a881b0
packages: create ntp settings extension
sam-berning Nov 10, 2023
1c9d491
host-containers: update admin container to v0.11.2
jpculp Dec 7, 2023
d330a4b
host-containers: update control container to v0.7.6
jpculp Dec 7, 2023
068a486
settings: add container-registry settings extension
sam-berning Dec 6, 2023
7a393e2
settings: use container-registry settings extension in models
sam-berning Dec 7, 2023
df89b79
Merge pull request #3674 from sam-berning/registry-settings-extension
sam-berning Dec 22, 2023
af51a35
settings: add updates settings extension
sam-berning Dec 15, 2023
b09c353
settings: use updates settings extension in models
sam-berning Dec 19, 2023
dc20d84
sources: fix clippy warnings for 1.75.0
jpculp Jan 4, 2024
2564779
Merge pull request #3689 from sam-berning/update-settings-extension-r…
sam-berning Jan 4, 2024
1c5b00b
Add kubernetes-1.29 package and variants
gthao313 Nov 29, 2023
a4c9184
host-containers: update admin container to v0.11.3
markusboehme Jan 9, 2024
e69ba3e
host-containers: update control container to v0.7.7
markusboehme Jan 9, 2024
d4aa874
settings: create kernel settings extension
sam-berning Jan 23, 2024
1de6fd1
settings: use kernel settings extension in models
sam-berning Jan 23, 2024
376b896
Drop K8s 1.24 metal and VMware variants
yeazelm Jan 27, 2024
c771a49
ecs: add additional settings
arnaldo2792 Jan 30, 2024
eae9172
host-containers: update admin container to v0.11.4
yeazelm Feb 6, 2024
893476e
host-containers: update control container to v0.7.8
yeazelm Feb 6, 2024
c88b1c4
settings: remove rand from kernel setting extension
sam-berning Feb 9, 2024
1a62891
settings: sort settings extensions alphabetically
sam-berning Feb 9, 2024
17613e6
settings: create aws settings extension
sam-berning Jan 26, 2024
ed09f35
settings: use aws settings extension in models
sam-berning Jan 26, 2024
7367456
certdog: Adjust certdog to use a generated configuration file
jmt-lab Feb 2, 2024
2dc615c
Merge pull request #3706 from jmt-lab/jmt/ootb/certdog-config-file
jmt-lab Feb 13, 2024
178acbb
ecs: add support for ECS_ENABLE_CONTAINER_METADATA
arnaldo2792 Feb 16, 2024
414e38a
prairiedog: adjust to leverage a rendered config file
jmt-lab Feb 6, 2024
1d711bb
thar-be-updates: migrate to use configuration file
jmt-lab Jan 18, 2024
e2a882c
os: create host-containers config template
sam-berning Feb 13, 2024
33be090
corndog: migrate to use config file
jmt-lab Jan 17, 2024
e193c90
host-containers: update admin container to v0.11.6
ytsssun Mar 19, 2024
145a2d6
host-containers: update control container to v0.7.10
ytsssun Mar 19, 2024
48e715d
sources: bump to aws-sdk v1
jmt-lab Mar 18, 2024
cd4f680
Merge pull request #3830 from jmt-lab/jmt/1.19.3/dependency
jmt-lab Mar 21, 2024
fa8ffb1
bootstrap-containers: migrate to using configuration file
jmt-lab Jan 19, 2024
b2a666d
add k8s-1.30 package and variants boilerplate
ginglis13 Mar 25, 2024
6be53b9
Merge pull request #3724 from jmt-lab/jmt/bootstrap-containers/config
jmt-lab Apr 3, 2024
919fc69
ecs-agent: migrate all ECS settings to drop-ins
arnaldo2792 Mar 18, 2024
bb56522
os: remove ecs-settings-applier
arnaldo2792 Mar 18, 2024
068d7e1
ntp: Add setting to configure options
domgoodwin Mar 25, 2024
f7f3470
Drop k8s 1.25 metal and VMware variants
ginglis13 Apr 12, 2024
24d656c
static-pods: move to own package and include in kubernetes-*
jmt-lab Apr 17, 2024
9d1e7b6
host-containers: update admin container to v0.11.7
vyaghras Apr 24, 2024
71453d5
host-containers: update control container to v0.7.11
vyaghras Apr 24, 2024
bcca3ab
settings: Add container-runtime settings to nvidia variants
yeazelm May 3, 2024
5fcb97e
host-containers: update admin container to v0.11.8
KCSesh May 7, 2024
41b2f34
host-containers: update control container to v0.7.12
KCSesh May 7, 2024
8fc634f
settings: create pki settings extension
mgsharm May 16, 2024
8e0d011
settings: add pki settings extension
mgsharm May 16, 2024
8b9a14a
settings: create metrics settings extension
sumukhballal May 20, 2024
9245987
settings: use metrics settings extension in models
sumukhballal May 20, 2024
fd894eb
settings: create oci hooks settings extension
mgsharm May 22, 2024
c4e8464
settings: use oci hooks settings extension in models
mgsharm May 22, 2024
dc66283
settings: create dns settings extension
mgsharm May 22, 2024
0786b97
settings: use dns settings extension in models
mgsharm May 22, 2024
83e1e00
pluto: convert to be an agent during boot
jmt-lab May 6, 2024
b257260
Merge pull request #3828 from jmt-lab/jmt/ootb/pluto
jmt-lab May 23, 2024
403992a
settings: create ecs settings extension
mgsharm May 23, 2024
2e802b5
settings: use ecs settings extension in models
mgsharm May 23, 2024
b9dabbb
settings: create cloudformation settings extension
mgsharm May 29, 2024
510b65d
settings: use cloudformation settings extension in models
mgsharm May 29, 2024
a6f7868
Drop k8s 1.26 metal and VMWare variants
ginglis13 May 31, 2024
1f0c337
settings: use built-in pause container image for k8s
tzneal May 15, 2024
2bb45d6
Merge pull request #4018 from ginglis13/rm-k8s-1.26-vmware-metal
ginglis13 Jun 4, 2024
6629fc6
Merge pull request #3940 from tzneal/build-pause-image-with-k8s
bcressey Jun 6, 2024
bdf572e
settings: create bootstrap container settings extension
mgsharm Jun 9, 2024
9ac2fc0
settings: use bootstrap container settings extension in models
mgsharm Jun 9, 2024
8821c46
settings: create autoscaling settings extension
mgsharm Jun 9, 2024
0c8fc86
settings: use autoscaling settings extension in models
mgsharm Jun 9, 2024
878dd75
settings: create host-containers settings extension
mgsharm Jun 9, 2024
16bac9a
settings: use host containers settings extension in models
mgsharm Jun 9, 2024
ac804fb
settings: create network settings extension package
mgsharm Jun 10, 2024
c10c254
settings: use network settings extension in models
mgsharm Jun 10, 2024
4b10454
settings: create container runtime settings extension
mgsharm Jun 11, 2024
13d7f9e
settings: use container runtime settings extension in models
mgsharm Jun 11, 2024
5f27ca2
settings: create oci defaults settings extension
mgsharm Jun 11, 2024
fbd2887
settings: use oci defaults settings extension in models
mgsharm Jun 11, 2024
ed75e0c
models: remove structs that migrated to extensions
bcressey Jun 1, 2024
47b9230
sources: refresh settings sdk dependencies
bcressey Jun 5, 2024
4f3c001
settings-plugins: add aws-dev plugin
bcressey Jun 12, 2024
7f7da2a
settings-plugins: add aws-ecs-1 plugin
bcressey Jun 1, 2024
992e873
settings-plugins: add aws-ecs-2 plugin
bcressey Jun 12, 2024
4fed877
settings-plugins: add aws-k8s plugin
bcressey Jun 1, 2024
75c41a9
settings-plugins: add metal-dev plugin
bcressey Jun 12, 2024
47e8977
settings-plugins: add metal-k8s plugin
bcressey Jun 1, 2024
f757c03
settings-plugins: add vmware-dev plugin
bcressey Jun 1, 2024
1740a35
settings-plugins: add vmware-k8s plugin
bcressey Jun 1, 2024
c05299d
models: implement Default and Clone for types
sam-berning Jun 1, 2024
f93eaf9
models: load settings through plugin
sam-berning Jun 6, 2024
e4214ec
models: relocate shared defaults
bcressey Jun 4, 2024
a28ce7d
settings-defaults: add defaults for aws-dev
bcressey Jun 4, 2024
b678d1a
settings-defaults: add defaults for aws-ecs-1
bcressey Jun 4, 2024
d0a9c32
settings-defaults: add defaults for aws-ecs-2
bcressey Jun 4, 2024
f554ef7
settings-defaults: add defaults for aws-ecs-1-nvidia
bcressey Jun 4, 2024
54ad329
settings-defaults: add defaults for aws-ecs-2-nvidia
bcressey Jun 4, 2024
9268f69
settings-defaults: add defaults for aws-k8s-1.24
bcressey Jun 4, 2024
43549dc
settings-defaults: add defaults for aws-k8s-1.24-nvidia
bcressey Jun 4, 2024
6e2f0d6
settings-defaults: add defaults for aws-k8s-1.25
bcressey Jun 4, 2024
51f0904
settings-defaults: add defaults for aws-k8s-1.25-nvidia
bcressey Jun 4, 2024
6bcd691
settings-defaults: add defaults for aws-k8s-1.26
bcressey Jun 4, 2024
67179b2
settings-defaults: add defaults for aws-k8s-1.26-nvidia
bcressey Jun 4, 2024
860b5db
settings-defaults: add defaults for aws-k8s-1.30
bcressey Jun 4, 2024
25fc865
settings-defaults: add defaults for aws-k8s-1.30-nvidia
bcressey Jun 4, 2024
cf15b12
settings-defaults: add defaults for metal-dev
bcressey Jun 4, 2024
3686796
settings-defaults: add defaults for metal-k8s-1.30
bcressey Jun 4, 2024
9487a68
settings-defaults: add defaults for vmware-dev
bcressey Jun 4, 2024
ac0baaf
settings-defaults: add defaults for vmware-k8s-1.30
bcressey Jun 4, 2024
e53ed97
models: drop build-time dependency on VARIANT
bcressey Jun 4, 2024
faa4d16
K8s kubelet reserved-cpus support
james-masson Jun 6, 2024
d18811f
chore: merge models history
cbgbt Jun 17, 2024
c364913
chore: move models into desired directories
cbgbt Jun 17, 2024
221d5c6
fix: remove README generators
cbgbt Jun 13, 2024
4fa24d9
fix: remove unneeded model code
cbgbt Jun 13, 2024
ee1aa1e
fix: create models workspace
cbgbt Jun 13, 2024
8f51c66
fix: change model package names
cbgbt Jun 13, 2024
fefcd0e
refactor: organize symbols in settings-models
cbgbt Jun 13, 2024
dc49279
fix: cargo fmt
cbgbt Jun 13, 2024
7e60558
chore: fix docstrings moved by cargo-fmt
cbgbt Jun 14, 2024
cc68555
chore: update x509-parser to 0.16
cbgbt Jun 14, 2024
973de21
chore: add licence exceptions for icu4x packages
cbgbt Jun 14, 2024
1915c20
chore: use path dependency on settings sdk
cbgbt Jun 14, 2024
4001348
feat: expose settings model apis
cbgbt Jun 14, 2024
3c9b963
feat: use env-logger in motd extension
cbgbt Jun 14, 2024
84e39a3
chore: fix dependency ordering
cbgbt Jun 14, 2024
43c22ac
chore: rename string_impls_for to string-impls-for
cbgbt Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,44 @@
resolver = "2"

members = [
"bottlerocket-settings-sdk",
"bottlerocket-template-helper",
"bottlerocket-defaults-helper",
# Settings Plugin SDK
"bottlerocket-settings-plugin",
"bottlerocket-settings-derive",
"bottlerocket-defaults-helper",

# Public API for Bottlerocket settings models
"bottlerocket-settings-models/settings-models",

# Useful libraries for constructing settings models
"bottlerocket-settings-models/model-derive",
"bottlerocket-settings-models/modeled-types",
"bottlerocket-settings-models/scalar",
"bottlerocket-settings-models/scalar-derive",
"bottlerocket-settings-models/string-impls-for",

# Settings extensions
# These will eventually live in the kit workspaces that own the related software
"bottlerocket-settings-models/settings-extensions/autoscaling",
"bottlerocket-settings-models/settings-extensions/aws",
"bottlerocket-settings-models/settings-extensions/bootstrap-containers",
"bottlerocket-settings-models/settings-extensions/cloudformation",
"bottlerocket-settings-models/settings-extensions/container-registry",
"bottlerocket-settings-models/settings-extensions/container-runtime",
"bottlerocket-settings-models/settings-extensions/dns",
"bottlerocket-settings-models/settings-extensions/ecs",
"bottlerocket-settings-models/settings-extensions/host-containers",
"bottlerocket-settings-models/settings-extensions/kernel",
"bottlerocket-settings-models/settings-extensions/metrics",
"bottlerocket-settings-models/settings-extensions/motd",
"bottlerocket-settings-models/settings-extensions/network",
"bottlerocket-settings-models/settings-extensions/ntp",
"bottlerocket-settings-models/settings-extensions/oci-defaults",
"bottlerocket-settings-models/settings-extensions/oci-hooks",
"bottlerocket-settings-models/settings-extensions/pki",
"bottlerocket-settings-models/settings-extensions/updates",

# Settings Extension SDK
# Currently unused in Bottlerocket
"bottlerocket-settings-sdk",
"bottlerocket-template-helper",
]
18 changes: 18 additions & 0 deletions bottlerocket-settings-models/model-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "bottlerocket-model-derive"
version = "0.1.0"
authors = ["Tom Kirchner <tjk@amazon.com>"]
license = "Apache-2.0 OR MIT"
edition = "2021"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[lib]
path = "src/lib.rs"
proc-macro = true

[dependencies]
darling = "0.20"
quote = "1"
syn = { version = "2", default-features = false, features = ["full", "parsing", "printing", "proc-macro", "visit-mut"] }
44 changes: 44 additions & 0 deletions bottlerocket-settings-models/model-derive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# model-derive

Current version: 0.1.0

## Overview

This module provides a attribute-style procedural macro, `model`, that makes sure a struct is
ready to be used as an API model.

The goal is to reduce cognitive overhead when reading models.
We do this by automatically specifying required attributes on structs and fields.

Several arguments are available to override default behavior; see below.

## Changes it makes

### Visibility

All types must be public, so `pub` is added.
Override this (at a per-struct or per-field level) by specifying your own visibility.

### Derives

All structs must serde-`Serializable` and -`Deserializable`, and comparable via `PartialEq`.
`Debug` is added for convenience.
`Default` can also be added by specifying the argument `impl_default = true`.

### Serde

Structs have a `#[serde(...)]` attribute added to deny unknown fields and rename fields to kebab-case.
The struct can be renamed (for ser/de purposes) by specifying the argument `rename = "bla"`.

Fields have a `#[serde(...)]` attribute added to skip `Option` fields that are `None`.
This is because we accept updates in the API that are structured the same way as the model, but we don't want to require users to specify fields they aren't changing.
This can be disabled by specifying the argument `add_option = false`.

### Option

Fields are all wrapped in `Option<...>`.
Similar to the `serde` attribute added to fields, this is because we don't want users to have to specify fields they aren't changing, and can be disabled the same way, by specifying `add_option = false`.

## Colophon

This text was generated from `README.tpl` using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/lib.rs`.
175 changes: 175 additions & 0 deletions bottlerocket-settings-models/model-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*!
# Overview

This module provides a attribute-style procedural macro, `model`, that makes sure a struct is
ready to be used as an API model.

The goal is to reduce cognitive overhead when reading models.
We do this by automatically specifying required attributes on structs and fields.

Several arguments are available to override default behavior; see below.

# Changes it makes

## Visibility

All types must be public, so `pub` is added.
Override this (at a per-struct or per-field level) by specifying your own visibility.

## Derives

All structs must serde-`Serializable` and -`Deserializable`, and comparable via `PartialEq`.
`Debug` is added for convenience.
`Default` can also be added by specifying the argument `impl_default = true`.

## Serde

Structs have a `#[serde(...)]` attribute added to deny unknown fields and rename fields to kebab-case.
The struct can be renamed (for ser/de purposes) by specifying the argument `rename = "bla"`.

Fields have a `#[serde(...)]` attribute added to skip `Option` fields that are `None`.
This is because we accept updates in the API that are structured the same way as the model, but we don't want to require users to specify fields they aren't changing.
This can be disabled by specifying the argument `add_option = false`.

## Option

Fields are all wrapped in `Option<...>`.
Similar to the `serde` attribute added to fields, this is because we don't want users to have to specify fields they aren't changing, and can be disabled the same way, by specifying `add_option = false`.
*/

extern crate proc_macro;

use darling::{ast::NestedMeta, FromMeta};
use proc_macro::TokenStream;
use quote::ToTokens;
use syn::visit_mut::{self, VisitMut};
use syn::{parse_quote, Attribute, Field, ItemStruct, Visibility};

/// Define a `#[model]` attribute that can be placed on structs to be used in an API model.
/// Model requirements are automatically applied to the struct and its fields.
/// (The attribute must be placed on sub-structs; it can't be recursively applied to structs
/// referenced in the given struct.)
#[proc_macro_attribute]
pub fn model(args: TokenStream, input: TokenStream) -> TokenStream {
// Parse args
let args: ParsedArgs = ParsedArgs::from_list(
&NestedMeta::parse_meta_list(args.into())
.expect("Unable to parse arguments to `model` macro"),
)
.expect("Unable to parse arguments to `model` macro");
let mut helper = ModelHelper::from(args);

// Parse and modify source
let mut ast: ItemStruct =
syn::parse(input).expect("Unable to parse item `model` was placed on - is it a struct?");
helper.visit_item_struct_mut(&mut ast);
ast.into_token_stream().into()
}

/// Store any args given by the user inside `#[model(...)]`.
#[derive(Debug, Default, FromMeta)]
#[darling(default)]
struct ParsedArgs {
rename: Option<String>,
impl_default: Option<bool>,
add_option: Option<bool>,
}

/// Stores the user's requested options, plus any defaults for unspecified options.
#[derive(Debug)]
struct ModelHelper {
rename: Option<String>,
impl_default: bool,
add_option: bool,
}

/// Takes the user's requested options and sets default values for anything unspecified.
impl From<ParsedArgs> for ModelHelper {
fn from(args: ParsedArgs) -> Self {
// Add any default values
ModelHelper {
rename: args.rename,
impl_default: args.impl_default.unwrap_or(false),
add_option: args.add_option.unwrap_or(true),
}
}
}

/// VisitMut helps us modify the node types we want without digging through the huge token trees
/// need to represent them.
impl VisitMut for ModelHelper {
// Visit struct definitions.
fn visit_item_struct_mut(&mut self, node: &mut ItemStruct) {
if let Visibility::Inherited = node.vis {
node.vis = parse_quote!(pub)
}

// Add our serde attribute, if the user hasn't set one
if !is_attr_set("serde", &node.attrs) {
// Rename the struct, if the user requested
let attr = if let Some(ref rename_to) = self.rename {
parse_quote!(
#[serde(deny_unknown_fields, rename_all = "kebab-case", rename = #rename_to)]
)
} else {
parse_quote!(
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
)
};
node.attrs.push(attr);
}

// Add our derives, if the user hasn't set any
if !is_attr_set("derive", &node.attrs) {
// Derive Default, if the user requested
let attr = if self.impl_default {
parse_quote!(#[derive(Clone, Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)])
} else {
parse_quote!(#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)])
};
// Rust 1.52 added a legacy_derive_helpers warning (soon to be an error) that yells if
// you use an attribute macro before the derive macro that introduces it. We should
// always put derive macros at the start of the list to avoid this.
node.attrs.insert(0, attr);
}

// Let the default implementation do its thing, recursively.
visit_mut::visit_item_struct_mut(self, node);
}

// Visit field definitions in structs.
fn visit_field_mut(&mut self, node: &mut Field) {
if let Visibility::Inherited = node.vis {
node.vis = parse_quote!(pub)
}

// Add our serde attribute, if the user hasn't set one
if self.add_option {
if !is_attr_set("serde", &node.attrs) {
node.attrs.push(parse_quote!(
#[serde(skip_serializing_if = "Option::is_none")]
));
}

// Wrap each field's type in `Option<...>`
let ty = &node.ty;
node.ty = parse_quote!(Option<#ty>);
}

// Let the default implementation do its thing, recursively.
visit_mut::visit_field_mut(self, node);
}
}

/// Checks whether an attribute named `attr_name` (e.g. "serde") is set in the given list of
/// `syn::Attribute`s.
fn is_attr_set(attr_name: &'static str, attrs: &[Attribute]) -> bool {
for attr in attrs {
if let Some(name) = attr.path().get_ident() {
if name == attr_name {
return true;
}
}
}
false
}
25 changes: 25 additions & 0 deletions bottlerocket-settings-models/modeled-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "bottlerocket-modeled-types"
version = "0.1.0"
authors = []
license = "Apache-2.0 OR MIT"
edition = "2021"
publish = false
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[dependencies]
base64 = "0.21"
indexmap = { version = "2", features = ["serde"] }
lazy_static = "1"
regex = "1"
bottlerocket-scalar = { path = "../scalar", version = "0.1" }
bottlerocket-scalar-derive = { path = "../scalar-derive", version = "0.1" }
semver = "1"
serde = "1"
serde_json = "1"
serde_plain = "1"
snafu = "0.8"
bottlerocket-string-impls-for = { path = "../string-impls-for", version = "0.1" }
url = "2"
x509-parser = "0.16"
11 changes: 11 additions & 0 deletions bottlerocket-settings-models/modeled-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# modeled-types

Current version: 0.1.0

This module contains data types that can be used in the model when special input/output
(ser/de) behavior is desired. For example, the ValidBase64 type can be used for a model field
when we don't even want to accept an API call with invalid base64 data.

## Colophon

This text was generated from `README.tpl` using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/lib.rs`.
Loading