Generate Puppet resource types natively before the env swap #2
Reference in New Issue
Block a user
Delete Branch "benvin/generate-types"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Puppet servers need
.resource_typesto isolate custom types per environment;puppet generate typesneeds a Ruby toolchain on the deploy host and runs outside the atomic swap.internal/gentypes, a static Go port ofpuppet generate types(classic DSL + Resource API).resource_typessymlinkw10k.generate_types: true; print skipped-type counts per envgenerate_typesand the generator version),],}orendmakes skipStatement return without advancing;parseFile(")\n")loops forever and hangs the deploy → always consume at least one token, or error at depth 0 closers[,{,#{); 4 MiB of[in a branch type file is a fatal stack overflow that kills w10k → cap nesting depth and return an errorinclude PuppetX::Foo::Params(anincludedhook callingbase.newparam),extend,instance_eval,Foo.add_params(self)silently drop attributes puppet emits; contradicts "unknown constructs fail" → allowlist harmless calls (validate, autorequire, feature, def, ...) and fail on the restdef exists?/create/destroyin the type body make puppet add an implicitensure(metatype/manager.rb:121); output has no ensure → detect the three public defs and add default ensure, or failbehavior:as an alias ofbehaviour:(type_definition.rb);behavior: :namevarrenders as a property with title pattern[\x27\x27]→ read both keys0x1f/1_000render as0x1f/1_000(puppet31/1000); lexer.go:483"\101"→101(puppetA); render.go:142/é/→/é/(puppet/(?-mix:é)/) → normalise or fail on these literals.resource_typessurvive cleanup (puppet unlinks every stale child) → remove non-directories too$basemodulepathmodules are dropped; puppet generates their types too → state it in the PR body or error when basemodulepath has typesprovidecall in eachgenerate_typeson leaves unchanged complete envs without.resource_typesuntil their next commit → note the forced redeploy in the PR bodycase c == '@' || c == '$'— a type/mixin file ending in$panics (slice out of range); prepare has no recover, so one file kills w10k → bounds-check before advancing past$provideris emitted for any provider//*.rb; puppet adds it only when a file callsprovide(empty or class-only file → none); deploy_test's empty posix.rb asserts the wrong output → skip unless every provider file is a recognisedprovide, fix the fixturePuppet::Type.type(:a).send(:newparam, :extra),H.add(Puppet::Type.type(:a))or.provide(:x) {}change puppet's output, not ours → allowlist top-level statements, skip the rest'namevar' => truemakes a namevar,'parent' => Puppet::Parameter::Booleanadds values, string-keyed register_type emits; puppet ignores/rejects all three.features: [:custom_insync]adds the trigger, puppet matches strings only → symbol keys only, string-only featuresVariant[String]→Pattern[//],Optional[Variant[Integer]]→Pattern[/^-?\d+$/]in puppet,Anyhere; unparseable'string'fails in puppet, emits here → skip anything outside a strict grammarType.newtypeoutsidemodule Puppet, and parents/Puppet::ResourceApiused without theirrequire, NameError in puppet but emit here → skip when scope/require is missingPuppet::Typestatements, the provide block and any constparent:(:1844); providers load insidenewtype, sorequire 'missing_gem',raise, undefined consts orparent: Puppet::Provider::Nopemake puppet drop the type while w10k writes it → analyse provider files with the type-file allowlist (block body included) or skip.title provider alias audit before consume export loglevel noop notify require schedule stage subscribe tag),desc+docs,ensurenotEnum[present, absent], attrrsapi_custom_insync_trigger; puppet emits nothing, w10k emits → skip these.Variantmember not flattened:Variant[Variant, String]is String in puppet (Pattern[//]), w10k emitsAny→ drop kid-less Variants when flattening.1.0e+5,0e0,1e400, which TypeParser rejects (puppet emits nothing) → match puppet's float lexing and reject float64 overflow.puppet_x/a/mix.rbor a second module's copy adds an implicitensurepuppet lacks → use only the required file; skip if >1 module provides it.$LOAD_PATH;require 'puppet/util/execution'loads core but w10k analyses the module copy (puppet: uninitialized constant, w10k: emits) → only resolve module requires for paths core/gems can't provide (e.g.puppet_x/), else skip.VALS='a'+module Puppet; VALS='b'; end+ top-level newtype gives puppetEnum['a'], w10kEnum['b']→ scope consts or skip on multi-scope assignment.