Class: Mutations::Ci::Lint

Inherits:
BaseMutation
  • Object
show all
Includes:
Gitlab::Graphql::Authorize::AuthorizeResource, ResolvesProject
Defined in:
app/graphql/mutations/ci/lint.rb

Constant Summary

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Instance Method Summary collapse

Methods included from ResolvesProject

#resolve_project

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #raise_resource_not_available_error!

Methods inherited from BaseMutation

#api_user?, authorization, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Instance Method Details

#resolve(project_path:, content:, ref: nil, dry_run: false) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/graphql/mutations/ci/lint.rb', line 36

def resolve(project_path:, content:, ref: nil, dry_run: false)
  project = authorized_find!(project_path: project_path)
  ref ||= project.default_branch

  result = ::Gitlab::Ci::Lint
    .new(project: project, current_user: context[:current_user])
    .validate(content, dry_run: dry_run, ref: ref)

  {
    config: response(result),
    errors: []
  }
rescue GRPC::InvalidArgument => e
  Gitlab::ErrorTracking.track_and_raise_exception(e, ref: ref)
end