Skip to content
Draft
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
17 changes: 17 additions & 0 deletions central/app/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app

import (
"github.com/stackrox/rox/central/graphql/resolvers/loaders"
"github.com/stackrox/rox/pkg/memlimit"
"github.com/stackrox/rox/pkg/premain"
)

// Run is the main entry point for the central application.
// Performs early initialization and component-specific setup before
// main.centralRun() starts the actual central service logic.
func Run() {
memlimit.SetMemoryLimit()
premain.StartMain()

loaders.Init()
}
2 changes: 1 addition & 1 deletion central/graphql/resolvers/access_scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerAccessScopesSchema() {
schema := getBuilder()
utils.Must(
schema.AddQuery("simpleAccessScopes: [SimpleAccessScope!]!"),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/cluster_count_by_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerClusterCountByTypeSchema() {
schema := getBuilder()
utils.Must(
schema.AddType("ClusterCountByType", []string{
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/cluster_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerClusterHealthSchema() {
schema := getBuilder()
utils.Must(
schema.AddQuery("clusterHealthCounter(query: String): ClusterHealthCounter!"),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/cluster_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerClusterVulnerabilitiesSchema() {
schema := getBuilder()
utils.Must(
// NOTE: This list is and should remain alphabetically ordered
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerClustersSchema() {
schema := getBuilder()
utils.Must(
schema.AddType("PolicyStatus", []string{"status: String!", "failingPolicies: [Policy!]!"}),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
complianceOnce sync.Once
)

func init() {
func registerComplianceSchema() {
InitCompliance()
}

Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/compliance_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerComplianceManagementSchema() {
schema := getBuilder()
utils.Must(
schema.AddQuery("complianceRecentRuns(clusterId:ID, standardId:ID, since:Time): [ComplianceRun!]!"),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
componentPredicateFactory = predicate.NewFactory("component", &storage.EmbeddedImageScanComponent{})
)

func init() {
func registerComponentsSchema() {
schema := getBuilder()
utils.Must(
// NOTE: This list is and should remain alphabetically ordered
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/container_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerContainerInstancesSchema() {
schema := getBuilder()
const groupResolverName = "ContainerNameGroup"
utils.Must(
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/deploymentevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerDeploymentEventsSchema() {
schema := getBuilder()
utils.Must(
schema.AddInterfaceType("DeploymentEvent", []string{
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerDeploymentsSchema() {
schema := getBuilder()
utils.Must(
// NOTE: This list is and should remain alphabetically ordered
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerGroupsSchema() {
schema := getBuilder()
utils.Must(
schema.AddQuery("groups: [Group!]!"),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_components.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerImageComponentsSchema() {
schema := getBuilder()
utils.Must(schema.AddType("ImageComponentV2", []string{
"architecture: String!",
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_cve_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
maxImages = 1000
)

func init() {
func registerImageCVECoreSchema() {
schema := getBuilder()
utils.Must(
// NOTE: This list is and should remain alphabetically ordered
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerImageScanSchema() {
schema := getBuilder()
utils.Must(
schema.AddExtraResolvers("ImageScan", []string{
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_signature_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerImageSignatureVerificationSchema() {
schema := getBuilder()
utils.Must(
schema.AddExtraResolver("ImageSignatureVerificationResult", "verifierName: String!"),
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/image_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerImageVulnerabilitiesSchema() {
schema := getBuilder()
generator.RegisterProtoEnum(schema, reflect.TypeOf(storage.CvssScoreVersion(0)))

Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func registerImageWatchStatus(s string) string {
return s
}

func init() {
func registerImagesSchema() {
schema := getBuilder()
utils.Must(
schema.AddType("BaseImage", []string{
Expand Down
2 changes: 1 addition & 1 deletion central/graphql/resolvers/images_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerImagesV2Schema() {
schema := getBuilder()
utils.Must(
schema.AddExtraResolvers("ImageV2", []string{
Expand Down
57 changes: 57 additions & 0 deletions central/graphql/resolvers/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package resolvers

// Init registers all GraphQL resolver schemas.
// Called explicitly from getBuilder() in schema.go instead of package init().
func Init() {
// Register all resolver schemas in alphabetical order
registerAccessScopesSchema()
registerClusterCountByTypeSchema()
registerClusterHealthSchema()
registerClusterVulnerabilitiesSchema()
registerClustersSchema()
registerComplianceSchema()
registerComplianceManagementSchema()
registerComponentsSchema()
registerContainerInstancesSchema()
registerDeploymentEventsSchema()
registerDeploymentsSchema()
registerGroupsSchema()
registerImageComponentsSchema()
registerImageCVECoreSchema()
registerImageScanSchema()
registerImageSignatureVerificationSchema()
registerImageVulnerabilitiesSchema()
registerImagesSchema()
registerImagesV2Schema()
registerK8sRolesSchema()
registerNamespacesSchema()
registerNodeComponentsSchema()
registerNodeComponentsV1Schema()
registerNodeCVECoreSchema()
registerNodeScanSchema()
registerNodeVulnerabilitiesSchema()
registerNodesSchema()
registerNotifiersSchema()
registerPermissionSetsSchema()
registerPlatformCVECoreSchema()
registerPlatformCVECountByFixabilitySchema()
registerPlatformCVECountByTypeSchema()
registerPlottedImageVulnerabilitiesSchema()
registerPlottedNodeVulnerabilitiesSchema()
registerPodsSchema()
registerPoliciesSchema()
registerPolicyCounterSchema()
registerResourceCountBySeveritySchema()
registerRolesSchema()
registerSearchSchema()
registerSecretsSchema()
registerServiceAccountsSchema()
registerSubjectsSchema()
registerTokensSchema()
registerViolationsSchema()
registerVulMgmtWidgetsSchema()
registerVulnerabilitiesSchema()
registerVulnerabilityCounterSchema()
registerVulnerabilityRequestsSchema()
registerVulnerabilityVectorsSchema()
}
2 changes: 1 addition & 1 deletion central/graphql/resolvers/k8sroles.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stackrox/rox/pkg/utils"
)

func init() {
func registerK8sRolesSchema() {
schema := getBuilder()
utils.Must(
schema.AddQuery("k8sRole(id: ID!): K8SRole"),
Expand Down
6 changes: 0 additions & 6 deletions central/graphql/resolvers/loaders/cluster_cves.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import (

var clusterCveLoaderType = reflect.TypeOf(storage.ClusterCVE{})

func init() {
RegisterTypeFactory(reflect.TypeOf(storage.ClusterCVE{}), func() interface{} {
return NewClusterCVELoader(clusterCVEDataStore.Singleton())
})
}

// NewClusterCVELoader creates a new loader for cluster cve data.
func NewClusterCVELoader(ds clusterCVEDataStore.DataStore) ClusterCVELoader {
return &clusterCveLoaderImpl{
Expand Down
6 changes: 0 additions & 6 deletions central/graphql/resolvers/loaders/componentsV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ var (
componentV2LoaderType = reflect.TypeOf(storage.ImageComponentV2{})
)

func init() {
RegisterTypeFactory(componentV2LoaderType, func() interface{} {
return NewComponentV2Loader(datastore.Singleton())
})
}

// NewComponentV2Loader creates a new loader for component data.
func NewComponentV2Loader(ds datastore.DataStore) ComponentV2Loader {
return &componentV2LoaderImpl{
Expand Down
6 changes: 0 additions & 6 deletions central/graphql/resolvers/loaders/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import (

var deploymentLoaderType = reflect.TypeOf(storage.Deployment{})

func init() {
RegisterTypeFactory(reflect.TypeOf(storage.Deployment{}), func() interface{} {
return NewDeploymentLoader(datastore.Singleton(), deploymentsView.Singleton())
})
}

// NewDeploymentLoader creates a new loader for deployment data.
func NewDeploymentLoader(ds datastore.DataStore, deploymentView deploymentsView.DeploymentView) DeploymentLoader {
return &deploymentLoaderImpl{
Expand Down
6 changes: 0 additions & 6 deletions central/graphql/resolvers/loaders/image_cves_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import (

var imageCveV2LoaderType = reflect.TypeOf(storage.ImageCVEV2{})

func init() {
RegisterTypeFactory(imageCveV2LoaderType, func() interface{} {
return NewImageCVEV2Loader(ImageCVEDataStore.Singleton())
})
}

// NewImageCVEV2Loader creates a new loader for image cve data.
func NewImageCVEV2Loader(ds ImageCVEDataStore.DataStore) ImageCVEV2Loader {
return &imageCveV2LoaderImpl{
Expand Down
7 changes: 0 additions & 7 deletions central/graphql/resolvers/loaders/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/pkg/errors"
imageDatastore "github.com/stackrox/rox/central/image/datastore"
"github.com/stackrox/rox/central/imagev2/datastore/mapper/datastore"
imagesView "github.com/stackrox/rox/central/views/images"
v1 "github.com/stackrox/rox/generated/api/v1"
"github.com/stackrox/rox/generated/storage"
Expand All @@ -16,12 +15,6 @@ import (

var imageLoaderType = reflect.TypeOf(storage.Image{})

func init() {
RegisterTypeFactory(reflect.TypeOf(storage.Image{}), func() interface{} {
return NewImageLoader(datastore.Singleton(), imagesView.Singleton())
})
}

// NewImageLoader creates a new loader for image data. If postgres is enabled, this loader holds images without scan data—components and vulns.
func NewImageLoader(ds imageDatastore.DataStore, imageView imagesView.ImageView) ImageLoader {
return &imageLoaderImpl{
Expand Down
6 changes: 0 additions & 6 deletions central/graphql/resolvers/loaders/images_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ import (

var imageV2LoaderType = reflect.TypeOf(storage.ImageV2{})

func init() {
RegisterTypeFactory(reflect.TypeOf(storage.ImageV2{}), func() interface{} {
return NewImageV2Loader(datastore.Singleton(), imagesView.Singleton())
})
}

// NewImageV2Loader creates a new loader for image data.
func NewImageV2Loader(ds datastore.DataStore, imageView imagesView.ImageView) ImageV2Loader {
return &imageV2LoaderImpl{
Expand Down
Loading
Loading