Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var SecretsParser = &resourceparser.Parser{ Name: "Secrets", InterestingImports: resourceparser.RunAlways, Run: func(p *resourceparser.Pass) { secrets := p.Pkg.Names().PkgDecls["secrets"] if secrets == nil || secrets.Type != token.VAR { return } spec := secrets.Spec.(*ast.ValueSpec) if spec.Type == nil { p.Errs.Add(errSecretsMustBeStruct.AtGoNode(spec, errors.AsError(fmt.Sprintf("got %s", parseutil.NodeType(spec))))) return } else if len(spec.Names) != 1 { p.Errs.Add(errSecretsDefinedSeperately.AtGoNode(spec)) return } else if len(spec.Values) != 0 { p.Errs.Add(errSecretsGivenValue.AtGoNode(spec.Values[0])) return } st, ok := p.SchemaParser.ParseType(secrets.File, spec.Type).(schema.StructType) if !ok { p.Errs.Add(errSecretsMustBeStruct.AtGoNode(spec, errors.AsError(fmt.Sprintf("got %s", parseutil.NodeType(spec))))) return } res := &Secrets{ AST: spec.Type.(*ast.StructType), File: secrets.File, Spec: spec, Ident: spec.Names[0], } for _, f := range st.Fields { if f.IsAnonymous() { p.Errs.Add(errAnonymousFields.AtGoNode(f.AST)) continue } if !schemautil.IsBuiltinKind(f.Type, schema.String) { p.Errs.Add(errSecretsMustBeString.AtGoNode(f.AST.Type, errors.AsError(fmt.Sprintf("got %s", literals.PrettyPrint(f.Type.ASTExpr()))))) continue } res.Keys = append(res.Keys, f.Name.MustGet()) } p.RegisterResource(res) p.AddBind(res.Ident, res) }, }
Functions ¶
This section is empty.
Types ¶
type Secrets ¶
type Secrets struct { AST *ast.StructType File *pkginfo.File // Where the secrets struct is declared Ident *ast.Ident // The identifier of the secrets struct Keys []string // Secret keys to load // Spec is the value spec that defines the 'secrets' variable. Spec *ast.ValueSpec }
Secrets represents a secrets struct.
Click to show internal directories.
Click to hide internal directories.