Skip to main content

FileDeploy

File deployment operations on target hosts -- deploy files from the Object Store to agents, check status, and undeploy.

Methods

MethodDescription
Deploy(ctx, opts)Deploy file to agent with SHA check
Undeploy(ctx, opts)Remove a deployed file
Status(ctx, target, path)Check deployed file status

FileDeployOpts

FieldTypeRequiredDescription
ObjectNamestringYesName of the file in Object Store
PathstringYesDestination path on the target host
ContentTypestringYes"raw" or "template"
ModestringNoFile permission mode (e.g. "0644")
OwnerstringNoFile owner user
GroupstringNoFile owner group
Varsmap[string]anyNoTemplate variables for "template"
TargetstringYesHost target (see Targeting below)

Usage

import "github.com/retr0h/osapi/pkg/sdk/client"

c := client.New("http://localhost:8080", token)

// Deploy a raw file to a specific host
resp, err := c.FileDeploy.Deploy(ctx, client.FileDeployOpts{
ObjectName: "nginx.conf",
Path: "/etc/nginx/nginx.conf",
ContentType: "raw",
Mode: "0644",
Target: "web-01",
})

// Deploy a template with variables
resp, err := c.FileDeploy.Deploy(ctx, client.FileDeployOpts{
ObjectName: "app.conf.tmpl",
Path: "/etc/app/config.yaml",
ContentType: "template",
Vars: map[string]any{
"port": 8080,
"debug": false,
},
Target: "_all",
})

// Check file status on a host
resp, err := c.FileDeploy.Status(ctx, "web-01", "/etc/nginx/nginx.conf")

Example

See examples/sdk/client/file_deploy.go for a complete working example. See also examples/sdk/client/file.go for Object Store operations (upload, list, get, delete).

Permissions

Deploy and undeploy require file:write. Status requires file:read.