Skip to content

Commit

Permalink
Add tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Mar 3, 2022
1 parent e3c3ee9 commit bd26d93
Show file tree
Hide file tree
Showing 8 changed files with 1,301 additions and 0 deletions.
7 changes: 7 additions & 0 deletions logger/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Package logger provides a global logger interface for logging from plugins.
//
// This package is a wrapper for hclog, and it initializes the global logger on import.
// You can freely write logs from anywhere via the public API according to the log level.
// The log by hclog is interpreted as a structured log by go-plugin, and the log level
// can be handled correctly.
package logger
12 changes: 12 additions & 0 deletions plugin/fromproto/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package fromproto contains an implementation to decode a structure
// generated from *.proto into a real Go structure. This package is not
// intended to be used directly from plugins.
//
// Many primitives can be handled as-is, but some interfaces and errors
// require special decoding. The `hcl.Expression` restores the interface
// by reparsed based on the bytes and their range. The `tflint.Rule`
// restores the interface by filling the value in a pseudo-structure that
// satisfies the interface. Error makes use of gRPC error details to recover
// the wrapped error. Rewrap the error based on the error code obtained
// from details.
package fromproto
12 changes: 12 additions & 0 deletions plugin/host2plugin/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package host2plugin contains a gRPC server (plugin) and client (host).
//
// In the plugin system, this communication is the first thing that happens,
// and a plugin must use this package to provide a gRPC server.
// However, the detailed implementation is hidden in the tflint.RuleSet interface,
// and plugin developers usually don't need to be aware of gRPC server behavior.
//
// When the host initializes a gRPC client, go-plugin starts a gRPC server
// on the plugin side as another process. This package acts as a wrapper for go-plugin.
// Separately, the Check function initializes a new gRPC client for plugin-to-host
// communication. See the plugin2host package for details.
package host2plugin
4 changes: 4 additions & 0 deletions plugin/interceptor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package interceptor contains gRPC interceptors.
// This package is not intended to be used directly from plugins.
// Its main use today is to insert shared processes such as logging.
package interceptor
12 changes: 12 additions & 0 deletions plugin/plugin2host/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package plugin2host contains a gRPC server (host) and client (plugin).
//
// Communication from the plugin to the host is the second one that occurs.
// To understand what happens first, see the host2plugin package first.
// The gRPC client used by the plugin is implicitly initialized by the host2plugin
// package and hidden in the tflint.Runner interface. Normally, plugin developers
// do not need to be aware of the details of this client.
//
// The host starts a gRPC server as goroutine to respond from the plugin side
// when calling Check function in host2plugin. Please note that the gRPC server
// and client startup in plugin2host is not due to go-plugin.
package plugin2host
Loading

0 comments on commit bd26d93

Please sign in to comment.