Module: Conify::Manifest

Extended by:
Helpers, Manifest
Included in:
Manifest
Defined in:
lib/conify/manifest.rb

Instance Method Summary collapse

Methods included from Helpers

allow_user_response, ask_for_conflux_creds, ask_for_password, ask_for_password_on_windows, camelize, display, echo_off, echo_on, error, exclusive_deep_merge, format_with_bang, host, host_url, kensa_manifest_name, kensa_manifest_path, manifest_content, manifest_filename, manifest_path, manually_added_methods, open_url, running_on_a_mac?, running_on_windows?, site_url, to_table, with_tty

Instance Method Details

#conflux_templateObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/conify/manifest.rb', line 34

def conflux_template
  "{\n  \"id\": \"myservice\",\n  \"api\": {\n\"config_vars\": [\n  \"MYSERVICE_URL\"\n],\n\"password\": \"\",\n\"sso_salt\": \"\",\n\"production\": {\n  \"base_url\": \"https://yourapp.com/conflux/resources\",\n  \"sso_url\": \"https://yourapp.com/conflux/sso\"\n},\n\"test\": {\n  \"base_url\": \"http://localhost:\#{default_port}/conflux/resources\",\n  \"sso_url\": \"http://localhost:\#{default_port}/conflux/sso\"\n}\n  }\n}\n  JSON\nend\n"

#default_portObject



13
14
15
# File 'lib/conify/manifest.rb', line 13

def default_port
  3000
end

#password_gen(size = 8) ⇒ Object



9
10
11
# File 'lib/conify/manifest.rb', line 9

def password_gen(size = 8)
  SecureRandom.hex(size)
end

#templateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/conify/manifest.rb', line 17

def template
  # Use conflux template as default
  manifest = JSON.parse(conflux_template)

  # If the kensa manifest exists, return the exclusively merged two manifests.
  if File.exists?(kensa_manifest_name)
    kensa_manifest = JSON.parse(File.read(kensa_manifest_path)) rescue {}
    manifest = exclusive_deep_merge(manifest, kensa_manifest)
  end

  # Don't copy over password or sso_salt, so just set them now:
  manifest['api']['password'] = password_gen
  manifest['api']['sso_salt'] = password_gen

  JSON.pretty_generate(manifest)
end