From a4206dd44a231b497c340f0bfd160d213efef9a2 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Fri, 19 Jun 2020 12:09:57 -0400 Subject: [PATCH] Support installing non-core integrations --- cmd/agent/app/integrations.go | 19 +++++++++++++++++-- ...on-core-integrations-985b24d4d4a08f4f.yaml | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/support-installing-non-core-integrations-985b24d4d4a08f4f.yaml diff --git a/cmd/agent/app/integrations.go b/cmd/agent/app/integrations.go index ad590efef3828c..d191ae97eb8a1d 100644 --- a/cmd/agent/app/integrations.go +++ b/cmd/agent/app/integrations.go @@ -56,11 +56,17 @@ var ( useSysPython bool versionOnly bool localWheel bool + integrationType string rootDir string pythonMajorVersion string pythonMinorVersion string reqAgentReleasePath string constraintsPath string + + rootLayoutTypeMap = map[string]string{ + "core": "core", + "contrib": "extras", + } ) func init() { @@ -81,6 +87,9 @@ func init() { installCmd.Flags().BoolVarP( &localWheel, "local-wheel", "w", false, fmt.Sprintf("install an agent check from a locally available wheel file. %s", disclaimer), ) + installCmd.Flags().StringVarP( + &integrationType, "type", "t", "core", "indicate the type of integration (default: core), among: core, contrib", + ) } var integrationCmd = &cobra.Command{ @@ -408,8 +417,13 @@ func install(cmd *cobra.Command, args []string) error { ) } + rootLayoutType, exists := rootLayoutTypeMap[integrationType] + if !exists { + return fmt.Errorf("unknown integration type: %s", integrationType) + } + // Download the wheel - wheelPath, err := downloadWheel(integration, semverToPEP440(versionToInstall)) + wheelPath, err := downloadWheel(integration, semverToPEP440(versionToInstall), rootLayoutType) if err != nil { return fmt.Errorf("error when downloading the wheel for %s %s: %v", integration, versionToInstall, err) } @@ -445,7 +459,7 @@ func install(cmd *cobra.Command, args []string) error { return nil } -func downloadWheel(integration, version string) (string, error) { +func downloadWheel(integration, version, rootLayoutType string) (string, error) { pyPath, err := getCommandPython() if err != nil { return "", err @@ -455,6 +469,7 @@ func downloadWheel(integration, version string) (string, error) { "-m", downloaderModule, integration, "--version", version, + "--type", rootLayoutType, } if verbose > 0 { args = append(args, fmt.Sprintf("-%s", strings.Repeat("v", verbose))) diff --git a/releasenotes/notes/support-installing-non-core-integrations-985b24d4d4a08f4f.yaml b/releasenotes/notes/support-installing-non-core-integrations-985b24d4d4a08f4f.yaml new file mode 100644 index 00000000000000..8669be6d147eb4 --- /dev/null +++ b/releasenotes/notes/support-installing-non-core-integrations-985b24d4d4a08f4f.yaml @@ -0,0 +1,4 @@ +features: + - | + Support installing non-core integrations with the ``integration`` command, + such as those located in the ``integrations-extras`` repository.