Commit 96d1baa3 authored by Philip Cunningham's avatar Philip Cunningham Committed by Fabio Pitino

Reduce On-Demand CI YAML raw string size

Uses the DAST template to avoid storing whole CI YAML in the db.
parent c221a8e4
...@@ -11,15 +11,20 @@ module Ci ...@@ -11,15 +11,20 @@ module Ci
full_scan_enabled: 'DAST_FULL_SCAN_ENABLED' full_scan_enabled: 'DAST_FULL_SCAN_ENABLED'
}.freeze }.freeze
def self.ci_template_raw def self.ci_template
@ci_template_raw ||= Gitlab::Template::GitlabCiYmlTemplate.find('DAST').content @ci_template ||= YAML.safe_load(ci_template_raw)
end end
def self.ci_template def self.ci_template_raw
@ci_template ||= YAML.safe_load(ci_template_raw).tap do |template| <<~YAML
template['stages'] = ['dast'] include:
template['dast'].delete('rules') - template: DAST.gitlab-ci.yml
end stages:
- dast
dast:
rules:
- when: always
YAML
end end
def execute(branch:, **args) def execute(branch:, **args)
......
...@@ -24,8 +24,13 @@ RSpec.describe Ci::RunDastScanService do ...@@ -24,8 +24,13 @@ RSpec.describe Ci::RunDastScanService do
expect(described_class.ci_template['stages']).to eq(['dast']) expect(described_class.ci_template['stages']).to eq(['dast'])
end end
it 'has has no rules' do it 'has one rule is always true' do
expect(described_class.ci_template['dast']['rules']).to be_nil rules = described_class.ci_template['dast']['rules']
aggregate_failures do
expect(rules.size).to eq(1)
expect(rules).to include('when' => 'always')
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment