Skip to content

Commit

Permalink
Support installing non-core integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Jun 19, 2020
1 parent 4915790 commit a4206dd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/agent/app/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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{
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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)))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
features:
- |
Support installing non-core integrations with the ``integration`` command,
such as those located in the ``integrations-extras`` repository.

0 comments on commit a4206dd

Please sign in to comment.