Module: PDQTest::Pdk

Defined in:
lib/pdqtest/pdk.rb

Overview

the main purpose of this is to add emoji after running a PDK lifecycle.. There is basically no other way to do this mega-hack. while ‘pdk` itself is a kind of selective wrapper around ruby, I couldn’t get calling ‘pdk` from inside `pdk bundle` to work, nor could I figure out how to load the PDK libraries from the “inside”

Constant Summary collapse

SYNC_YML =
'.sync.yml'
PDK_TAGS =

Copy these values from PDK generated metadata to module metadata

[
  "pdk-version",
  "template-url",
  "template-ref",
]
PDK_VERSION_TAG =

Golden metadata key which proves PDK is already installed

"pdk-version"

Class Method Summary collapse

Class Method Details

.amend_sync_yml(data) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/pdqtest/pdk.rb', line 59

def self.amend_sync_yml(data)
  if File.exist? SYNC_YML
    sync = YAML.load_file(SYNC_YML)

    # PDQTest < 2.0.4 mistakenly dropped an array into
    # .sync.yml[.gitattributes][include] that will crash PDK on upgrade
    # nuke this key on sight to fix
    if sync.dig(".gitattributes", "include").is_a? Array
      sync[".gitattributes"].delete("include")
    end
  else
    sync = {}
  end
  sync.deep_merge!(data)
  $logger.info("Updated .sync.yml with #{data}")

  File.open(SYNC_YML, 'w') { |f| YAML.dump(sync, f) }
end

.enable_pdk(pdk_metadata) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/pdqtest/pdk.rb', line 43

def self.enable_pdk()
  if ! is_pdk_enabled
    $logger.info("enabling PDK in metadata.json")
     = Puppet.

    PDK_TAGS.each do |pdk_tag|
      [pdk_tag] = [pdk_tag]
    end
    PDQTest::Puppet.()
  end
end

.is_pdk_enabledObject



55
56
57
# File 'lib/pdqtest/pdk.rb', line 55

def self.is_pdk_enabled
  Puppet..include?(PDK_VERSION_TAG)
end

.run(subcommand) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pdqtest/pdk.rb', line 24

def self.run(subcommand)
  if Util.is_windows
    pdk = "powershell -command \"pdk #{subcommand}\" ; exit $LastExitCode"
  else
    pdk = "pdk #{subcommand}"
  end

  # write a .fixtures.yml for PDK test commands
  if subcommand =~ /test/
    PDQTest::Puppet.fixtures_yml
  end

  # our environment is heavly contaminated by bundler and maybe RVM too
  status = system(Util.clean_env, pdk, unsetenv_others: true)

  PDQTest::Emoji.partial_status(status, subcommand)
  status
end