Skip to content

Commit

Permalink
fix download plugins and add download policies
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Newbury committed Dec 12, 2024
1 parent d8c2b30 commit 23f7581
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ func (ar *AgentRunner) runInstance(nc *nats.Conn) error {
}

for _, inputBundle := range pluginConfig.Policies {
policyPath := ar.policyLocations[string(*inputBundle)]
res, err := runnerInstance.Eval(&proto.EvalRequest{
BundlePath: string(*inputBundle),
BundlePath: policyPath,
})
if err != nil {
return err
Expand Down Expand Up @@ -540,6 +541,10 @@ func (ar *AgentRunner) DownloadPolicies() error {
}

destination := path.Join(AgentPolicyDir, tag.RepositoryStr(), tag.Identifier())
policiesDir := path.Join(destination, "policies")
if err := os.MkdirAll(policiesDir, 0755); err != nil {
return err
}

downloaderImpl, err := oci.NewDownloader(
tag,
Expand All @@ -548,14 +553,11 @@ func (ar *AgentRunner) DownloadPolicies() error {
if err != nil {
return err
}
err = downloaderImpl.Download(remote.WithPlatform(v1.Platform{
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
}))
err = downloaderImpl.Download()
if err != nil {
return err
}
policyFile := path.Join(destination, "policy")
policyFile := policiesDir // Ensure the specific policy file name is used
ar.logger.Debug("Policy downloaded successfully", "Destination", policyFile)

if ar.policyLocations == nil {
Expand Down

0 comments on commit 23f7581

Please sign in to comment.