Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Consolidate discovery options for all providers and remove duplicate all/auto from CLI help info. #4840

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cli/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ func setConnector(provider *plugin.Provider, connector *plugin.Connector, run fu
for _, tmpFile := range temporaryFiles {
_ = os.Remove(tmpFile)
}

}

attachFlags(cmd.Flags(), allFlags)
Expand Down
3 changes: 2 additions & 1 deletion providers/atlassian/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package config
import (
"go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v11/providers/atlassian/connection"
"go.mondoo.com/cnquery/v11/providers/atlassian/connection/confluence"
"go.mondoo.com/cnquery/v11/providers/atlassian/provider"
)
Expand Down Expand Up @@ -49,7 +50,7 @@ Notes:
Atlassian provides these values when you set up an identity provider.
`,
MaxArgs: 2,
Discovery: []string{},
Discovery: []string{connection.DiscoveryOrganization},
Flags: []plugin.Flag{
{
Long: "admin-token",
Expand Down
3 changes: 0 additions & 3 deletions providers/atlassian/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import (
)

const (
// Discovery flags
DiscoveryAuto = "auto"
DiscoveryAll = "all"
DiscoveryOrganization = "organization"
)

Expand Down
6 changes: 4 additions & 2 deletions providers/aws/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ Notes:
MaxArgs: 4,
Discovery: []string{
resources.DiscoveryAccounts,
resources.DiscoveryAll,
resources.DiscoveryAuto,

resources.DiscoveryInstances,
resources.DiscoveryEC2InstanceAPI,
resources.DiscoverySSMInstances,
resources.DiscoverySSMInstanceAPI,
resources.DiscoveryECR,
resources.DiscoveryECRImageAPI,
resources.DiscoveryECS,
resources.DiscoveryECSContainersAPI,

resources.DiscoveryOrg,
resources.DiscoveryResources,
resources.DiscoveryS3Buckets,
resources.DiscoveryCloudtrailTrails,
Expand All @@ -78,6 +79,7 @@ Notes:
resources.DiscoveryCloudwatchLoggroups,
resources.DiscoveryLambdaFunctions,
resources.DiscoveryDynamoDBTables,
resources.DiscoveryDynamoDBGlobalTables,
resources.DiscoveryRedshiftClusters,
resources.DiscoveryVolumes,
resources.DiscoverySnapshots,
Expand Down
4 changes: 2 additions & 2 deletions providers/azure/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ var Config = plugin.Provider{
MinArgs: 0,
MaxArgs: 8,
Discovery: []string{
resources.DiscoveryAuto,
resources.DiscoveryAll,
resources.DiscoverySubscriptions,
resources.DiscoveryInstances,
resources.DiscoveryInstancesApi,
resources.DiscoverySqlServers,
resources.DiscoveryPostgresServers,
resources.DiscoveryPostgresFlexibleServers,
resources.DiscoveryMySqlServers,
resources.DiscoveryMySqlFlexibleServers,
resources.DiscoveryMariaDbServers,
resources.DiscoveryStorageAccounts,
resources.DiscoveryStorageContainers,
Expand Down
2 changes: 0 additions & 2 deletions providers/gcp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ var Config = plugin.Provider{
Short: "a Google Cloud project or folder",
MaxArgs: 2,
Discovery: []string{
resources.DiscoveryAll,
resources.DiscoveryAuto,
resources.DiscoveryOrganization,
resources.DiscoveryFolders,
resources.DiscoveryInstances,
Expand Down
1 change: 1 addition & 0 deletions providers/github/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Notes:
Discovery: []string{
connection.DiscoveryRepos,
connection.DiscoveryUsers,
connection.DiscoveryOrganization,
connection.DiscoveryTerraform,
connection.DiscoveryK8sManifests,
},
Expand Down
2 changes: 1 addition & 1 deletion providers/gitlab/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ var Config = plugin.Provider{
Use: "gitlab",
Short: "a GitLab group or project",
Discovery: []string{
provider.DiscoveryAuto,
provider.DiscoveryGroup,
provider.DiscoveryProject,
provider.DiscoveryTerraform,
provider.DiscoveryK8sManifests,
},
Flags: []plugin.Flag{
{
Expand Down
2 changes: 1 addition & 1 deletion providers/ipmi/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Examples:
`,
MinArgs: 1,
MaxArgs: 1,
Discovery: []string{provider.ConnectionType},
Discovery: []string{},
Flags: []plugin.Flag{
{
Long: "ask-pass",
Expand Down
2 changes: 0 additions & 2 deletions providers/k8s/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ var Config = plugin.Provider{
MinArgs: 0,
MaxArgs: 1,
Discovery: []string{
resources.DiscoveryAll,
resources.DiscoveryAuto,
resources.DiscoveryAdmissionReviews,
resources.DiscoveryClusters,
resources.DiscoveryContainerImages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ type Resolver struct {
NoStrictValidation bool
}

func (r *Resolver) Name() string {
return "Container Registry Discover"
}

func (r *Resolver) AvailableDiscoveryTargets() []string {
return []string{"auto", "all"}
}

func (r *Resolver) Resolve(ctx context.Context, root *inventory.Asset, conf *inventory.Config, credsResolver vault.Resolver) ([]*inventory.Asset, error) {
resolved := []*inventory.Asset{}

Expand Down
8 changes: 0 additions & 8 deletions providers/os/resources/discovery/docker_engine/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ const (

type Resolver struct{}

func (r *Resolver) Name() string {
return "Docker Resolver"
}

func (r *Resolver) AvailableDiscoveryTargets() []string {
return []string{"auto", "all", DiscoveryContainerRunning, DiscoveryContainerImages}
}

// func (r *Resolver) Resolve(ctx context.Context, root *inventory.Asset, conf *inventory.Config, credsResolver vault.Resolver, sfn common.QuerySecretFn, userIdDetectors ...providers.PlatformIdDetector) ([]*inventory.Asset, error) {
func (r *Resolver) Resolve(ctx context.Context, root *inventory.Asset, conf *inventory.Config, credsResolver vault.Resolver) ([]*inventory.Asset, error) {
if conf == nil {
Expand Down
2 changes: 0 additions & 2 deletions providers/shodan/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Examples:
MinArgs: 0,
MaxArgs: 2,
Discovery: []string{
connection.DiscoveryAll,
connection.DiscoveryAuto,
connection.DiscoveryHosts,
},
Flags: []plugin.Flag{
Expand Down
Loading