Class: Abt::Providers::Devops::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/abt/providers/devops/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli:) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
# File 'lib/abt/providers/devops/configuration.rb', line 9

def initialize(cli:)
  @cli = cli
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli.



7
8
9
# File 'lib/abt/providers/devops/configuration.rb', line 7

def cli
  @cli
end

Instance Method Details

#access_token_for_organization(organization_name) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/abt/providers/devops/configuration.rb', line 45

def access_token_for_organization(organization_name)
  access_token_key = "organizations.#{organization_name}.accessToken"

  return git_global[access_token_key] unless git_global[access_token_key].nil?

  git_global[access_token_key] = cli.prompt.text(<<~TXT)
    Please provide your personal access token for the DevOps organization (#{organization_name}).
    If you don't have one, follow the guide here: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate

    The token MUST have "Read" permission for Work Items
    Future features will likely require "Write" or "Manage

    Enter access token"
  TXT
end

#clear_global(verbose: true) ⇒ Object



29
30
31
# File 'lib/abt/providers/devops/configuration.rb', line 29

def clear_global(verbose: true)
  git_global.clear(output: verbose ? cli.err_output : nil)
end

#clear_local(verbose: true) ⇒ Object



25
26
27
# File 'lib/abt/providers/devops/configuration.rb', line 25

def clear_local(verbose: true)
  git.clear(output: verbose ? cli.err_output : nil)
end

#local_available?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/abt/providers/devops/configuration.rb', line 13

def local_available?
  git.available?
end

#pathObject



17
18
19
# File 'lib/abt/providers/devops/configuration.rb', line 17

def path
  Path.new((local_available? && git["path"]) || cli.directory_config.dig("devops", "path") || "")
end

#path=(new_path) ⇒ Object



21
22
23
# File 'lib/abt/providers/devops/configuration.rb', line 21

def path=(new_path)
  git["path"] = new_path
end

#username_for_organization(organization_name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/abt/providers/devops/configuration.rb', line 33

def username_for_organization(organization_name)
  username_key = "organizations.#{organization_name}.username"

  return git_global[username_key] unless git_global[username_key].nil?

  git_global[username_key] = cli.prompt.text([
    "Please provide your username for the DevOps organization (#{organization_name}).",
    "",
    "Enter username"
  ].join("\n"))
end