From c4b9063db8fa76b2e35766e257aeb7d50645859d Mon Sep 17 00:00:00 2001 From: minnakt Date: Mon, 25 Nov 2024 15:56:59 -0500 Subject: [PATCH] DEVPROD-12026: Expose `execUser` field from GraphQL Distro object --- graphql/generated.go | 74 +++++++++++- graphql/schema/types/distro.graphql | 2 + graphql/tests/query/distro/data.json | 103 +++++++++++++++++ .../queries/distro.graphql | 1 + graphql/tests/query/distro/results.json | 40 +++++++ graphql/tests/query/distros/results.json | 105 ++++++------------ 6 files changed, 254 insertions(+), 71 deletions(-) create mode 100644 graphql/tests/query/distro/data.json rename graphql/tests/query/{distros => distro}/queries/distro.graphql (95%) create mode 100644 graphql/tests/query/distro/results.json diff --git a/graphql/generated.go b/graphql/generated.go index 8cf8ea45db2..f571ec5bdb7 100644 --- a/graphql/generated.go +++ b/graphql/generated.go @@ -257,6 +257,7 @@ type ComplexityRoot struct { DisableShallowClone func(childComplexity int) int Disabled func(childComplexity int) int DispatcherSettings func(childComplexity int) int + ExecUser func(childComplexity int) int Expansions func(childComplexity int) int FinderSettings func(childComplexity int) int HomeVolumeSettings func(childComplexity int) int @@ -2772,6 +2773,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Distro.DispatcherSettings(childComplexity), true + case "Distro.execUser": + if e.complexity.Distro.ExecUser == nil { + break + } + + return e.complexity.Distro.ExecUser(childComplexity), true + case "Distro.expansions": if e.complexity.Distro.Expansions == nil { break @@ -17473,6 +17481,50 @@ func (ec *executionContext) fieldContext_Distro_dispatcherSettings(_ context.Con return fc, nil } +func (ec *executionContext) _Distro_execUser(ctx context.Context, field graphql.CollectedField, obj *model.APIDistro) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Distro_execUser(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ExecUser, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalNString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Distro_execUser(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Distro", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Distro_expansions(ctx context.Context, field graphql.CollectedField, obj *model.APIDistro) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Distro_expansions(ctx, field) if err != nil { @@ -25594,6 +25646,8 @@ func (ec *executionContext) fieldContext_Image_distros(_ context.Context, field return ec.fieldContext_Distro_disableShallowClone(ctx, field) case "dispatcherSettings": return ec.fieldContext_Distro_dispatcherSettings(ctx, field) + case "execUser": + return ec.fieldContext_Distro_execUser(ctx, field) case "expansions": return ec.fieldContext_Distro_expansions(ctx, field) case "finderSettings": @@ -46274,6 +46328,8 @@ func (ec *executionContext) fieldContext_Query_distro(ctx context.Context, field return ec.fieldContext_Distro_disableShallowClone(ctx, field) case "dispatcherSettings": return ec.fieldContext_Distro_dispatcherSettings(ctx, field) + case "execUser": + return ec.fieldContext_Distro_execUser(ctx, field) case "expansions": return ec.fieldContext_Distro_expansions(ctx, field) case "finderSettings": @@ -46454,6 +46510,8 @@ func (ec *executionContext) fieldContext_Query_distros(ctx context.Context, fiel return ec.fieldContext_Distro_disableShallowClone(ctx, field) case "dispatcherSettings": return ec.fieldContext_Distro_dispatcherSettings(ctx, field) + case "execUser": + return ec.fieldContext_Distro_execUser(ctx, field) case "expansions": return ec.fieldContext_Distro_expansions(ctx, field) case "finderSettings": @@ -52546,6 +52604,8 @@ func (ec *executionContext) fieldContext_SaveDistroPayload_distro(_ context.Cont return ec.fieldContext_Distro_disableShallowClone(ctx, field) case "dispatcherSettings": return ec.fieldContext_Distro_dispatcherSettings(ctx, field) + case "execUser": + return ec.fieldContext_Distro_execUser(ctx, field) case "expansions": return ec.fieldContext_Distro_expansions(ctx, field) case "finderSettings": @@ -73768,7 +73828,7 @@ func (ec *executionContext) unmarshalInputDistroInput(ctx context.Context, obj i asMap[k] = v } - fieldsInOrder := [...]string{"adminOnly", "aliases", "arch", "authorizedKeysFile", "bootstrapSettings", "containerPool", "disabled", "disableShallowClone", "dispatcherSettings", "expansions", "finderSettings", "homeVolumeSettings", "hostAllocatorSettings", "iceCreamSettings", "imageId", "isCluster", "isVirtualWorkStation", "name", "warningNote", "note", "plannerSettings", "provider", "providerSettingsList", "setup", "setupAsSudo", "sshOptions", "user", "userSpawnAllowed", "validProjects", "workDir", "mountpoints"} + fieldsInOrder := [...]string{"adminOnly", "aliases", "arch", "authorizedKeysFile", "bootstrapSettings", "containerPool", "disabled", "disableShallowClone", "dispatcherSettings", "execUser", "expansions", "finderSettings", "homeVolumeSettings", "hostAllocatorSettings", "iceCreamSettings", "imageId", "isCluster", "isVirtualWorkStation", "name", "warningNote", "note", "plannerSettings", "provider", "providerSettingsList", "setup", "setupAsSudo", "sshOptions", "user", "userSpawnAllowed", "validProjects", "workDir", "mountpoints"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -73840,6 +73900,13 @@ func (ec *executionContext) unmarshalInputDistroInput(ctx context.Context, obj i return it, err } it.DispatcherSettings = data + case "execUser": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("execUser")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ExecUser = data case "expansions": ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("expansions")) data, err := ec.unmarshalNExpansionInput2ᚕgithubᚗcomᚋevergreenᚑciᚋevergreenᚋrestᚋmodelᚐAPIExpansionᚄ(ctx, v) @@ -79920,6 +79987,11 @@ func (ec *executionContext) _Distro(ctx context.Context, sel ast.SelectionSet, o if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } + case "execUser": + out.Values[i] = ec._Distro_execUser(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "expansions": out.Values[i] = ec._Distro_expansions(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/graphql/schema/types/distro.graphql b/graphql/schema/types/distro.graphql index 59409b6bb46..43bc2455b56 100644 --- a/graphql/schema/types/distro.graphql +++ b/graphql/schema/types/distro.graphql @@ -124,6 +124,7 @@ input DistroInput { disabled: Boolean! disableShallowClone: Boolean! dispatcherSettings: DispatcherSettingsInput! + execUser: String expansions: [ExpansionInput!]! finderSettings: FinderSettingsInput! homeVolumeSettings: HomeVolumeSettingsInput! @@ -275,6 +276,7 @@ type Distro { disabled: Boolean! disableShallowClone: Boolean! dispatcherSettings: DispatcherSettings! + execUser: String! expansions: [Expansion!]! finderSettings: FinderSettings! homeVolumeSettings: HomeVolumeSettings! diff --git a/graphql/tests/query/distro/data.json b/graphql/tests/query/distro/data.json new file mode 100644 index 00000000000..c810951017a --- /dev/null +++ b/graphql/tests/query/distro/data.json @@ -0,0 +1,103 @@ +{ + "distro": [ + { + "_id": "rhel71-power8-large", + "aliases": ["rhel71-power8", "rhel71-power8-build"], + "arch": "linux_ppc64le", + "work_dir": "/data/mci", + "provider": "static", + "provider_settings": [ + { + "hosts": [ + { + "name": "rhel71-ppc-1.pic.build.10gen.cc" + }, + { + "name": "rhel71-ppc-4.pic.build.10gen.cc" + } + ] + } + ], + "user": "mci-exec", + "bootstrap_settings": { + "method": "legacy-ssh", + "communication": "legacy-ssh", + "client_dir": "/home/mci-exec/evergreen_provisioning", + "jasper_binary_dir": "/home/mci-exec/evergreen_provisioning", + "jasper_credentials_path": "/home/mci-exec/evergreen_provisioning/jasper_credentials.json", + "shell_path": "/bin/bash", + "resource_limits": { + "num_files": 64000, + "num_processes": -1, + "locked_memory": -1, + "virtual_memory": -1 + } + }, + "clone_method": "legacy-ssh", + "ssh_options": [ + "StrictHostKeyChecking=no", + "BatchMode=yes", + "ConnectTimeout=10" + ], + "spawn_allowed": true, + "expansions": [ + { + "key": "decompress", + "value": "tar xzvf" + }, + { + "key": "ps", + "value": "ps aux" + }, + { + "key": "kill_pid", + "value": "kill -- -$(ps opgid= %v)" + } + ], + "finder_settings": { + "version": "legacy" + }, + "planner_settings": { + "version": "tunable", + "target_time": { + "$numberLong": "0" + }, + "group_versions": false, + "patch_zipper_factor": { + "$numberLong": "0" + }, + "patch_time_in_queue_factor": { + "$numberLong": "0" + }, + "commit_queue_factor": { + "$numberLong": "0" + }, + "mainline_time_in_queue_factor": { + "$numberLong": "0" + }, + "expected_runtime_factor": { + "$numberLong": "0" + } + }, + "dispatcher_settings": { + "version": "revised-with-dependencies" + }, + "host_allocator_settings": { + "version": "utilization", + "minimum_hosts": 0, + "maximum_hosts": 0, + "acceptable_host_idle_time": { + "$numberLong": "0" + } + }, + "disable_shallow_clone": false, + "note": "", + "is_virtual_workstation": false, + "is_cluster": false, + "home_volume_settings": { + "format_command": "" + }, + "icecream_settings": {} + } + ] +} diff --git a/graphql/tests/query/distros/queries/distro.graphql b/graphql/tests/query/distro/queries/distro.graphql similarity index 95% rename from graphql/tests/query/distros/queries/distro.graphql rename to graphql/tests/query/distro/queries/distro.graphql index 8a6550b5dea..52e6b902246 100644 --- a/graphql/tests/query/distros/queries/distro.graphql +++ b/graphql/tests/query/distro/queries/distro.graphql @@ -8,6 +8,7 @@ query { numProcesses } } + execUser name plannerSettings { mainlineTimeInQueueFactor diff --git a/graphql/tests/query/distro/results.json b/graphql/tests/query/distro/results.json new file mode 100644 index 00000000000..06133dc9f26 --- /dev/null +++ b/graphql/tests/query/distro/results.json @@ -0,0 +1,40 @@ +{ + "tests": [ + { + "query_file": "distro.graphql", + "result": { + "data": { + "distro": { + "adminOnly": false, + "bootstrapSettings": { + "communication": "LEGACY_SSH", + "resourceLimits": { + "numFiles": 64000, + "numProcesses": -1 + } + }, + "execUser": "", + "name": "rhel71-power8-large", + "plannerSettings": { + "mainlineTimeInQueueFactor": 0 + }, + "provider": "STATIC", + "providerSettingsList": [ + { + "hosts": [ + { + "name": "rhel71-ppc-1.pic.build.10gen.cc" + }, + { + "name": "rhel71-ppc-4.pic.build.10gen.cc" + } + ] + } + ], + "user": "mci-exec" + } + } + } + } + ] +} diff --git a/graphql/tests/query/distros/results.json b/graphql/tests/query/distros/results.json index b1646cc1d2d..a010b17e206 100644 --- a/graphql/tests/query/distros/results.json +++ b/graphql/tests/query/distros/results.json @@ -1,75 +1,40 @@ { - "tests": [ - { - "query_file": "distro.graphql", - "result": { - "data": { - "distro": { - "adminOnly": false, - "bootstrapSettings": { - "communication": "LEGACY_SSH", - "resourceLimits": { - "numFiles": 64000, - "numProcesses": -1 - } - }, - "name": "rhel71-power8-large", - "plannerSettings": { - "mainlineTimeInQueueFactor": 0 - }, - "provider": "STATIC", - "providerSettingsList": [ - { - "hosts": [ - { - "name": "rhel71-ppc-1.pic.build.10gen.cc" - }, - { - "name": "rhel71-ppc-4.pic.build.10gen.cc" - } - ] - } - ], - "user": "mci-exec" - } - } + "tests": [ + { + "query_file": "distros.graphql", + "result": { + "data": { + "distros": [ + { + "name": "localhost" + }, + { + "name": "localhost2" + }, + { + "name": "rhel71-power8-large" + }, + { + "name": "windows-64-vs2015-small" } - }, - { - "query_file": "distros.graphql", - "result": { - "data": { - "distros": [ - { - "name": "localhost" - }, - { - "name": "localhost2" - }, - { - "name": "rhel71-power8-large" - }, - { - "name": "windows-64-vs2015-small" - } - ] - } - } - }, - { - "query_file": "spawnable_distros.graphql", - "result": { - "data": { - "distros": [ - { - "name": "rhel71-power8-large" - }, - { - "name": "windows-64-vs2015-small" - } - ] - } + ] + } + } + }, + { + "query_file": "spawnable_distros.graphql", + "result": { + "data": { + "distros": [ + { + "name": "rhel71-power8-large" + }, + { + "name": "windows-64-vs2015-small" } + ] } - ] + } + } + ] }