-
Notifications
You must be signed in to change notification settings - Fork 94
Add read only file plugin #1128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: add-auxiliary-command-server-to-agent-config
Are you sure you want to change the base?
Add read only file plugin #1128
Conversation
internal/file/read_only_plugin.go
Outdated
|
||
var _ bus.Plugin = (*ReadFilePlugin)(nil) | ||
|
||
// The file plugin only writes, deletes and checks hashes of files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment accurate for a 'read only' plugin?
} | ||
|
||
// nolint: dupl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove duplicate code between the file plugin and the read only file plugin, you could use embedding to take all the functionally from the read only file plugin and override whatever functions you need to change.
This can be done by updateing the FilePlugin struct to the following:
type FilePlugin struct {
*ReadFilePlugin
}
internal/file/read_only_plugin.go
Outdated
// The file plugin only writes, deletes and checks hashes of files | ||
// the file plugin does not care about the instance type | ||
|
||
type ReadFilePlugin struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ReadFilePlugin struct { | |
type ReadOnlyFilePlugin struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can we change the name of the file to read_only_file_plugin.go
?
internal/file/read_only_plugin.go
Outdated
|
||
func (rp *ReadFilePlugin) Info() *bus.Info { | ||
return &bus.Info{ | ||
Name: "read", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name: "read", | |
Name: "read-only-file", |
internal/file/read_only_plugin.go
Outdated
} | ||
|
||
func (rp *ReadFilePlugin) Init(ctx context.Context, messagePipe bus.MessagePipeInterface) error { | ||
slog.DebugContext(ctx, "Starting read file plugin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slog.DebugContext(ctx, "Starting read file plugin") | |
slog.DebugContext(ctx, "Starting read only file plugin") |
Should be consistent in the plugin name for the rest of the log statements in this file
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
type FileServiceOperator struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here exampling the purpose of this operator
Features: config.DefaultFeatures(), | ||
}, | ||
expected: []bus.Plugin{ | ||
&resource.Resource{}, | ||
&command.CommandPlugin{}, | ||
&file.FilePlugin{}, | ||
&command.CommandPlugin{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&command.CommandPlugin{}
is here twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya thats right, when an auxiliary command server is configured there will be two command plugins and two file plugins, one for the command sever and one for the auxiliary sever
…read-only-file-plugin
conn: grpcConnection, | ||
config: agentConfig, | ||
conn: grpcConnection, | ||
serverType: serverType, | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Init
& Close
functions can you add the serverType to the context?
fp.handleConfigApplyFailedRequest(ctx, msg) | ||
default: | ||
slog.DebugContext(ctx, "File plugin received unknown topic", "topic", msg.Topic) | ||
if logger.ServerType(ctx) == fp.serverType.String() || logger.ServerType(ctx) == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If logger.ServerType(ctx) == ""
then we should create a new context with the serverType.
The FilePlugin Info function needs to be updated as well to reflect if the file plugin is for command or auxiliary |
Proposed changes
File plugin subscribes to different topics depending on the server type.
Moved all handling of grpc to file service operator
Refactored file manager service, file plugin and file operator.
Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTING
documentmake install-tools
and have attached any dependency changes to this pull requestREADME.md
)