Skip to content

Commit 29877db

Browse files
tas50claude
andauthored
✨ Add ZFS resources to OS provider (#6784)
Add zfs, zfs.pool, and zfs.dataset resources for querying ZFS storage pools and datasets (filesystems, volumes, snapshots, bookmarks). Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 540cb1b commit 29877db

File tree

8 files changed

+2183
-16
lines changed

8 files changed

+2183
-16
lines changed

.github/actions/spelling/expect.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ aad
22
ACCOUNTADMIN
33
ACTIVEMQ
44
advancedthreatprotection
5+
artifactregistry
56
alloydb
67
alpn
78
antispam
89
appslot
910
arp
10-
artifactregistry
1111
atlassian
1212
auditlog
1313
Auths
1414
autoaccept
1515
autoclose
16+
autoexpand
17+
autoreplace
18+
autotrim
1619
autoprovision
1720
Autoscalers
1821
awsapps
@@ -24,20 +27,20 @@ backupshorttermretentionpolicy
2427
bigquery
2528
bigtable
2629
blackhole
27-
Blobstore
2830
BYOS
2931
bytematchstatement
3032
cavium
3133
cdn
3234
certificatechains
3335
ciscocatalyst
3436
clcerts
37+
cname
3538
cloudflare
3639
Clusterwide
3740
cmek
3841
cmnd
39-
cname
4042
cooldown
43+
compressratio
4144
copywrite
4245
cpe
4346
cryptokey
@@ -50,15 +53,16 @@ datapath
5053
DATAUSER
5154
datetime
5255
ddos
56+
dedupratio
5357
deliverychannel
5458
dfw
5559
directoryservice
60+
documentdb
61+
draid
5662
dlp
5763
dlq
5864
dlv
5965
dnskey
60-
documentdb
61-
Doublings
6266
dsse
6367
eas
6468
Ecmp
@@ -68,17 +72,16 @@ ekus
6872
elbv
6973
endpointslice
7074
EPP
71-
ETL
7275
exo
7376
failback
7477
fargate
7578
filestore
7679
filesz
7780
firefox
7881
firestore
82+
fortios
7983
FLEXGROUP
8084
FLEXVOL
81-
fortios
8285
frontmatter
8386
ftps
8487
fumadocs
@@ -111,9 +114,8 @@ ipsetforwardedipconfig
111114
ipsetreferencestatement
112115
istio
113116
jira
114-
jsonbody
115117
junos
116-
KFP
118+
jsonbody
117119
kqueue
118120
KSK
119121
labelmatchstatement
@@ -129,17 +131,17 @@ managedzone
129131
maxmemory
130132
mcp
131133
mcr
132-
meid
133134
memorydb
135+
meid
134136
messagestoragepolicy
135137
mfs
136138
mgroup
137139
minfree
138140
MINIMALUSER
139141
mkey
140-
Mpim
141-
msk
142142
MULTIAZ
143+
msk
144+
Mpim
143145
naflags
144146
natgateway
145147
networkfirewall
@@ -182,9 +184,9 @@ psc
182184
PTn
183185
pushconfig
184186
Pzi
185-
Pzs
186187
pzs
187188
querypack
189+
raidz
188190
RABBITMQ
189191
ratebasedstatement
190192
recaptcha
@@ -199,7 +201,6 @@ rulegroup
199201
rulegroupreferencestatement
200202
saas
201203
Sas
202-
SASL
203204
sbom
204205
scim
205206
scm
@@ -233,13 +234,16 @@ toplevel
233234
tpu
234235
transitgateway
235236
udid
237+
UNAVAIL
236238
uefi
237239
Uocm
238240
usb
239241
Utc
240242
valkey
241243
VAULTNAME
242244
vdcs
245+
vdev
246+
vdevs
243247
VGeneration
244248
virtualmachine
245249
vlans
@@ -256,5 +260,7 @@ WORKSPACESUSER
256260
workspacesweb
257261
xssmatchstatement
258262
yara
263+
zfs
264+
zpool
259265
zrt
260-
ZSTD
266+
zstd

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ for {
431431
- `topicArn string``topic() aws.sns.topic`
432432
- `streamArn string``stream() aws.kinesis.stream`
433433
These enable MQL traversal (e.g., `aws.rds.proxy.vpc.cidrBlock`) instead of requiring manual lookups. Store the raw ID/ARN in a `cache*` field on the Internal struct, then implement the typed method using `NewResource`.
434-
- Every resource and field has an explicit entry in `.lr.versions`. When a new field is added to an `.lr` file that isn't yet tracked, the `versions` command automatically assigns it the next patch version (current provider version + 1 patch). Existing entries are never overwritten.
434+
- Every resource and field has an explicit entry in `.lr.versions`. New entries must use the **next patch version** after the provider's current version (e.g., if the provider is at `13.1.1`, new fields should be `13.1.2`). Check the provider's current version before adding entries. The `versions` command does this automatically, but verify the result. Existing entries are never overwritten.
435435
- **Match SDK types faithfully:** If an SDK field is `*bool`, use `bool` in `.lr` and `llx.BoolDataPtr()` in Go — don't cast it to `string`. If an SDK enum has only two states (Enabled/Disabled), prefer `bool`. Use `*type` intermediate variables with `llx.*DataPtr` helpers to preserve nil semantics.
436436
- **Consistency with existing fields:** Before adding new fields to a resource, check how its existing fields handle pointers, nil checks, and type conversions. Follow the same pattern.
437437
- **Verify enum values in `.lr` comments:** When listing possible values in field comments, check the SDK/API docs for completeness — don't assume the set is closed.

providers/os/resources/os.lr

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,3 +2645,111 @@ private mdadm.device @defaults("name state") {
26452645
// Device state (e.g., active sync, spare, faulty)
26462646
state string
26472647
}
2648+
2649+
// ZFS storage pool and dataset management
2650+
zfs @defaults("pools") {
2651+
// ZFS version string
2652+
version() string
2653+
// ZFS storage pools
2654+
pools() []zfs.pool
2655+
// All ZFS datasets (filesystems, volumes, snapshots, bookmarks)
2656+
datasets() []zfs.dataset
2657+
}
2658+
2659+
// ZFS storage pool
2660+
zfs.pool @defaults("name health sizeBytes") {
2661+
init(name string)
2662+
// Pool name
2663+
name string
2664+
// Pool GUID
2665+
guid string
2666+
// Health status (ONLINE, DEGRADED, FAULTED, OFFLINE, REMOVED, UNAVAIL)
2667+
health string
2668+
// Total size in bytes
2669+
sizeBytes int
2670+
// Allocated space in bytes
2671+
allocatedBytes int
2672+
// Free space in bytes
2673+
freeBytes int
2674+
// Fragmentation percentage
2675+
fragmentation int
2676+
// Percentage of pool space used (0-100)
2677+
percentUsed int
2678+
// Deduplication ratio
2679+
dedupratio float
2680+
// Whether the pool is read-only
2681+
readonly bool
2682+
// Whether auto-expand is enabled
2683+
autoexpand bool
2684+
// Whether auto-replace is enabled
2685+
autoreplace bool
2686+
// Whether auto-trim is enabled
2687+
autotrim bool
2688+
// Top-level virtual device groups (mirrors, raidz, etc.)
2689+
vdevs() []zfs.pool.vdev
2690+
// All pool properties (lazy-loaded via zpool get all)
2691+
properties() map[string]string
2692+
}
2693+
2694+
// ZFS virtual device (vdev) in a pool's topology
2695+
zfs.pool.vdev @defaults("name type state numDevices") {
2696+
// Vdev name (e.g., "raidz2-0", "mirror-0", "sda")
2697+
name string
2698+
// Vdev type (mirror, raidz, raidz2, raidz3, disk, file, draid, etc.)
2699+
type string
2700+
// Vdev state (ONLINE, DEGRADED, FAULTED, OFFLINE, REMOVED, UNAVAIL)
2701+
state string
2702+
// Device path (for leaf vdevs, empty for groups)
2703+
path string
2704+
// Read error count
2705+
readErrors int
2706+
// Write error count
2707+
writeErrors int
2708+
// Checksum error count
2709+
checksumErrors int
2710+
// Slow I/O count
2711+
slowIos int
2712+
// Number of child devices
2713+
numDevices int
2714+
// Child vdevs/devices
2715+
devices []zfs.pool.vdev
2716+
}
2717+
2718+
// ZFS dataset (filesystem, volume, snapshot, or bookmark)
2719+
zfs.dataset @defaults("name type usedBytes") {
2720+
init(name string)
2721+
// Full dataset name (pool/path or pool/path@snap)
2722+
name string
2723+
// Dataset type (filesystem, volume, snapshot, bookmark)
2724+
type string
2725+
// Used space in bytes
2726+
usedBytes int
2727+
// Available space in bytes
2728+
availableBytes int
2729+
// Referenced space in bytes
2730+
referencedBytes int
2731+
// Mount point (empty for volumes/snapshots)
2732+
mountpoint string
2733+
// Compression algorithm (off, lz4, gzip, zstd, etc.)
2734+
compression string
2735+
// Compression ratio
2736+
compressratio float
2737+
// Whether the dataset is currently mounted
2738+
mounted bool
2739+
// Record size in bytes
2740+
recordsizeBytes int
2741+
// Quota in bytes (0 = none)
2742+
quotaBytes int
2743+
// Reservation in bytes (0 = none)
2744+
reservationBytes int
2745+
// Origin snapshot (for clones, empty otherwise)
2746+
origin string
2747+
// Creation time
2748+
creation time
2749+
// Encryption algorithm (off, aes-256-gcm, etc.)
2750+
encryption string
2751+
// All dataset properties (lazy-loaded via zfs get all)
2752+
properties() map[string]string
2753+
// Snapshots of this dataset
2754+
snapshots() []zfs.dataset
2755+
}

0 commit comments

Comments
 (0)