Skip to content

Commit

Permalink
Process remarks.
Browse files Browse the repository at this point in the history
Signed-off-by: Vasil Sirakov <[email protected]>
  • Loading branch information
VasilSirakov committed Nov 12, 2024
1 parent 4f67b6c commit aaa666d
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 35 deletions.
42 changes: 23 additions & 19 deletions cli/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,30 +220,34 @@ func attachConnectorCmd(provider *plugin.Provider, connector *plugin.Connector,
setConnector(provider, connector, cmd.Run, res)
}

func genBuiltinFlags(supportedDiscoveries ...string) []plugin.Flag {
flags := []plugin.Flag{}
func genBuiltinFlags(discoveries ...string) []plugin.Flag {
supportedDiscoveries := append([]string{"all", "auto"}, discoveries...)

if len(supportedDiscoveries) > 0 {
flags = append(flags, plugin.Flag{
return []plugin.Flag{
// flags for providers:
{
Long: "discover",
Type: plugin.FlagType_List,
Desc: "Enable the discovery of nested assets. Supports: " + strings.Join(supportedDiscoveries, ","),
})
},
{
Long: "pretty",
Type: plugin.FlagType_Bool,
Desc: "Pretty-print JSON",
Option: plugin.FlagOption_Hidden,
},
// runtime-only flags:
{
Long: "record",
Type: plugin.FlagType_String,
Desc: "Record all resource calls and use resources in the recording",
},
{
Long: "use-recording",
Type: plugin.FlagType_String,
Desc: "Use a recording to inject resource data (read-only)",
},
}
return append(flags, plugin.Flag{
Long: "pretty",
Type: plugin.FlagType_Bool,
Desc: "Pretty-print JSON",
Option: plugin.FlagOption_Hidden,
}, plugin.Flag{
Long: "record",
Type: plugin.FlagType_String,
Desc: "Record all resource calls and use resources in the recording",
}, plugin.Flag{
Long: "use-recording",
Type: plugin.FlagType_String,
Desc: "Use a recording to inject resource data (read-only)",
})
}

// the following flags are not processed by providers
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
4 changes: 4 additions & 0 deletions providers/atlassian/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"go.mondoo.com/cnquery/v11/providers/atlassian/connection/shared"
)

const (
DiscoveryOrganization = "organization"
)

const (
Admin shared.ConnectionType = "atlassian"
)
Expand Down
2 changes: 0 additions & 2 deletions providers/aws/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ Notes:
MinArgs: 0,
MaxArgs: 4,
Discovery: []string{
resources.DiscoveryAll,
resources.DiscoveryAuto,
resources.DiscoveryAccounts,

resources.DiscoveryInstances,
Expand Down
2 changes: 0 additions & 2 deletions providers/azure/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var Config = plugin.Provider{
MinArgs: 0,
MaxArgs: 8,
Discovery: []string{
resources.DiscoveryAuto,
resources.DiscoveryAll,
resources.DiscoverySubscriptions,
resources.DiscoveryInstances,
resources.DiscoveryInstancesApi,
Expand Down
3 changes: 1 addition & 2 deletions providers/gcp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ 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,
resources.DiscoveryProjects,
Expand Down
1 change: 1 addition & 0 deletions providers/gcp/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
// Discovery flags
DiscoveryAuto = "auto"
DiscoveryAll = "all"
DiscoveryOrganization = "organization"
DiscoveryFolders = "folders"
DiscoveryInstances = "instances"
DiscoveryProjects = "projects"
Expand Down
2 changes: 0 additions & 2 deletions providers/github/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ Notes:
MinArgs: 2,
MaxArgs: 2,
Discovery: []string{
connection.DiscoveryAll,
connection.DiscoveryAuto,
connection.DiscoveryRepos,
connection.DiscoveryUsers,
connection.DiscoveryOrganization,
Expand Down
1 change: 0 additions & 1 deletion providers/gitlab/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var Config = plugin.Provider{
Use: "gitlab",
Short: "a GitLab group or project",
Discovery: []string{
provider.DiscoveryAuto,
provider.DiscoveryGroup,
provider.DiscoveryProject,
provider.DiscoveryTerraform,
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
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
2 changes: 0 additions & 2 deletions providers/vsphere/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var Config = plugin.Provider{
Use: "vsphere user@host",
Short: "a VMware vSphere installation",
Discovery: []string{
resources.DiscoveryAll,
resources.DiscoveryAuto,
resources.DiscoveryApi,
resources.DiscoveryInstances,
resources.DiscoveryHostMachines,
Expand Down

0 comments on commit aaa666d

Please sign in to comment.