Sha256: b5e56dc87d0a0ac77c1183c92391f68f35c8ad60838de8bd7e719403d154fe1b

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

class Helmsnap::Generate < Helmsnap::Service
  def initialize(config, snapshots_path: nil)
    super()
    self.config = config
    self.snapshots_path = snapshots_path || config.snapshots_path
  end

  def call
    Helmsnap::SetupDependencies.call(config)

    FileUtils.rmtree(snapshots_path)

    config.envs.each do |env|
      run_cmd(
        "helmfile",
        "--environment",
        env.name,
        "template",
        "--output-dir-template",
        snapshots_path.join(env.name).join("{{ .Release.Name }}"),
        "--skip-deps",
      )
    end

    snapshots_path.glob(["**/*yaml", "**/*.yml"]).each do |path|
      content = path.read
      content.gsub!(/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d+/, "2022-01-01 00:00:00.000")
      content.gsub!(/\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d/, "2022-01-01-00-00-00")
      content.gsub!(/\d\d\d\d-\d\d-\d\d-\d\d-\d\d/, "2022-01-01-00-00")
      path.write(content)
    end
  end

  private

  attr_accessor :config, :snapshots_path
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
helmsnap-1.1.0 lib/helmsnap/generate.rb
helmsnap-1.0.2 lib/helmsnap/generate.rb
helmsnap-1.0.1 lib/helmsnap/generate.rb
helmsnap-1.0.0 lib/helmsnap/generate.rb