-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSPM][SEC-5583] migrate compliance check to fx (#14052)
* move compliance check to fx * move stuff around so that it's importable * rename file * migrate cluster agent to use new component enabled check * bug fixes * improve cluster agent config setup * fix windows build
- Loading branch information
1 parent
7124208
commit d7f1b2d
Showing
9 changed files
with
172 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
package common | ||
|
||
import ( | ||
coreconfig "github.com/DataDog/datadog-agent/pkg/config" | ||
"github.com/DataDog/datadog-agent/pkg/logs" | ||
"github.com/DataDog/datadog-agent/pkg/logs/client" | ||
logshttp "github.com/DataDog/datadog-agent/pkg/logs/client/http" | ||
"github.com/DataDog/datadog-agent/pkg/logs/config" | ||
"github.com/DataDog/datadog-agent/pkg/util/log" | ||
) | ||
|
||
func NewLogContextCompliance() (*config.Endpoints, *client.DestinationsContext, error) { | ||
logsConfigComplianceKeys := config.NewLogsConfigKeys("compliance_config.endpoints.", coreconfig.Datadog) | ||
return NewLogContext(logsConfigComplianceKeys, "cspm-intake.", "compliance", config.DefaultIntakeOrigin, logs.AgentJSONIntakeProtocol) | ||
} | ||
|
||
func NewLogContext(logsConfig *config.LogsConfigKeys, endpointPrefix string, intakeTrackType config.IntakeTrackType, intakeOrigin config.IntakeOrigin, intakeProtocol config.IntakeProtocol) (*config.Endpoints, *client.DestinationsContext, error) { | ||
endpoints, err := config.BuildHTTPEndpointsWithConfig(logsConfig, endpointPrefix, intakeTrackType, intakeProtocol, intakeOrigin) | ||
if err != nil { | ||
endpoints, err = config.BuildHTTPEndpoints(intakeTrackType, intakeProtocol, intakeOrigin) | ||
if err == nil { | ||
httpConnectivity := logshttp.CheckConnectivity(endpoints.Main) | ||
endpoints, err = config.BuildEndpoints(httpConnectivity, intakeTrackType, intakeProtocol, intakeOrigin) | ||
} | ||
} | ||
|
||
if err != nil { | ||
return nil, nil, log.Errorf("Invalid endpoints: %v", err) | ||
} | ||
|
||
for _, status := range endpoints.GetStatus() { | ||
log.Info(status) | ||
} | ||
|
||
destinationsCtx := client.NewDestinationsContext() | ||
destinationsCtx.Start() | ||
|
||
return endpoints, destinationsCtx, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.