diff --git a/Makefile b/Makefile index d4169565..5dce6b17 100644 --- a/Makefile +++ b/Makefile @@ -80,12 +80,15 @@ FORCE: # build targets # -build-proto: check-protoc install-ttrpc-plugin install-wasm-plugin install-protoc-dependencies build-protoc-gen-strip +build-proto: check-protoc install-ttrpc-plugin install-wasm-plugin install-protoc-dependencies build-protoc-gen-strip build-protoc-gen-owners for src in $(PROTO_SOURCES); do \ $(PROTO_COMPILE) \ --plugin=protoc-gen-strip=$(abspath $(BIN_PATH)/protoc-gen-strip) \ --strip_out=pkg/api \ --strip_opt=file=strip.go \ + --plugin=protoc-gen-owners=$(abspath $(BIN_PATH)/protoc-gen-owners) \ + --owners_out=pkg/api \ + --owners_opt=file=owners_generated.go \ $$src; \ done sed -i '1s;^;//go:build !wasip1\n\n;' pkg/api/api_ttrpc.pb.go @@ -120,6 +123,11 @@ clean-cache: # plugins build targets # +.PHONY: build-protoc-gen-owners +build-protoc-gen-owners: + $(Q)echo "Building build/bin/protoc-gen-owners..."; \ + $(GO_BUILD) -C tools/protoc-gen-owners -o $(abspath $(BIN_PATH)/protoc-gen-owners) $(GO_BUILD_FLAGS) . + .PHONY: build-protoc-gen-strip build-protoc-gen-strip: $(Q)echo "Building build/bin/protoc-gen-strip..."; \ diff --git a/pkg/api/owners.go b/pkg/api/owners.go index 86e305e2..fa12476c 100644 --- a/pkg/api/owners.go +++ b/pkg/api/owners.go @@ -16,7 +16,7 @@ // TODO: Add comments to exported methods and functions. // -//nolint:revive // exported symbols should have comments +//nolint:revive // exported symbols should have comment package api import ( @@ -40,348 +40,24 @@ func NewOwningPlugins() *OwningPlugins { } } -func (o *OwningPlugins) ClaimAnnotation(id, key, plugin string) error { - return o.mustOwnersFor(id).ClaimAnnotation(key, plugin) -} - -func (o *OwningPlugins) ClaimMount(id, destination, plugin string) error { - return o.mustOwnersFor(id).ClaimMount(destination, plugin) -} +// Note: ClaimHooks, HooksOwner, ClearHooks, and ClearRdt are handwritten +// functions as they did not match the pattern used to generate the rest of the +// functions. func (o *OwningPlugins) ClaimHooks(id, plugin string) error { return o.mustOwnersFor(id).ClaimHooks(plugin) } -func (o *OwningPlugins) ClaimDevice(id, path, plugin string) error { - return o.mustOwnersFor(id).ClaimDevice(path, plugin) -} - -func (o *OwningPlugins) ClaimNamespace(id, typ, plugin string) error { - return o.mustOwnersFor(id).ClaimNamespace(typ, plugin) -} - -func (o *OwningPlugins) ClaimCdiDevice(id, name, plugin string) error { - return o.mustOwnersFor(id).ClaimCdiDevice(name, plugin) -} - -func (o *OwningPlugins) ClaimEnv(id, name, plugin string) error { - return o.mustOwnersFor(id).ClaimEnv(name, plugin) -} - -func (o *OwningPlugins) ClaimArgs(id, plugin string) error { - return o.mustOwnersFor(id).ClaimArgs(plugin) -} - -func (o *OwningPlugins) ClaimMemLimit(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemLimit(plugin) -} - -func (o *OwningPlugins) ClaimMemReservation(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemReservation(plugin) -} - -func (o *OwningPlugins) ClaimMemSwapLimit(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemSwapLimit(plugin) -} - -func (o *OwningPlugins) ClaimMemKernelLimit(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemKernelLimit(plugin) -} - -func (o *OwningPlugins) ClaimMemTCPLimit(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemTCPLimit(plugin) -} - -func (o *OwningPlugins) ClaimMemSwappiness(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemSwappiness(plugin) -} - -func (o *OwningPlugins) ClaimMemDisableOomKiller(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemDisableOomKiller(plugin) -} - -func (o *OwningPlugins) ClaimMemUseHierarchy(id, plugin string) error { - return o.mustOwnersFor(id).ClaimMemUseHierarchy(plugin) -} - -func (o *OwningPlugins) ClaimCPUShares(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPUShares(plugin) -} - -func (o *OwningPlugins) ClaimCPUQuota(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPUQuota(plugin) -} - -func (o *OwningPlugins) ClaimCPUPeriod(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPUPeriod(plugin) -} - -func (o *OwningPlugins) ClaimCPURealtimeRuntime(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPURealtimeRuntime(plugin) -} - -func (o *OwningPlugins) ClaimCPURealtimePeriod(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPURealtimePeriod(plugin) -} - -func (o *OwningPlugins) ClaimCPUSetCPUs(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPUSetCPUs(plugin) -} - -func (o *OwningPlugins) ClaimCPUSetMems(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCPUSetMems(plugin) -} - -func (o *OwningPlugins) ClaimPidsLimit(id, plugin string) error { - return o.mustOwnersFor(id).ClaimPidsLimit(plugin) -} - -func (o *OwningPlugins) ClaimHugepageLimit(id, size, plugin string) error { - return o.mustOwnersFor(id).ClaimHugepageLimit(size, plugin) -} - -func (o *OwningPlugins) ClaimBlockioClass(id, plugin string) error { - return o.mustOwnersFor(id).ClaimBlockioClass(plugin) -} - -func (o *OwningPlugins) ClaimRdtClass(id, plugin string) error { - return o.mustOwnersFor(id).ClaimRdtClass(plugin) -} - -func (o *OwningPlugins) ClaimRdtClosID(id, plugin string) error { - return o.mustOwnersFor(id).ClaimRdtClosID(plugin) -} - -func (o *OwningPlugins) ClaimRdtSchemata(id, plugin string) error { - return o.mustOwnersFor(id).ClaimRdtSchemata(plugin) -} - -func (o *OwningPlugins) ClaimRdtEnableMonitoring(id, plugin string) error { - return o.mustOwnersFor(id).ClaimRdtEnableMonitoring(plugin) -} - -func (o *OwningPlugins) ClaimCgroupsUnified(id, key, plugin string) error { - return o.mustOwnersFor(id).ClaimCgroupsUnified(key, plugin) -} - -func (o *OwningPlugins) ClaimCgroupsPath(id, plugin string) error { - return o.mustOwnersFor(id).ClaimCgroupsPath(plugin) -} - -func (o *OwningPlugins) ClaimOomScoreAdj(id, plugin string) error { - return o.mustOwnersFor(id).ClaimOomScoreAdj(plugin) -} - -func (o *OwningPlugins) ClaimLinuxScheduler(id, plugin string) error { - return o.mustOwnersFor(id).ClaimLinuxScheduler(plugin) -} - -func (o *OwningPlugins) ClaimRlimit(id, typ, plugin string) error { - return o.mustOwnersFor(id).ClaimRlimit(typ, plugin) -} - -func (o *OwningPlugins) ClaimIOPriority(id, plugin string) error { - return o.mustOwnersFor(id).ClaimIOPriority(plugin) -} - -func (o *OwningPlugins) ClaimSeccompPolicy(id, plugin string) error { - return o.mustOwnersFor(id).ClaimSeccompPolicy(plugin) -} - -func (o *OwningPlugins) ClaimSysctl(id, key, plugin string) error { - return o.mustOwnersFor(id).ClaimSysctl(key, plugin) -} - -func (o *OwningPlugins) ClaimLinuxNetDevice(id, path, plugin string) error { - return o.mustOwnersFor(id).ClaimLinuxNetDevice(path, plugin) -} - -func (o *OwningPlugins) ClearAnnotation(id, key, plugin string) { - o.mustOwnersFor(id).ClearAnnotation(key, plugin) -} - -func (o *OwningPlugins) ClearMount(id, key, plugin string) { - o.mustOwnersFor(id).ClearMount(key, plugin) -} - -func (o *OwningPlugins) ClearDevice(id, key, plugin string) { - o.mustOwnersFor(id).ClearDevice(key, plugin) -} - -func (o *OwningPlugins) ClearEnv(id, key, plugin string) { - o.mustOwnersFor(id).ClearEnv(key, plugin) -} - -func (o *OwningPlugins) ClearArgs(id, plugin string) { - o.mustOwnersFor(id).ClearArgs(plugin) -} - -func (o *OwningPlugins) ClearSysctl(id, key, plugin string) { - o.mustOwnersFor(id).ClearSysctl(key, plugin) -} - -func (o *OwningPlugins) ClearLinuxNetDevice(id, path, plugin string) { - o.mustOwnersFor(id).ClearLinuxNetDevice(path, plugin) -} - -func (o *OwningPlugins) ClearRdt(id, plugin string) { - o.mustOwnersFor(id).ClearRdt(plugin) -} - -func (o *OwningPlugins) AnnotationOwner(id, key string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Annotations.Key(), key) -} - -func (o *OwningPlugins) MountOwner(id, destination string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Mounts.Key(), destination) -} - func (o *OwningPlugins) HooksOwner(id string) (string, bool) { return o.ownersFor(id).simpleOwner(Field_OciHooks.Key()) } -func (o *OwningPlugins) DeviceOwner(id, path string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Devices.Key(), path) -} - -func (o *OwningPlugins) NamespaceOwner(id, path string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Namespace.Key(), path) -} - -func (o *OwningPlugins) NamespaceOwners(id string) (map[string]string, bool) { - return o.ownersFor(id).compoundOwnerMap(Field_Namespace.Key()) -} - -func (o *OwningPlugins) EnvOwner(id, name string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Env.Key(), name) -} - -func (o *OwningPlugins) ArgsOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_Args.Key()) -} - -func (o *OwningPlugins) MemLimitOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemLimit.Key()) -} - -func (o *OwningPlugins) MemReservationOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemReservation.Key()) -} - -func (o *OwningPlugins) MemSwapLimitOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemSwapLimit.Key()) -} - -func (o *OwningPlugins) MemKernelLimitOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemKernelLimit.Key()) -} - -func (o *OwningPlugins) MemTCPLimitOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemTCPLimit.Key()) -} - -func (o *OwningPlugins) MemSwappinessOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemSwappiness.Key()) -} - -func (o *OwningPlugins) MemDisableOomKillerOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemDisableOomKiller.Key()) -} - -func (o *OwningPlugins) MemUseHierarchyOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_MemUseHierarchy.Key()) -} - -func (o *OwningPlugins) CPUSharesOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPUShares.Key()) -} - -func (o *OwningPlugins) CPUQuotaOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPUQuota.Key()) -} - -func (o *OwningPlugins) CPUPeriodOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPUPeriod.Key()) -} - -func (o *OwningPlugins) CPURealtimeRuntimeOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPURealtimeRuntime.Key()) -} - -func (o *OwningPlugins) CPURealtimePeriodOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPURealtimePeriod.Key()) -} - -func (o *OwningPlugins) CPUSetCPUsOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPUSetCPUs.Key()) -} - -func (o *OwningPlugins) CPUSetMemsOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CPUSetMems.Key()) -} - -func (o *OwningPlugins) PidsLimitOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_PidsLimit.Key()) -} - -func (o *OwningPlugins) HugepageLimitOwner(id, size string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_HugepageLimits.Key(), size) -} - -func (o *OwningPlugins) BlockioClassOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_BlockioClass.Key()) -} - -func (o *OwningPlugins) RdtClassOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_RdtClass.Key()) -} - -func (o *OwningPlugins) RdtClosIDOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_RdtClosID.Key()) -} - -func (o *OwningPlugins) RdtSchemataOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_RdtSchemata.Key()) -} - -func (o *OwningPlugins) RdtEnableMonitoringOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_RdtEnableMonitoring.Key()) -} - -func (o *OwningPlugins) CgroupsUnifiedOwner(id, key string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_CgroupsUnified.Key(), key) -} - -func (o *OwningPlugins) CgroupsPathOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_CgroupsPath.Key()) -} - -func (o *OwningPlugins) OomScoreAdjOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_OomScoreAdj.Key()) -} - -func (o *OwningPlugins) LinuxScheduler(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_LinuxSched.Key()) +func (o *OwningPlugins) ClearHooks(id, plugin string) { + o.mustOwnersFor(id).ClearHooks(plugin) } -func (o *OwningPlugins) RlimitOwner(id, typ string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Rlimits.Key(), typ) -} - -func (o *OwningPlugins) IOPriorityOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_IoPriority.Key()) -} - -func (o *OwningPlugins) SeccompPolicyOwner(id string) (string, bool) { - return o.ownersFor(id).simpleOwner(Field_SeccompPolicy.Key()) -} - -func (o *OwningPlugins) SysctlOwner(id, key string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_Sysctl.Key(), key) -} - -func (o *OwningPlugins) LinuxNetDeviceOwner(id, path string) (string, bool) { - return o.ownersFor(id).compoundOwner(Field_LinuxNetDevices.Key(), path) +func (o *OwningPlugins) ClearRdt(id, plugin string) { + o.mustOwnersFor(id).ClearRdt(plugin) } func (o *OwningPlugins) mustOwnersFor(id string) *FieldOwners { @@ -466,161 +142,17 @@ func (f *FieldOwners) claimSimple(field int32, plugin string) error { return nil } -func (f *FieldOwners) ClaimAnnotation(key, plugin string) error { - return f.claimCompound(Field_Annotations.Key(), key, plugin) -} - -func (f *FieldOwners) ClaimMount(destination, plugin string) error { - return f.claimCompound(Field_Mounts.Key(), destination, plugin) -} - func (f *FieldOwners) ClaimHooks(plugin string) error { f.accumulateSimple(Field_OciHooks.Key(), plugin) return nil } -func (f *FieldOwners) ClaimDevice(path, plugin string) error { - return f.claimCompound(Field_Devices.Key(), path, plugin) -} - -func (f *FieldOwners) ClaimCdiDevice(name, plugin string) error { - return f.claimCompound(Field_CdiDevices.Key(), name, plugin) -} - -func (f *FieldOwners) ClaimNamespace(typ, plugin string) error { - return f.claimCompound(Field_Namespace.Key(), typ, plugin) -} - -func (f *FieldOwners) ClaimEnv(name, plugin string) error { - return f.claimCompound(Field_Env.Key(), name, plugin) -} - -func (f *FieldOwners) ClaimArgs(plugin string) error { - return f.claimSimple(Field_Args.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemLimit(plugin string) error { - return f.claimSimple(Field_MemLimit.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemReservation(plugin string) error { - return f.claimSimple(Field_MemReservation.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemSwapLimit(plugin string) error { - return f.claimSimple(Field_MemSwapLimit.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemKernelLimit(plugin string) error { - return f.claimSimple(Field_MemKernelLimit.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemTCPLimit(plugin string) error { - return f.claimSimple(Field_MemTCPLimit.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemSwappiness(plugin string) error { - return f.claimSimple(Field_MemSwappiness.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemDisableOomKiller(plugin string) error { - return f.claimSimple(Field_MemDisableOomKiller.Key(), plugin) -} - -func (f *FieldOwners) ClaimMemUseHierarchy(plugin string) error { - return f.claimSimple(Field_MemUseHierarchy.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPUShares(plugin string) error { - return f.claimSimple(Field_CPUShares.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPUQuota(plugin string) error { - return f.claimSimple(Field_CPUQuota.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPUPeriod(plugin string) error { - return f.claimSimple(Field_CPUPeriod.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPURealtimeRuntime(plugin string) error { - return f.claimSimple(Field_CPURealtimeRuntime.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPURealtimePeriod(plugin string) error { - return f.claimSimple(Field_CPURealtimePeriod.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPUSetCPUs(plugin string) error { - return f.claimSimple(Field_CPUSetCPUs.Key(), plugin) -} - -func (f *FieldOwners) ClaimCPUSetMems(plugin string) error { - return f.claimSimple(Field_CPUSetMems.Key(), plugin) -} - -func (f *FieldOwners) ClaimPidsLimit(plugin string) error { - return f.claimSimple(Field_PidsLimit.Key(), plugin) -} - -func (f *FieldOwners) ClaimHugepageLimit(size, plugin string) error { - return f.claimCompound(Field_HugepageLimits.Key(), size, plugin) -} - -func (f *FieldOwners) ClaimBlockioClass(plugin string) error { - return f.claimSimple(Field_BlockioClass.Key(), plugin) -} - -func (f *FieldOwners) ClaimRdtClass(plugin string) error { - return f.claimSimple(Field_RdtClass.Key(), plugin) -} - -func (f *FieldOwners) ClaimRdtClosID(plugin string) error { - return f.claimSimple(Field_RdtClosID.Key(), plugin) -} - -func (f *FieldOwners) ClaimRdtSchemata(plugin string) error { - return f.claimSimple(Field_RdtSchemata.Key(), plugin) -} - -func (f *FieldOwners) ClaimRdtEnableMonitoring(plugin string) error { - return f.claimSimple(Field_RdtEnableMonitoring.Key(), plugin) -} - -func (f *FieldOwners) ClaimCgroupsUnified(key, plugin string) error { - return f.claimCompound(Field_CgroupsUnified.Key(), key, plugin) -} - -func (f *FieldOwners) ClaimCgroupsPath(plugin string) error { - return f.claimSimple(Field_CgroupsPath.Key(), plugin) -} - -func (f *FieldOwners) ClaimOomScoreAdj(plugin string) error { - return f.claimSimple(Field_OomScoreAdj.Key(), plugin) -} - -func (f *FieldOwners) ClaimLinuxScheduler(plugin string) error { - return f.claimSimple(Field_LinuxSched.Key(), plugin) -} - -func (f *FieldOwners) ClaimRlimit(typ, plugin string) error { - return f.claimCompound(Field_Rlimits.Key(), typ, plugin) -} - -func (f *FieldOwners) ClaimIOPriority(plugin string) error { - return f.claimSimple(Field_IoPriority.Key(), plugin) -} - -func (f *FieldOwners) ClaimSeccompPolicy(plugin string) error { - return f.claimSimple(Field_SeccompPolicy.Key(), plugin) +func (f *FieldOwners) HooksOwner() (string, bool) { + return f.simpleOwner(Field_OciHooks.Key()) } -func (f *FieldOwners) ClaimSysctl(key, plugin string) error { - return f.claimCompound(Field_Sysctl.Key(), key, plugin) -} - -func (f *FieldOwners) ClaimLinuxNetDevice(path, plugin string) error { - return f.claimCompound(Field_LinuxNetDevices.Key(), path, plugin) +func (f *FieldOwners) ClearHooks(plugin string) { + f.clearSimple(Field_OciHooks.Key(), plugin) } func (f *FieldOwners) clearCompound(field int32, key, plugin string) { @@ -629,7 +161,6 @@ func (f *FieldOwners) clearCompound(field int32, key, plugin string) { m = NewCompoundFieldOwners() f.Compound[field] = m } - m.Owners[key] = MarkForRemoval(plugin) } @@ -637,38 +168,10 @@ func (f *FieldOwners) clearSimple(field int32, plugin string) { f.Simple[field] = MarkForRemoval(plugin) } -func (f *FieldOwners) ClearAnnotation(key, plugin string) { - f.clearCompound(Field_Annotations.Key(), key, plugin) -} - -func (f *FieldOwners) ClearMount(destination, plugin string) { - f.clearCompound(Field_Mounts.Key(), destination, plugin) -} - -func (f *FieldOwners) ClearDevice(path, plugin string) { - f.clearCompound(Field_Devices.Key(), path, plugin) -} - -func (f *FieldOwners) ClearEnv(name, plugin string) { - f.clearCompound(Field_Env.Key(), name, plugin) -} - -func (f *FieldOwners) ClearArgs(plugin string) { - f.clearSimple(Field_Args.Key(), plugin) -} - -func (f *FieldOwners) ClearSysctl(key, plugin string) { - f.clearCompound(Field_Sysctl.Key(), key, plugin) -} - -func (f *FieldOwners) ClearLinuxNetDevice(key, plugin string) { - f.clearCompound(Field_LinuxNetDevices.Key(), key, plugin) -} - func (f *FieldOwners) ClearRdt(plugin string) { - f.clearSimple(Field_RdtClosID.Key(), plugin) - f.clearSimple(Field_RdtSchemata.Key(), plugin) - f.clearSimple(Field_RdtEnableMonitoring.Key(), plugin) + f.clearSimple(int32(Field_RdtClosID), plugin) + f.clearSimple(int32(Field_RdtSchemata), plugin) + f.clearSimple(int32(Field_RdtEnableMonitoring), plugin) } func (f *FieldOwners) accumulateSimple(field int32, plugin string) { @@ -720,128 +223,8 @@ func (f *FieldOwners) simpleOwner(field int32) (string, bool) { return plugin, ok } -func (f *FieldOwners) AnnotationOwner(key string) (string, bool) { - return f.compoundOwner(Field_Annotations.Key(), key) -} - -func (f *FieldOwners) MountOwner(destination string) (string, bool) { - return f.compoundOwner(Field_Mounts.Key(), destination) -} - -func (f *FieldOwners) DeviceOwner(path string) (string, bool) { - return f.compoundOwner(Field_Devices.Key(), path) -} - -func (f *FieldOwners) NamespaceOwner(typ string) (string, bool) { - return f.compoundOwner(Field_Devices.Key(), typ) -} - -func (f *FieldOwners) EnvOwner(name string) (string, bool) { - return f.compoundOwner(Field_Env.Key(), name) -} - -func (f *FieldOwners) ArgsOwner() (string, bool) { - return f.simpleOwner(Field_Args.Key()) -} - -func (f *FieldOwners) MemLimitOwner() (string, bool) { - return f.simpleOwner(Field_MemLimit.Key()) -} - -func (f *FieldOwners) MemReservationOwner() (string, bool) { - return f.simpleOwner(Field_MemReservation.Key()) -} - -func (f *FieldOwners) MemSwapLimitOwner() (string, bool) { - return f.simpleOwner(Field_MemSwapLimit.Key()) -} - -func (f *FieldOwners) MemKernelLimitOwner() (string, bool) { - return f.simpleOwner(Field_MemKernelLimit.Key()) -} - -func (f *FieldOwners) MemTCPLimitOwner() (string, bool) { - return f.simpleOwner(Field_MemTCPLimit.Key()) -} - -func (f *FieldOwners) MemSwappinessOwner() (string, bool) { - return f.simpleOwner(Field_MemSwappiness.Key()) -} - -func (f *FieldOwners) MemDisableOomKillerOwner() (string, bool) { - return f.simpleOwner(Field_MemDisableOomKiller.Key()) -} - -func (f *FieldOwners) MemUseHierarchyOwner() (string, bool) { - return f.simpleOwner(Field_MemUseHierarchy.Key()) -} - -func (f *FieldOwners) CPUSharesOwner() (string, bool) { - return f.simpleOwner(Field_CPUShares.Key()) -} - -func (f *FieldOwners) CPUQuotaOwner() (string, bool) { - return f.simpleOwner(Field_CPUQuota.Key()) -} - -func (f *FieldOwners) CPUPeriodOwner() (string, bool) { - return f.simpleOwner(Field_CPUPeriod.Key()) -} - -func (f *FieldOwners) CPURealtimeRuntimeOwner() (string, bool) { - return f.simpleOwner(Field_CPURealtimeRuntime.Key()) -} - -func (f *FieldOwners) CPURealtimePeriodOwner() (string, bool) { - return f.simpleOwner(Field_CPURealtimePeriod.Key()) -} - -func (f *FieldOwners) CPUSetCPUsOwner() (string, bool) { - return f.simpleOwner(Field_CPUSetCPUs.Key()) -} - -func (f *FieldOwners) CPUSetMemsOwner() (string, bool) { - return f.simpleOwner(Field_CPUSetMems.Key()) -} - -func (f *FieldOwners) PidsLimitOwner() (string, bool) { - return f.simpleOwner(Field_PidsLimit.Key()) -} - -func (f *FieldOwners) HugepageLimitOwner(size string) (string, bool) { - return f.compoundOwner(Field_HugepageLimits.Key(), size) -} - -func (f *FieldOwners) BlockioClassOwner() (string, bool) { - return f.simpleOwner(Field_BlockioClass.Key()) -} - -func (f *FieldOwners) RdtClassOwner() (string, bool) { - return f.simpleOwner(Field_RdtClass.Key()) -} - -func (f *FieldOwners) RdtSchemataOwner() (string, bool) { - return f.simpleOwner(Field_RdtSchemata.Key()) -} - -func (f *FieldOwners) RdtEnableMonitoringOwner() (string, bool) { - return f.simpleOwner(Field_RdtEnableMonitoring.Key()) -} - -func (f *FieldOwners) CgroupsUnifiedOwner(key string) (string, bool) { - return f.compoundOwner(Field_CgroupsUnified.Key(), key) -} - -func (f *FieldOwners) CgroupsPathOwner() (string, bool) { - return f.simpleOwner(Field_CgroupsPath.Key()) -} - -func (f *FieldOwners) OomScoreAdjOwner() (string, bool) { - return f.simpleOwner(Field_OomScoreAdj.Key()) -} - -func (f *FieldOwners) RlimitOwner(typ string) (string, bool) { - return f.compoundOwner(Field_Rlimits.Key(), typ) +func (o *OwningPlugins) NamespaceOwners(id string) (map[string]string, bool) { + return o.ownersFor(id).compoundOwnerMap(Field_Namespace.Key()) } func qualify(field int32, qualifiers ...string) string { diff --git a/pkg/api/owners_generated.go b/pkg/api/owners_generated.go new file mode 100644 index 00000000..fb2be562 --- /dev/null +++ b/pkg/api/owners_generated.go @@ -0,0 +1,934 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// Code generated by tools/protoc-gen-owners. DO NOT EDIT. +// versions: +// protoc-gen-owners 0.0.1 +// protoc v3.20.1 + +package api + +func (o *OwningPlugins) ClaimAnnotation(id, key, plugin string) error { + return o.mustOwnersFor(id).ClaimAnnotation(key, plugin) +} + +func (f *FieldOwners) ClaimAnnotation(key, plugin string) error { + return f.claimCompound(Field_Annotations.Key(), key, plugin) +} + +func (o *OwningPlugins) AnnotationOwner(id, key string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Annotations.Key(), key) +} + +func (f *FieldOwners) AnnotationOwner(key string) (string, bool) { + return f.compoundOwner(Field_Annotations.Key(), key) +} + +func (o *OwningPlugins) ClearAnnotation(id, key, plugin string) { + o.mustOwnersFor(id).ClearAnnotation(key, plugin) +} + +func (f *FieldOwners) ClearAnnotation(key, plugin string) { + f.clearCompound(Field_Annotations.Key(), key, plugin) +} + +func (o *OwningPlugins) ClaimMount(id, destination, plugin string) error { + return o.mustOwnersFor(id).ClaimMount(destination, plugin) +} + +func (f *FieldOwners) ClaimMount(destination, plugin string) error { + return f.claimCompound(Field_Mounts.Key(), destination, plugin) +} + +func (o *OwningPlugins) MountOwner(id, destination string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Mounts.Key(), destination) +} + +func (f *FieldOwners) MountOwner(destination string) (string, bool) { + return f.compoundOwner(Field_Mounts.Key(), destination) +} + +func (o *OwningPlugins) ClearMount(id, destination, plugin string) { + o.mustOwnersFor(id).ClearMount(destination, plugin) +} + +func (f *FieldOwners) ClearMount(destination, plugin string) { + f.clearCompound(Field_Mounts.Key(), destination, plugin) +} + +func (o *OwningPlugins) ClaimDevice(id, path, plugin string) error { + return o.mustOwnersFor(id).ClaimDevice(path, plugin) +} + +func (f *FieldOwners) ClaimDevice(path, plugin string) error { + return f.claimCompound(Field_Devices.Key(), path, plugin) +} + +func (o *OwningPlugins) DeviceOwner(id, path string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Devices.Key(), path) +} + +func (f *FieldOwners) DeviceOwner(path string) (string, bool) { + return f.compoundOwner(Field_Devices.Key(), path) +} + +func (o *OwningPlugins) ClearDevice(id, path, plugin string) { + o.mustOwnersFor(id).ClearDevice(path, plugin) +} + +func (f *FieldOwners) ClearDevice(path, plugin string) { + f.clearCompound(Field_Devices.Key(), path, plugin) +} + +func (o *OwningPlugins) ClaimCdiDevice(id, name, plugin string) error { + return o.mustOwnersFor(id).ClaimCdiDevice(name, plugin) +} + +func (f *FieldOwners) ClaimCdiDevice(name, plugin string) error { + return f.claimCompound(Field_CdiDevices.Key(), name, plugin) +} + +func (o *OwningPlugins) CdiDeviceOwner(id, name string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_CdiDevices.Key(), name) +} + +func (f *FieldOwners) CdiDeviceOwner(name string) (string, bool) { + return f.compoundOwner(Field_CdiDevices.Key(), name) +} + +func (o *OwningPlugins) ClearCdiDevice(id, name, plugin string) { + o.mustOwnersFor(id).ClearCdiDevice(name, plugin) +} + +func (f *FieldOwners) ClearCdiDevice(name, plugin string) { + f.clearCompound(Field_CdiDevices.Key(), name, plugin) +} + +func (o *OwningPlugins) ClaimEnv(id, name, plugin string) error { + return o.mustOwnersFor(id).ClaimEnv(name, plugin) +} + +func (f *FieldOwners) ClaimEnv(name, plugin string) error { + return f.claimCompound(Field_Env.Key(), name, plugin) +} + +func (o *OwningPlugins) EnvOwner(id, name string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Env.Key(), name) +} + +func (f *FieldOwners) EnvOwner(name string) (string, bool) { + return f.compoundOwner(Field_Env.Key(), name) +} + +func (o *OwningPlugins) ClearEnv(id, name, plugin string) { + o.mustOwnersFor(id).ClearEnv(name, plugin) +} + +func (f *FieldOwners) ClearEnv(name, plugin string) { + f.clearCompound(Field_Env.Key(), name, plugin) +} + +func (o *OwningPlugins) ClaimArgs(id, plugin string) error { + return o.mustOwnersFor(id).ClaimArgs(plugin) +} + +func (f *FieldOwners) ClaimArgs(plugin string) error { + return f.claimSimple(Field_Args.Key(), plugin) +} + +func (o *OwningPlugins) ArgsOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_Args.Key()) +} + +func (f *FieldOwners) ArgsOwner() (string, bool) { + return f.simpleOwner(Field_Args.Key()) +} + +func (o *OwningPlugins) ClearArgs(id, plugin string) { + o.mustOwnersFor(id).ClearArgs(plugin) +} + +func (f *FieldOwners) ClearArgs(plugin string) { + f.clearSimple(Field_Args.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemLimit(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemLimit(plugin) +} + +func (f *FieldOwners) ClaimMemLimit(plugin string) error { + return f.claimSimple(Field_MemLimit.Key(), plugin) +} + +func (o *OwningPlugins) MemLimitOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemLimit.Key()) +} + +func (f *FieldOwners) MemLimitOwner() (string, bool) { + return f.simpleOwner(Field_MemLimit.Key()) +} + +func (o *OwningPlugins) ClearMemLimit(id, plugin string) { + o.mustOwnersFor(id).ClearMemLimit(plugin) +} + +func (f *FieldOwners) ClearMemLimit(plugin string) { + f.clearSimple(Field_MemLimit.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemReservation(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemReservation(plugin) +} + +func (f *FieldOwners) ClaimMemReservation(plugin string) error { + return f.claimSimple(Field_MemReservation.Key(), plugin) +} + +func (o *OwningPlugins) MemReservationOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemReservation.Key()) +} + +func (f *FieldOwners) MemReservationOwner() (string, bool) { + return f.simpleOwner(Field_MemReservation.Key()) +} + +func (o *OwningPlugins) ClearMemReservation(id, plugin string) { + o.mustOwnersFor(id).ClearMemReservation(plugin) +} + +func (f *FieldOwners) ClearMemReservation(plugin string) { + f.clearSimple(Field_MemReservation.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemSwapLimit(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemSwapLimit(plugin) +} + +func (f *FieldOwners) ClaimMemSwapLimit(plugin string) error { + return f.claimSimple(Field_MemSwapLimit.Key(), plugin) +} + +func (o *OwningPlugins) MemSwapLimitOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemSwapLimit.Key()) +} + +func (f *FieldOwners) MemSwapLimitOwner() (string, bool) { + return f.simpleOwner(Field_MemSwapLimit.Key()) +} + +func (o *OwningPlugins) ClearMemSwapLimit(id, plugin string) { + o.mustOwnersFor(id).ClearMemSwapLimit(plugin) +} + +func (f *FieldOwners) ClearMemSwapLimit(plugin string) { + f.clearSimple(Field_MemSwapLimit.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemKernelLimit(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemKernelLimit(plugin) +} + +func (f *FieldOwners) ClaimMemKernelLimit(plugin string) error { + return f.claimSimple(Field_MemKernelLimit.Key(), plugin) +} + +func (o *OwningPlugins) MemKernelLimitOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemKernelLimit.Key()) +} + +func (f *FieldOwners) MemKernelLimitOwner() (string, bool) { + return f.simpleOwner(Field_MemKernelLimit.Key()) +} + +func (o *OwningPlugins) ClearMemKernelLimit(id, plugin string) { + o.mustOwnersFor(id).ClearMemKernelLimit(plugin) +} + +func (f *FieldOwners) ClearMemKernelLimit(plugin string) { + f.clearSimple(Field_MemKernelLimit.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemTCPLimit(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemTCPLimit(plugin) +} + +func (f *FieldOwners) ClaimMemTCPLimit(plugin string) error { + return f.claimSimple(Field_MemTCPLimit.Key(), plugin) +} + +func (o *OwningPlugins) MemTCPLimitOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemTCPLimit.Key()) +} + +func (f *FieldOwners) MemTCPLimitOwner() (string, bool) { + return f.simpleOwner(Field_MemTCPLimit.Key()) +} + +func (o *OwningPlugins) ClearMemTCPLimit(id, plugin string) { + o.mustOwnersFor(id).ClearMemTCPLimit(plugin) +} + +func (f *FieldOwners) ClearMemTCPLimit(plugin string) { + f.clearSimple(Field_MemTCPLimit.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemSwappiness(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemSwappiness(plugin) +} + +func (f *FieldOwners) ClaimMemSwappiness(plugin string) error { + return f.claimSimple(Field_MemSwappiness.Key(), plugin) +} + +func (o *OwningPlugins) MemSwappinessOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemSwappiness.Key()) +} + +func (f *FieldOwners) MemSwappinessOwner() (string, bool) { + return f.simpleOwner(Field_MemSwappiness.Key()) +} + +func (o *OwningPlugins) ClearMemSwappiness(id, plugin string) { + o.mustOwnersFor(id).ClearMemSwappiness(plugin) +} + +func (f *FieldOwners) ClearMemSwappiness(plugin string) { + f.clearSimple(Field_MemSwappiness.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemDisableOomKiller(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemDisableOomKiller(plugin) +} + +func (f *FieldOwners) ClaimMemDisableOomKiller(plugin string) error { + return f.claimSimple(Field_MemDisableOomKiller.Key(), plugin) +} + +func (o *OwningPlugins) MemDisableOomKillerOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemDisableOomKiller.Key()) +} + +func (f *FieldOwners) MemDisableOomKillerOwner() (string, bool) { + return f.simpleOwner(Field_MemDisableOomKiller.Key()) +} + +func (o *OwningPlugins) ClearMemDisableOomKiller(id, plugin string) { + o.mustOwnersFor(id).ClearMemDisableOomKiller(plugin) +} + +func (f *FieldOwners) ClearMemDisableOomKiller(plugin string) { + f.clearSimple(Field_MemDisableOomKiller.Key(), plugin) +} + +func (o *OwningPlugins) ClaimMemUseHierarchy(id, plugin string) error { + return o.mustOwnersFor(id).ClaimMemUseHierarchy(plugin) +} + +func (f *FieldOwners) ClaimMemUseHierarchy(plugin string) error { + return f.claimSimple(Field_MemUseHierarchy.Key(), plugin) +} + +func (o *OwningPlugins) MemUseHierarchyOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_MemUseHierarchy.Key()) +} + +func (f *FieldOwners) MemUseHierarchyOwner() (string, bool) { + return f.simpleOwner(Field_MemUseHierarchy.Key()) +} + +func (o *OwningPlugins) ClearMemUseHierarchy(id, plugin string) { + o.mustOwnersFor(id).ClearMemUseHierarchy(plugin) +} + +func (f *FieldOwners) ClearMemUseHierarchy(plugin string) { + f.clearSimple(Field_MemUseHierarchy.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPUShares(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPUShares(plugin) +} + +func (f *FieldOwners) ClaimCPUShares(plugin string) error { + return f.claimSimple(Field_CPUShares.Key(), plugin) +} + +func (o *OwningPlugins) CPUSharesOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPUShares.Key()) +} + +func (f *FieldOwners) CPUSharesOwner() (string, bool) { + return f.simpleOwner(Field_CPUShares.Key()) +} + +func (o *OwningPlugins) ClearCPUShares(id, plugin string) { + o.mustOwnersFor(id).ClearCPUShares(plugin) +} + +func (f *FieldOwners) ClearCPUShares(plugin string) { + f.clearSimple(Field_CPUShares.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPUQuota(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPUQuota(plugin) +} + +func (f *FieldOwners) ClaimCPUQuota(plugin string) error { + return f.claimSimple(Field_CPUQuota.Key(), plugin) +} + +func (o *OwningPlugins) CPUQuotaOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPUQuota.Key()) +} + +func (f *FieldOwners) CPUQuotaOwner() (string, bool) { + return f.simpleOwner(Field_CPUQuota.Key()) +} + +func (o *OwningPlugins) ClearCPUQuota(id, plugin string) { + o.mustOwnersFor(id).ClearCPUQuota(plugin) +} + +func (f *FieldOwners) ClearCPUQuota(plugin string) { + f.clearSimple(Field_CPUQuota.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPUPeriod(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPUPeriod(plugin) +} + +func (f *FieldOwners) ClaimCPUPeriod(plugin string) error { + return f.claimSimple(Field_CPUPeriod.Key(), plugin) +} + +func (o *OwningPlugins) CPUPeriodOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPUPeriod.Key()) +} + +func (f *FieldOwners) CPUPeriodOwner() (string, bool) { + return f.simpleOwner(Field_CPUPeriod.Key()) +} + +func (o *OwningPlugins) ClearCPUPeriod(id, plugin string) { + o.mustOwnersFor(id).ClearCPUPeriod(plugin) +} + +func (f *FieldOwners) ClearCPUPeriod(plugin string) { + f.clearSimple(Field_CPUPeriod.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPURealtimeRuntime(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPURealtimeRuntime(plugin) +} + +func (f *FieldOwners) ClaimCPURealtimeRuntime(plugin string) error { + return f.claimSimple(Field_CPURealtimeRuntime.Key(), plugin) +} + +func (o *OwningPlugins) CPURealtimeRuntimeOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPURealtimeRuntime.Key()) +} + +func (f *FieldOwners) CPURealtimeRuntimeOwner() (string, bool) { + return f.simpleOwner(Field_CPURealtimeRuntime.Key()) +} + +func (o *OwningPlugins) ClearCPURealtimeRuntime(id, plugin string) { + o.mustOwnersFor(id).ClearCPURealtimeRuntime(plugin) +} + +func (f *FieldOwners) ClearCPURealtimeRuntime(plugin string) { + f.clearSimple(Field_CPURealtimeRuntime.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPURealtimePeriod(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPURealtimePeriod(plugin) +} + +func (f *FieldOwners) ClaimCPURealtimePeriod(plugin string) error { + return f.claimSimple(Field_CPURealtimePeriod.Key(), plugin) +} + +func (o *OwningPlugins) CPURealtimePeriodOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPURealtimePeriod.Key()) +} + +func (f *FieldOwners) CPURealtimePeriodOwner() (string, bool) { + return f.simpleOwner(Field_CPURealtimePeriod.Key()) +} + +func (o *OwningPlugins) ClearCPURealtimePeriod(id, plugin string) { + o.mustOwnersFor(id).ClearCPURealtimePeriod(plugin) +} + +func (f *FieldOwners) ClearCPURealtimePeriod(plugin string) { + f.clearSimple(Field_CPURealtimePeriod.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPUSetCPUs(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPUSetCPUs(plugin) +} + +func (f *FieldOwners) ClaimCPUSetCPUs(plugin string) error { + return f.claimSimple(Field_CPUSetCPUs.Key(), plugin) +} + +func (o *OwningPlugins) CPUSetCPUsOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPUSetCPUs.Key()) +} + +func (f *FieldOwners) CPUSetCPUsOwner() (string, bool) { + return f.simpleOwner(Field_CPUSetCPUs.Key()) +} + +func (o *OwningPlugins) ClearCPUSetCPUs(id, plugin string) { + o.mustOwnersFor(id).ClearCPUSetCPUs(plugin) +} + +func (f *FieldOwners) ClearCPUSetCPUs(plugin string) { + f.clearSimple(Field_CPUSetCPUs.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCPUSetMems(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCPUSetMems(plugin) +} + +func (f *FieldOwners) ClaimCPUSetMems(plugin string) error { + return f.claimSimple(Field_CPUSetMems.Key(), plugin) +} + +func (o *OwningPlugins) CPUSetMemsOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CPUSetMems.Key()) +} + +func (f *FieldOwners) CPUSetMemsOwner() (string, bool) { + return f.simpleOwner(Field_CPUSetMems.Key()) +} + +func (o *OwningPlugins) ClearCPUSetMems(id, plugin string) { + o.mustOwnersFor(id).ClearCPUSetMems(plugin) +} + +func (f *FieldOwners) ClearCPUSetMems(plugin string) { + f.clearSimple(Field_CPUSetMems.Key(), plugin) +} + +func (o *OwningPlugins) ClaimPidsLimit(id, plugin string) error { + return o.mustOwnersFor(id).ClaimPidsLimit(plugin) +} + +func (f *FieldOwners) ClaimPidsLimit(plugin string) error { + return f.claimSimple(Field_PidsLimit.Key(), plugin) +} + +func (o *OwningPlugins) PidsLimitOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_PidsLimit.Key()) +} + +func (f *FieldOwners) PidsLimitOwner() (string, bool) { + return f.simpleOwner(Field_PidsLimit.Key()) +} + +func (o *OwningPlugins) ClearPidsLimit(id, plugin string) { + o.mustOwnersFor(id).ClearPidsLimit(plugin) +} + +func (f *FieldOwners) ClearPidsLimit(plugin string) { + f.clearSimple(Field_PidsLimit.Key(), plugin) +} + +func (o *OwningPlugins) ClaimHugepageLimit(id, size, plugin string) error { + return o.mustOwnersFor(id).ClaimHugepageLimit(size, plugin) +} + +func (f *FieldOwners) ClaimHugepageLimit(size, plugin string) error { + return f.claimCompound(Field_HugepageLimits.Key(), size, plugin) +} + +func (o *OwningPlugins) HugepageLimitOwner(id, size string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_HugepageLimits.Key(), size) +} + +func (f *FieldOwners) HugepageLimitOwner(size string) (string, bool) { + return f.compoundOwner(Field_HugepageLimits.Key(), size) +} + +func (o *OwningPlugins) ClearHugepageLimit(id, size, plugin string) { + o.mustOwnersFor(id).ClearHugepageLimit(size, plugin) +} + +func (f *FieldOwners) ClearHugepageLimit(size, plugin string) { + f.clearCompound(Field_HugepageLimits.Key(), size, plugin) +} + +func (o *OwningPlugins) ClaimBlockioClass(id, plugin string) error { + return o.mustOwnersFor(id).ClaimBlockioClass(plugin) +} + +func (f *FieldOwners) ClaimBlockioClass(plugin string) error { + return f.claimSimple(Field_BlockioClass.Key(), plugin) +} + +func (o *OwningPlugins) BlockioClassOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_BlockioClass.Key()) +} + +func (f *FieldOwners) BlockioClassOwner() (string, bool) { + return f.simpleOwner(Field_BlockioClass.Key()) +} + +func (o *OwningPlugins) ClearBlockioClass(id, plugin string) { + o.mustOwnersFor(id).ClearBlockioClass(plugin) +} + +func (f *FieldOwners) ClearBlockioClass(plugin string) { + f.clearSimple(Field_BlockioClass.Key(), plugin) +} + +func (o *OwningPlugins) ClaimRdtClass(id, plugin string) error { + return o.mustOwnersFor(id).ClaimRdtClass(plugin) +} + +func (f *FieldOwners) ClaimRdtClass(plugin string) error { + return f.claimSimple(Field_RdtClass.Key(), plugin) +} + +func (o *OwningPlugins) RdtClassOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_RdtClass.Key()) +} + +func (f *FieldOwners) RdtClassOwner() (string, bool) { + return f.simpleOwner(Field_RdtClass.Key()) +} + +func (o *OwningPlugins) ClearRdtClass(id, plugin string) { + o.mustOwnersFor(id).ClearRdtClass(plugin) +} + +func (f *FieldOwners) ClearRdtClass(plugin string) { + f.clearSimple(Field_RdtClass.Key(), plugin) +} + +func (o *OwningPlugins) ClaimCgroupsUnified(id, key, plugin string) error { + return o.mustOwnersFor(id).ClaimCgroupsUnified(key, plugin) +} + +func (f *FieldOwners) ClaimCgroupsUnified(key, plugin string) error { + return f.claimCompound(Field_CgroupsUnified.Key(), key, plugin) +} + +func (o *OwningPlugins) CgroupsUnifiedOwner(id, key string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_CgroupsUnified.Key(), key) +} + +func (f *FieldOwners) CgroupsUnifiedOwner(key string) (string, bool) { + return f.compoundOwner(Field_CgroupsUnified.Key(), key) +} + +func (o *OwningPlugins) ClearCgroupsUnified(id, key, plugin string) { + o.mustOwnersFor(id).ClearCgroupsUnified(key, plugin) +} + +func (f *FieldOwners) ClearCgroupsUnified(key, plugin string) { + f.clearCompound(Field_CgroupsUnified.Key(), key, plugin) +} + +func (o *OwningPlugins) ClaimCgroupsPath(id, plugin string) error { + return o.mustOwnersFor(id).ClaimCgroupsPath(plugin) +} + +func (f *FieldOwners) ClaimCgroupsPath(plugin string) error { + return f.claimSimple(Field_CgroupsPath.Key(), plugin) +} + +func (o *OwningPlugins) CgroupsPathOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_CgroupsPath.Key()) +} + +func (f *FieldOwners) CgroupsPathOwner() (string, bool) { + return f.simpleOwner(Field_CgroupsPath.Key()) +} + +func (o *OwningPlugins) ClearCgroupsPath(id, plugin string) { + o.mustOwnersFor(id).ClearCgroupsPath(plugin) +} + +func (f *FieldOwners) ClearCgroupsPath(plugin string) { + f.clearSimple(Field_CgroupsPath.Key(), plugin) +} + +func (o *OwningPlugins) ClaimOomScoreAdj(id, plugin string) error { + return o.mustOwnersFor(id).ClaimOomScoreAdj(plugin) +} + +func (f *FieldOwners) ClaimOomScoreAdj(plugin string) error { + return f.claimSimple(Field_OomScoreAdj.Key(), plugin) +} + +func (o *OwningPlugins) OomScoreAdjOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_OomScoreAdj.Key()) +} + +func (f *FieldOwners) OomScoreAdjOwner() (string, bool) { + return f.simpleOwner(Field_OomScoreAdj.Key()) +} + +func (o *OwningPlugins) ClearOomScoreAdj(id, plugin string) { + o.mustOwnersFor(id).ClearOomScoreAdj(plugin) +} + +func (f *FieldOwners) ClearOomScoreAdj(plugin string) { + f.clearSimple(Field_OomScoreAdj.Key(), plugin) +} + +func (o *OwningPlugins) ClaimRlimit(id, typ, plugin string) error { + return o.mustOwnersFor(id).ClaimRlimit(typ, plugin) +} + +func (f *FieldOwners) ClaimRlimit(typ, plugin string) error { + return f.claimCompound(Field_Rlimits.Key(), typ, plugin) +} + +func (o *OwningPlugins) RlimitOwner(id, typ string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Rlimits.Key(), typ) +} + +func (f *FieldOwners) RlimitOwner(typ string) (string, bool) { + return f.compoundOwner(Field_Rlimits.Key(), typ) +} + +func (o *OwningPlugins) ClearRlimit(id, typ, plugin string) { + o.mustOwnersFor(id).ClearRlimit(typ, plugin) +} + +func (f *FieldOwners) ClearRlimit(typ, plugin string) { + f.clearCompound(Field_Rlimits.Key(), typ, plugin) +} + +func (o *OwningPlugins) ClaimIOPriority(id, plugin string) error { + return o.mustOwnersFor(id).ClaimIOPriority(plugin) +} + +func (f *FieldOwners) ClaimIOPriority(plugin string) error { + return f.claimSimple(Field_IoPriority.Key(), plugin) +} + +func (o *OwningPlugins) IOPriorityOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_IoPriority.Key()) +} + +func (f *FieldOwners) IOPriorityOwner() (string, bool) { + return f.simpleOwner(Field_IoPriority.Key()) +} + +func (o *OwningPlugins) ClearIOPriority(id, plugin string) { + o.mustOwnersFor(id).ClearIOPriority(plugin) +} + +func (f *FieldOwners) ClearIOPriority(plugin string) { + f.clearSimple(Field_IoPriority.Key(), plugin) +} + +func (o *OwningPlugins) ClaimSeccompPolicy(id, plugin string) error { + return o.mustOwnersFor(id).ClaimSeccompPolicy(plugin) +} + +func (f *FieldOwners) ClaimSeccompPolicy(plugin string) error { + return f.claimSimple(Field_SeccompPolicy.Key(), plugin) +} + +func (o *OwningPlugins) SeccompPolicyOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_SeccompPolicy.Key()) +} + +func (f *FieldOwners) SeccompPolicyOwner() (string, bool) { + return f.simpleOwner(Field_SeccompPolicy.Key()) +} + +func (o *OwningPlugins) ClearSeccompPolicy(id, plugin string) { + o.mustOwnersFor(id).ClearSeccompPolicy(plugin) +} + +func (f *FieldOwners) ClearSeccompPolicy(plugin string) { + f.clearSimple(Field_SeccompPolicy.Key(), plugin) +} + +func (o *OwningPlugins) ClaimNamespace(id, typ, plugin string) error { + return o.mustOwnersFor(id).ClaimNamespace(typ, plugin) +} + +func (f *FieldOwners) ClaimNamespace(typ, plugin string) error { + return f.claimCompound(Field_Namespace.Key(), typ, plugin) +} + +func (o *OwningPlugins) NamespaceOwner(id, typ string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Namespace.Key(), typ) +} + +func (f *FieldOwners) NamespaceOwner(typ string) (string, bool) { + return f.compoundOwner(Field_Namespace.Key(), typ) +} + +func (o *OwningPlugins) ClearNamespace(id, typ, plugin string) { + o.mustOwnersFor(id).ClearNamespace(typ, plugin) +} + +func (f *FieldOwners) ClearNamespace(typ, plugin string) { + f.clearCompound(Field_Namespace.Key(), typ, plugin) +} + +func (o *OwningPlugins) ClaimSysctl(id, key, plugin string) error { + return o.mustOwnersFor(id).ClaimSysctl(key, plugin) +} + +func (f *FieldOwners) ClaimSysctl(key, plugin string) error { + return f.claimCompound(Field_Sysctl.Key(), key, plugin) +} + +func (o *OwningPlugins) SysctlOwner(id, key string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_Sysctl.Key(), key) +} + +func (f *FieldOwners) SysctlOwner(key string) (string, bool) { + return f.compoundOwner(Field_Sysctl.Key(), key) +} + +func (o *OwningPlugins) ClearSysctl(id, key, plugin string) { + o.mustOwnersFor(id).ClearSysctl(key, plugin) +} + +func (f *FieldOwners) ClearSysctl(key, plugin string) { + f.clearCompound(Field_Sysctl.Key(), key, plugin) +} + +func (o *OwningPlugins) ClaimLinuxNetDevice(id, path, plugin string) error { + return o.mustOwnersFor(id).ClaimLinuxNetDevice(path, plugin) +} + +func (f *FieldOwners) ClaimLinuxNetDevice(path, plugin string) error { + return f.claimCompound(Field_LinuxNetDevices.Key(), path, plugin) +} + +func (o *OwningPlugins) LinuxNetDeviceOwner(id, path string) (string, bool) { + return o.ownersFor(id).compoundOwner(Field_LinuxNetDevices.Key(), path) +} + +func (f *FieldOwners) LinuxNetDeviceOwner(path string) (string, bool) { + return f.compoundOwner(Field_LinuxNetDevices.Key(), path) +} + +func (o *OwningPlugins) ClearLinuxNetDevice(id, path, plugin string) { + o.mustOwnersFor(id).ClearLinuxNetDevice(path, plugin) +} + +func (f *FieldOwners) ClearLinuxNetDevice(path, plugin string) { + f.clearCompound(Field_LinuxNetDevices.Key(), path, plugin) +} + +func (o *OwningPlugins) ClaimLinuxScheduler(id, plugin string) error { + return o.mustOwnersFor(id).ClaimLinuxScheduler(plugin) +} + +func (f *FieldOwners) ClaimLinuxScheduler(plugin string) error { + return f.claimSimple(Field_LinuxSched.Key(), plugin) +} + +func (o *OwningPlugins) LinuxSchedulerOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_LinuxSched.Key()) +} + +func (f *FieldOwners) LinuxSchedulerOwner() (string, bool) { + return f.simpleOwner(Field_LinuxSched.Key()) +} + +func (o *OwningPlugins) ClearLinuxScheduler(id, plugin string) { + o.mustOwnersFor(id).ClearLinuxScheduler(plugin) +} + +func (f *FieldOwners) ClearLinuxScheduler(plugin string) { + f.clearSimple(Field_LinuxSched.Key(), plugin) +} + +func (o *OwningPlugins) ClaimRdtClosID(id, plugin string) error { + return o.mustOwnersFor(id).ClaimRdtClosID(plugin) +} + +func (f *FieldOwners) ClaimRdtClosID(plugin string) error { + return f.claimSimple(Field_RdtClosID.Key(), plugin) +} + +func (o *OwningPlugins) RdtClosIDOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_RdtClosID.Key()) +} + +func (f *FieldOwners) RdtClosIDOwner() (string, bool) { + return f.simpleOwner(Field_RdtClosID.Key()) +} + +func (o *OwningPlugins) ClearRdtClosID(id, plugin string) { + o.mustOwnersFor(id).ClearRdtClosID(plugin) +} + +func (f *FieldOwners) ClearRdtClosID(plugin string) { + f.clearSimple(Field_RdtClosID.Key(), plugin) +} + +func (o *OwningPlugins) ClaimRdtSchemata(id, plugin string) error { + return o.mustOwnersFor(id).ClaimRdtSchemata(plugin) +} + +func (f *FieldOwners) ClaimRdtSchemata(plugin string) error { + return f.claimSimple(Field_RdtSchemata.Key(), plugin) +} + +func (o *OwningPlugins) RdtSchemataOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_RdtSchemata.Key()) +} + +func (f *FieldOwners) RdtSchemataOwner() (string, bool) { + return f.simpleOwner(Field_RdtSchemata.Key()) +} + +func (o *OwningPlugins) ClearRdtSchemata(id, plugin string) { + o.mustOwnersFor(id).ClearRdtSchemata(plugin) +} + +func (f *FieldOwners) ClearRdtSchemata(plugin string) { + f.clearSimple(Field_RdtSchemata.Key(), plugin) +} + +func (o *OwningPlugins) ClaimRdtEnableMonitoring(id, plugin string) error { + return o.mustOwnersFor(id).ClaimRdtEnableMonitoring(plugin) +} + +func (f *FieldOwners) ClaimRdtEnableMonitoring(plugin string) error { + return f.claimSimple(Field_RdtEnableMonitoring.Key(), plugin) +} + +func (o *OwningPlugins) RdtEnableMonitoringOwner(id string) (string, bool) { + return o.ownersFor(id).simpleOwner(Field_RdtEnableMonitoring.Key()) +} + +func (f *FieldOwners) RdtEnableMonitoringOwner() (string, bool) { + return f.simpleOwner(Field_RdtEnableMonitoring.Key()) +} + +func (o *OwningPlugins) ClearRdtEnableMonitoring(id, plugin string) { + o.mustOwnersFor(id).ClearRdtEnableMonitoring(plugin) +} + +func (f *FieldOwners) ClearRdtEnableMonitoring(plugin string) { + f.clearSimple(Field_RdtEnableMonitoring.Key(), plugin) +} diff --git a/tools/protoc-gen-owners/main.go b/tools/protoc-gen-owners/main.go new file mode 100644 index 00000000..18a5c391 --- /dev/null +++ b/tools/protoc-gen-owners/main.go @@ -0,0 +1,246 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package main + +import ( + "flag" + "fmt" + "strings" + + "google.golang.org/protobuf/compiler/protogen" +) + +const ( + version = "0.0.1" + licenseHeader = `/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/` +) + +var ownersGoFilename string + +// Hardcoded map to distinguish simple vs compound fields. +var compoundFields = map[string]bool{ + "Annotations": true, + "Mounts": true, + "Devices": true, + "CdiDevices": true, + "Env": true, + "HugepageLimits": true, + "CgroupsUnified": true, + "Rlimits": true, + "Namespace": true, + "Sysctl": true, + "LinuxNetDevices": true, +} + +var compoundKeys = map[string]string{ + "Annotations": "key", + "Mounts": "destination", + "Devices": "path", + "CdiDevices": "name", + "Env": "name", + "HugepageLimits": "size", + "CgroupsUnified": "key", + "Rlimits": "typ", + "Namespace": "typ", + "Sysctl": "key", + "LinuxNetDevices": "path", +} + +func main() { + var flags flag.FlagSet + flags.StringVar(&ownersGoFilename, "file", "owners_generated.go", "output filename for owner functions") + + protogen.Options{ + ParamFunc: flags.Set, + }.Run(func(gen *protogen.Plugin) error { + for _, f := range gen.Files { + if !f.Generate { + continue + } + generateFile(gen, f) + } + return nil + }) +} + +// generateFile generates a .go file containing owner functions. +func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.GeneratedFile { + var fieldEnum *protogen.Enum + for _, e := range file.Enums { + if e.GoIdent.GoName == "Field" { + fieldEnum = e + break + } + } + if fieldEnum == nil { + return nil + } + + filename := ownersGoFilename + g := gen.NewGeneratedFile(filename, file.GoImportPath) + + for _, line := range strings.Split(licenseHeader, "\n") { + g.P(line) + } + g.P() + g.P("// Code generated by tools/protoc-gen-owners. DO NOT EDIT.") + g.P("// versions:") + g.P(fmt.Sprintf("// protoc-gen-owners %s", version)) + g.P(fmt.Sprintf("// protoc %s", protocVersion(gen))) + g.P() + g.P("package ", file.GoPackageName) + g.P() + + generateOwnerFuncs(g, fieldEnum) + + return g +} + +var skipFields = map[string]bool{ + "OciHooks": true, +} + +var nameOverrides = map[string]string{ + "Annotations": "Annotation", + "Mounts": "Mount", + "Devices": "Device", + "HugepageLimits": "HugepageLimit", + "LinuxNetDevices": "LinuxNetDevice", + "CdiDevices": "CdiDevice", + "IoPriority": "IOPriority", + "LinuxSched": "LinuxScheduler", + "Rlimits": "Rlimit", +} + +func generateOwnerFuncs(g *protogen.GeneratedFile, fieldEnum *protogen.Enum) { + for _, enumValue := range fieldEnum.Values { + enumValueName := enumValue.GoIdent.GoName + if enumValueName == "Field_None" || enumValueName == "None" { + continue + } + originalFieldName := strings.TrimPrefix(enumValueName, "Field_") + if skipFields[originalFieldName] { + continue + } + fieldName := originalFieldName + if override, ok := nameOverrides[originalFieldName]; ok { + fieldName = override + } + + isCompound := compoundFields[originalFieldName] + keyName := compoundKeys[originalFieldName] + + if isCompound { + // OwningPlugins.Claim + g.P("func (o *OwningPlugins) Claim", fieldName, "(id, ", keyName, ", plugin string) error {") + g.P(" return o.mustOwnersFor(id).Claim", fieldName, "(", keyName, ", plugin)") + g.P("}") + g.P() + + // FieldOwners.Claim + g.P("func (f *FieldOwners) Claim", fieldName, "(", keyName, ", plugin string) error {") + g.P(" return f.claimCompound(Field_", originalFieldName, ".Key(), ", keyName, ", plugin)") + g.P("}") + g.P() + + // OwningPlugins.Owner + g.P("func (o *OwningPlugins) ", fieldName, "Owner(id, ", keyName, " string) (string, bool) {") + g.P(" return o.ownersFor(id).compoundOwner(Field_", originalFieldName, ".Key(), ", keyName, ")") + g.P("}") + g.P() + + // FieldOwners.Owner + g.P("func (f *FieldOwners) ", fieldName, "Owner(", keyName, " string) (string, bool) {") + g.P(" return f.compoundOwner(Field_", originalFieldName, ".Key(), ", keyName, ")") + g.P("}") + g.P() + + // OwningPlugins.Clear + g.P("func (o *OwningPlugins) Clear", fieldName, "(id, ", keyName, ", plugin string) {") + g.P(" o.mustOwnersFor(id).Clear", fieldName, "(", keyName, ", plugin)") + g.P("}") + g.P() + + // FieldOwners.Clear + g.P("func (f *FieldOwners) Clear", fieldName, "(", keyName, ", plugin string) {") + g.P(" f.clearCompound(Field_", originalFieldName, ".Key(), ", keyName, ", plugin)") + g.P("}") + g.P() + } else { + // OwningPlugins.Claim + g.P("func (o *OwningPlugins) Claim", fieldName, "(id, plugin string) error {") + g.P(" return o.mustOwnersFor(id).Claim", fieldName, "(plugin)") + g.P("}") + g.P() + + // FieldOwners.Claim + g.P("func (f *FieldOwners) Claim", fieldName, "(plugin string) error {") + g.P(" return f.claimSimple(Field_", originalFieldName, ".Key(), plugin)") + g.P("}") + g.P() + + // OwningPlugins.Owner + g.P("func (o *OwningPlugins) ", fieldName, "Owner(id string) (string, bool) {") + g.P(" return o.ownersFor(id).simpleOwner(Field_", originalFieldName, ".Key())") + g.P("}") + g.P() + + // FieldOwners.Owner + g.P("func (f *FieldOwners) ", fieldName, "Owner() (string, bool) {") + g.P(" return f.simpleOwner(Field_", originalFieldName, ".Key())") + g.P("}") + g.P() + + // OwningPlugins.Clear + g.P("func (o *OwningPlugins) Clear", fieldName, "(id, plugin string) {") + g.P(" o.mustOwnersFor(id).Clear", fieldName, "(plugin)") + g.P("}") + g.P() + + // FieldOwners.Clear + g.P("func (f *FieldOwners) Clear", fieldName, "(plugin string) {") + g.P(" f.clearSimple(Field_", originalFieldName, ".Key(), plugin)") + g.P("}") + g.P() + } + } +} + +func protocVersion(gen *protogen.Plugin) string { + if v := gen.Request.GetCompilerVersion(); v != nil { + suffix := "" + if v.GetSuffix() != "" { + suffix = "-" + v.GetSuffix() + } + return fmt.Sprintf("v%d.%d.%d%s", v.GetMajor(), v.GetMinor(), v.GetPatch(), suffix) + } + return "(unknown)" +}