Documentation ¶
Overview ¶
Package agent includes helpers related to the Datadog Agent on Windows
Package agent includes helpers related to the Datadog Agent on Windows
Index ¶
- Constants
- func GetAgentUserFromRegistry(host *components.RemoteHost) (string, string, error)
- func GetBetaMSIURL(version string, arch string) (string, error)
- func GetChannelURL(channel string) (string, error)
- func GetConfigRootFromRegistry(host *components.RemoteHost) (string, error)
- func GetDatadogAgentProductCode(host *components.RemoteHost) (string, error)
- func GetInstallPathFromRegistry(host *components.RemoteHost) (string, error)
- func GetLatestMSIURL(majorVersion string, arch string) string
- func GetMSIURL(channel string, version string, arch string) (string, error)
- func GetPipelineMSIURL(pipelineID string, majorVersion string, arch string) (string, error)
- func GetStableMSIURL(version string, arch string) (string, error)
- func HasValidDatadogCodeSignature(host *components.RemoteHost, path string) error
- func InstallAgent(host *components.RemoteHost, options ...InstallAgentOption) (string, error)
- func LookupArchFromEnv() (string, bool)
- func LookupChannelFromEnv() (string, bool)
- func LookupChannelURLFromEnv() (string, bool)
- func LookupVersionFromEnv() (string, bool)
- func RepairAllAgent(host *components.RemoteHost, args string, logPath string) error
- func TestAgentVersion(t *testing.T, expected string, actual string) bool
- func TestValidDatadogCodeSignatures(t *testing.T, host *components.RemoteHost, paths []string) bool
- func UninstallAgent(host *components.RemoteHost, logPath string) error
- type InstallAgentOption
- func WithAPIKey(apiKey string) InstallAgentOption
- func WithAgentUser(username string) InstallAgentOption
- func WithAgentUserPassword(password string) InstallAgentOption
- func WithDdURL(ddURL string) InstallAgentOption
- func WithFakeIntake(fakeIntake *components.FakeIntake) InstallAgentOption
- func WithInstallLogFile(logFileName string) InstallAgentOption
- func WithLastStablePackage() InstallAgentOption
- func WithPackage(agentPackage *Package) InstallAgentOption
- func WithSite(site string) InstallAgentOption
- func WithValidAPIKey() InstallAgentOption
- func WithWixFailWhenDeferred() InstallAgentOption
- type InstallAgentParams
- type Package
Constants ¶
const ( // DatadogCodeSignatureThumbprint is the thumbprint of the Datadog Code Signing certificate // Valid From: May 2023 // Valid To: May 2025 DatadogCodeSignatureThumbprint = `B03F29CC07566505A718583E9270A6EE17678742` // RegistryKeyPath is the root registry key that the Datadog Agent uses to store some state RegistryKeyPath = "HKLM:\\SOFTWARE\\Datadog\\Datadog Agent" )
Variables ¶
This section is empty.
Functions ¶
func GetAgentUserFromRegistry ¶
func GetAgentUserFromRegistry(host *components.RemoteHost) (string, string, error)
GetAgentUserFromRegistry gets the domain and username that the agent was installed with from the registry
func GetBetaMSIURL ¶
GetBetaMSIURL returns the URL for the beta agent MSI majorVersion: 6, 7 arch: x86_64
func GetChannelURL ¶
GetChannelURL returns the URL for the channel name channel: beta, stable
func GetConfigRootFromRegistry ¶
func GetConfigRootFromRegistry(host *components.RemoteHost) (string, error)
GetConfigRootFromRegistry gets the config root from the registry, e.g. C:\ProgramData\Datadog
func GetDatadogAgentProductCode ¶
func GetDatadogAgentProductCode(host *components.RemoteHost) (string, error)
GetDatadogAgentProductCode returns the product code GUID for the Datadog Agent
func GetInstallPathFromRegistry ¶
func GetInstallPathFromRegistry(host *components.RemoteHost) (string, error)
GetInstallPathFromRegistry gets the install path from the registry, e.g. C:\Program Files\Datadog\Datadog Agent
func GetLatestMSIURL ¶
GetLatestMSIURL returns the URL for the latest agent MSI majorVersion: 6, 7 arch: x86_64
func GetMSIURL ¶
GetMSIURL returns the URL for the agent MSI channel: beta, stable majorVersion: 6, 7 arch: x86_64
func GetPipelineMSIURL ¶
GetPipelineMSIURL returns the URL for the agent MSI built by the pipeline majorVersion: 6, 7 arch: x86_64
func GetStableMSIURL ¶
GetStableMSIURL returns the URL for the stable agent MSI majorVersion: 6, 7 arch: x86_64
func HasValidDatadogCodeSignature ¶
func HasValidDatadogCodeSignature(host *components.RemoteHost, path string) error
HasValidDatadogCodeSignature an error if the file at the given path is not validy signed by the Datadog Code Signing certificate
func InstallAgent ¶
func InstallAgent(host *components.RemoteHost, options ...InstallAgentOption) (string, error)
InstallAgent installs the agent and returns the remote MSI path and any errors
func LookupArchFromEnv ¶
LookupArchFromEnv looks at environment variabes to select the agent arch, if the value is found it is returned along with true, otherwise a default value and false are returned.
WINDOWS_AGENT_ARCH: The arch of the agent, x86_64
Default arch: x86_64
func LookupChannelFromEnv ¶
LookupChannelFromEnv looks at environment variabes to select the agent channel, if the value is found it is returned along with true, otherwise a default value and false are returned.
WINDOWS_AGENT_CHANNEL: beta, stable
Default channel: stable
func LookupChannelURLFromEnv ¶
LookupChannelURLFromEnv looks at environment variabes to select the agent channel URL, if the value is found it is returned along with true, otherwise a default value and false are returned.
WINDOWS_AGENT_CHANNEL_URL: URL to installers_v2.json
See also LookupChannelFromEnv()
Default channel: stable
func LookupVersionFromEnv ¶
LookupVersionFromEnv looks at environment variabes to select the agent version, if the value is found it is returned along with true, otherwise a default value and false are returned.
In order of priority:
WINDOWS_AGENT_VERSION: The complete version, e.g. 7.49.0-1, 7.49.0-rc.3-1, or a major version, e.g. 7
AGENT_MAJOR_VERSION: The major version of the agent, 6 or 7
If only a major version is provided, the latest version of that major version is used.
Default version: 7
func RepairAllAgent ¶
func RepairAllAgent(host *components.RemoteHost, args string, logPath string) error
RepairAllAgent repairs the Datadog Agent
func TestAgentVersion ¶
TestAgentVersion compares the major.minor.patch-prefix parts of two agent versions
func TestValidDatadogCodeSignatures ¶
func TestValidDatadogCodeSignatures(t *testing.T, host *components.RemoteHost, paths []string) bool
TestValidDatadogCodeSignatures verifies that the files at the given paths are validly signed by the Datadog Code Signing certificate This test is skipped if the verify_code_signature parameter is set to false.
func UninstallAgent ¶
func UninstallAgent(host *components.RemoteHost, logPath string) error
UninstallAgent uninstalls the Datadog Agent
Types ¶
type InstallAgentOption ¶
type InstallAgentOption = func(*InstallAgentParams) error
InstallAgentOption is an optional function parameter type for InstallAgentParams options
func WithAPIKey ¶
func WithAPIKey(apiKey string) InstallAgentOption
WithAPIKey specifies the APIKEY parameter.
func WithAgentUser ¶
func WithAgentUser(username string) InstallAgentOption
WithAgentUser specifies the DDAGENTUSER_NAME parameter.
func WithAgentUserPassword ¶
func WithAgentUserPassword(password string) InstallAgentOption
WithAgentUserPassword specifies the DDAGENTUSER_PASSWORD parameter.
func WithDdURL ¶
func WithDdURL(ddURL string) InstallAgentOption
WithDdURL specifies the DD_URL parameter.
func WithFakeIntake ¶
func WithFakeIntake(fakeIntake *components.FakeIntake) InstallAgentOption
WithFakeIntake configures the Agent to use a fake intake URL.
func WithInstallLogFile ¶
func WithInstallLogFile(logFileName string) InstallAgentOption
WithInstallLogFile specifies the file where to save the MSI install logs.
func WithLastStablePackage ¶
func WithLastStablePackage() InstallAgentOption
WithLastStablePackage specifies to use the last stable installation package.
func WithPackage ¶
func WithPackage(agentPackage *Package) InstallAgentOption
WithPackage specifies the Agent installation package.
func WithSite ¶
func WithSite(site string) InstallAgentOption
WithSite specifies the SITE parameter.
func WithValidAPIKey ¶
func WithValidAPIKey() InstallAgentOption
WithValidAPIKey sets a valid API key fetched from the runner secret store.
func WithWixFailWhenDeferred ¶
func WithWixFailWhenDeferred() InstallAgentOption
WithWixFailWhenDeferred sets the WixFailWhenDeferred parameter.
type InstallAgentParams ¶
type InstallAgentParams struct { AgentUser string `installer_arg:"DDAGENTUSER_NAME"` AgentUserPassword string `installer_arg:"DDAGENTUSER_PASSWORD"` Site string `installer_arg:"SITE"` DdURL string `installer_arg:"DD_URL"` APIKey string `installer_arg:"APIKEY"` WixFailWhenDeferred string `installer_arg:"WIXFAILWHENDEFERRED"` InstallLogFile string Package *Package }
InstallAgentParams are the parameters used for installing the Agent using msiexec.
type Package ¶
type Package struct { // PipelineID is the pipeline ID used to lookup the MSI URL from the CI pipeline artifacts. PipelineID string // Channel is the channel used to lookup the MSI URL for the Version from the installers_v2.json file. Channel string // Version is the version of the MSI, e.g. 7.49.0-1, 7.49.0-rc.3-1, or a major version, e.g. 7 Version string // Arch is the architecture of the MSI, e.g. x86_64 Arch string // URL is the URL the MSI can be downloaded from URL string }
Package contains identifying information about an Agent MSI package.
func GetLastStablePackageFromEnv ¶
GetLastStablePackageFromEnv returns the latest stable agent MSI URL.
These environment variables are mutually exclusive, only one should be set, listed here in the order they are considered:
LAST_STABLE_WINDOWS_AGENT_MSI_URL: manually provided URL (all other parameters are informational only)
LAST_STABLE_VERSION: The complete version, e.g. 7.49.0-1, 7.49.0-rc.3-1, or a major version, e.g. 7, arch and channel are used
The value of LAST_STABLE_VERSION is set in release.json, and can be acquired by running: invoke release.get-release-json-value "last_stable::$AGENT_MAJOR_VERSION"
func GetPackageFromEnv ¶
GetPackageFromEnv looks at environment variabes to select the Agent MSI URL.
The returned Package contains the MSI URL and other identifying information. Some Package fields will be populated but may not be related to the returned URL. For example, if a URL is provided directly, the Channel, Version, and Arch fields have no effect on the returned URL. They are returned anyway so they can be used for other purposes, such as logging, stack name, instance options, test assertions, etc.
These environment variables are mutually exclusive, only one should be set, listed here in the order they are considered:
WINDOWS_AGENT_MSI_URL: manually provided URL (all other parameters are informational only)
CI_PIPELINE_ID: use the URL from a specific CI pipeline, major version and arch are used, channel is blank
WINDOWS_AGENT_VERSION: The complete version, e.g. 7.49.0-1, 7.49.0-rc.3-1, or a major version, e.g. 7, arch and channel are used
Other environment variables:
WINDOWS_AGENT_CHANNEL: beta or stable
WINDOWS_AGENT_ARCH: The arch of the agent, x86_64
If a channel is not provided and the version contains `-rc.`, the beta channel is used.
See other Lookup*FromEnv functions for more options and details.
If none of the above are set, the latest stable version is used.
func (*Package) AgentVersion ¶
AgentVersion returns a string containing version number and the pre only, e.g. `0.0.0-beta.1`