diff options
Diffstat (limited to 'app/graphql/types/ci')
-rw-r--r-- | app/graphql/types/ci/ci_cd_setting_type.rb | 5 | ||||
-rw-r--r-- | app/graphql/types/ci/code_quality_report_summary_type.rb | 20 | ||||
-rw-r--r-- | app/graphql/types/ci/job_token_scope/direction_enum.rb | 21 | ||||
-rw-r--r-- | app/graphql/types/ci/job_token_scope_type.rb | 18 | ||||
-rw-r--r-- | app/graphql/types/ci/job_type.rb | 4 | ||||
-rw-r--r-- | app/graphql/types/ci/pipeline_type.rb | 4 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_type.rb | 15 | ||||
-rw-r--r-- | app/graphql/types/ci/runner_upgrade_status_enum.rb | 12 | ||||
-rw-r--r-- | app/graphql/types/ci/variable_sort_enum.rb | 13 |
9 files changed, 105 insertions, 7 deletions
diff --git a/app/graphql/types/ci/ci_cd_setting_type.rb b/app/graphql/types/ci/ci_cd_setting_type.rb index 574791b79e6..dd6647b749d 100644 --- a/app/graphql/types/ci/ci_cd_setting_type.rb +++ b/app/graphql/types/ci/ci_cd_setting_type.rb @@ -30,6 +30,11 @@ module Types field :merge_trains_enabled, GraphQL::Types::Boolean, null: true, description: 'Whether merge trains are enabled.', method: :merge_trains_enabled? + field :opt_in_jwt, + GraphQL::Types::Boolean, + null: true, + description: 'When disabled, the JSON Web Token is always available in all jobs in the pipeline.', + method: :opt_in_jwt? field :project, Types::ProjectType, null: true, description: 'Project the CI/CD settings belong to.' end diff --git a/app/graphql/types/ci/code_quality_report_summary_type.rb b/app/graphql/types/ci/code_quality_report_summary_type.rb new file mode 100644 index 00000000000..0d560d9e9e8 --- /dev/null +++ b/app/graphql/types/ci/code_quality_report_summary_type.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Types + module Ci + # rubocop: disable Graphql/AuthorizeTypes + # This is presented through `PipelineType` that has its own authorization + class CodeQualityReportSummaryType < BaseObject + graphql_name 'CodeQualityReportSummary' + description 'Code Quality report for a pipeline' + + field :count, GraphQL::Types::Int, null: true, + description: 'Total number of Code Quality reports.' + ::Gitlab::Ci::Reports::CodequalityReports::SEVERITY_PRIORITIES.each_key do |status| + field status, GraphQL::Types::Int, null: true, + description: "Total number of #{status} status." + end + end + # rubocop: enable Graphql/AuthorizeTypes + end +end diff --git a/app/graphql/types/ci/job_token_scope/direction_enum.rb b/app/graphql/types/ci/job_token_scope/direction_enum.rb new file mode 100644 index 00000000000..f52cf891af8 --- /dev/null +++ b/app/graphql/types/ci/job_token_scope/direction_enum.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Types + module Ci + module JobTokenScope + class DirectionEnum < BaseEnum + graphql_name 'CiJobTokenScopeDirection' + description 'Direction of access.' + + value 'OUTBOUND', + value: :outbound, + description: 'Job token scope project can access target project in the outbound allowlist.' + + value 'INBOUND', + value: :inbound, + description: 'Target projects in the inbound allowlist can access the scope project ' \ + 'through their job tokens.' + end + end + end +end diff --git a/app/graphql/types/ci/job_token_scope_type.rb b/app/graphql/types/ci/job_token_scope_type.rb index 37c0af944a7..639bbaa22af 100644 --- a/app/graphql/types/ci/job_token_scope_type.rb +++ b/app/graphql/types/ci/job_token_scope_type.rb @@ -11,7 +11,23 @@ module Types Types::ProjectType.connection_type, null: false, description: 'Allow list of projects that can be accessed by CI Job tokens created by this project.', - method: :all_projects + method: :outbound_projects, + deprecated: { + reason: 'The `projects` attribute is being deprecated. Use `outbound_allowlist`', + milestone: '15.9' + } + + field :outbound_allowlist, + Types::ProjectType.connection_type, + null: false, + description: "Allow list of projects that are accessible using the current project's CI Job tokens.", + method: :outbound_projects + + field :inbound_allowlist, + Types::ProjectType.connection_type, + null: false, + description: "Allow list of projects that can access the current project through its CI Job tokens.", + method: :inbound_projects end end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index 4447a10a74e..a97e9cee4b1 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -37,6 +37,8 @@ module Types # Life-cycle timestamps: field :created_at, Types::TimeType, null: false, description: "When the job was created." + field :erased_at, Types::TimeType, null: true, + description: "When the job was erased." field :finished_at, Types::TimeType, null: true, description: 'When a job has finished running.' field :queued_at, Types::TimeType, null: true, @@ -97,6 +99,8 @@ module Types field :web_path, GraphQL::Types::String, null: true, description: 'Web path of the job.' + field :project, Types::ProjectType, null: true, description: 'Project that the job belongs to.' + def kind return ::Ci::Build unless [::Ci::Build, ::Ci::Bridge].include?(object.class) diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index cb561f48b3b..19d261853a7 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -178,6 +178,10 @@ module Types field :merge_request_event_type, Types::Ci::PipelineMergeRequestEventTypeEnum, null: true, description: "Event type of the pipeline associated with a merge request." + def commit + BatchLoader::GraphQL.wrap(object.commit) + end + def detailed_status object.detailed_status(current_user) end diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb index 35339624e37..10d18f9ad2a 100644 --- a/app/graphql/types/ci/runner_type.rb +++ b/app/graphql/types/ci/runner_type.rb @@ -14,6 +14,9 @@ module Types JOB_COUNT_LIMIT = 1000 + # Only allow ephemeral_authentication_token to be visible for a short while + RUNNER_EPHEMERAL_TOKEN_AVAILABILITY_TIME = 3.hours + alias_method :runner, :object field :access_level, ::Types::Ci::RunnerAccessLevelEnum, null: false, @@ -35,6 +38,10 @@ module Types description: 'Description of the runner.' field :edit_admin_url, GraphQL::Types::String, null: true, description: 'Admin form URL of the runner. Only available for administrators.' + field :ephemeral_authentication_token, GraphQL::Types::String, null: true, + description: 'Ephemeral authentication token used for runner machine registration.', + authorize: :read_ephemeral_token, + alpha: { milestone: '15.9' } field :executor_name, GraphQL::Types::String, null: true, description: 'Executor last advertised by the runner.', method: :executor_name @@ -134,6 +141,14 @@ module Types Gitlab::Routing.url_helpers.edit_admin_runner_url(runner) if can_admin_runners? end + def ephemeral_authentication_token + return unless runner.authenticated_user_registration_type? + return unless runner.created_at > RUNNER_EPHEMERAL_TOKEN_AVAILABILITY_TIME.ago + return if runner.runner_machines.any? + + runner.token + end + def project_count BatchLoader::GraphQL.for(runner.id).batch(key: :runner_project_count) do |ids, loader, args| counts = ::Ci::Runner.project_type diff --git a/app/graphql/types/ci/runner_upgrade_status_enum.rb b/app/graphql/types/ci/runner_upgrade_status_enum.rb index 34a931c8f79..668970aaff2 100644 --- a/app/graphql/types/ci/runner_upgrade_status_enum.rb +++ b/app/graphql/types/ci/runner_upgrade_status_enum.rb @@ -5,13 +5,13 @@ module Types class RunnerUpgradeStatusEnum < BaseEnum graphql_name 'CiRunnerUpgradeStatus' + MODEL_STATUS_TO_GRAPHQL_TRANSLATIONS = { + invalid_version: :invalid, + unavailable: :not_available + }.freeze + ::Ci::RunnerVersion::STATUS_DESCRIPTIONS.each do |status, description| - status_name_src = - if status == :invalid_version - :invalid - else - status - end + status_name_src = MODEL_STATUS_TO_GRAPHQL_TRANSLATIONS.fetch(status, status) value status_name_src.to_s.upcase, description: description, value: status end diff --git a/app/graphql/types/ci/variable_sort_enum.rb b/app/graphql/types/ci/variable_sort_enum.rb new file mode 100644 index 00000000000..3a60899ab5d --- /dev/null +++ b/app/graphql/types/ci/variable_sort_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Types + module Ci + class VariableSortEnum < BaseEnum + graphql_name 'CiVariableSort' + description 'Values for sorting variables' + + value 'KEY_ASC', 'Sorted by key in ascending order.', value: :key_asc + value 'KEY_DESC', 'Sorted by key in descending order.', value: :key_desc + end + end +end |