Documentation
¶
Overview ¶
Package embedded provides proto files bundled into the Buffalo binary.
When Buffalo is installed via `go install`, the proto files for buffalo.validate are embedded into the binary and can be extracted to the user's project workspace at any time.
This solves the problem of proto files not being available after `go install`, since Go only installs the compiled binary.
Index ¶
- Variables
- func ExtractAllProtos(workspaceDir string) (protoPath string, err error)
- func ExtractBazelRules(workspaceDir string) (rulesPath string, err error)
- func ExtractValidateProto(workspaceDir string) (protoPath string, err error)
- func ListEmbeddedBazelFiles() ([]string, error)
- func ListEmbeddedProtos() ([]string, error)
- func ValidateProtoImportPath(workspaceDir string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var BazelFS embed.FS
BazelFS contains the rules_buffalo Bazel module files. Extracted to .buffalo/bazel/rules_buffalo/ via ExtractBazelRules().
var ProtoFS embed.FS
ProtoFS contains all embedded proto files from the proto/ directory tree. The files are available at runtime and can be extracted to disk via ExtractValidateProto().
Functions ¶
func ExtractAllProtos ¶
ExtractAllProtos extracts every embedded proto file into workspaceDir and returns the root proto_path that should be passed to protoc.
Existing files are overwritten to ensure the version matches the binary.
func ExtractBazelRules ¶ added in v1.32.0
ExtractBazelRules extracts the embedded rules_buffalo Bazel module into <workspaceDir>/bazel/rules_buffalo/.
The extracted files provide Bazel rules for Buffalo proto compilation:
- buffalo_proto_compile — hermetic rule for bazel build
- buffalo_proto_gen — source-tree generation via bazel run
Returns the absolute path to the extracted rules_buffalo directory.
func ExtractValidateProto ¶
ExtractValidateProto extracts the embedded buffalo/validate/validate.proto into the given workspace directory.
The file is placed at:
<workspaceDir>/proto/buffalo/validate/validate.proto
It returns the absolute path to the directory that should be added to protoc's --proto_path (i.e. <workspaceDir>/proto).
func ListEmbeddedBazelFiles ¶ added in v1.32.0
ListEmbeddedBazelFiles returns a list of all embedded Bazel rule file paths.
func ListEmbeddedProtos ¶
ListEmbeddedProtos returns a list of all embedded proto file paths.
func ValidateProtoImportPath ¶
ValidateProtoImportPath returns the proto_path that should be added to protoc / Buffalo import paths so that `import "buffalo/validate/validate.proto";` and `import "buffalo/permissions/permissions.proto";` resolve correctly. If any embedded files haven't been extracted yet, it re-extracts them all.
workspaceDir is typically ".buffalo".
Types ¶
This section is empty.