Class: Kamal::Lint::Context

Inherits:
Struct
  • Object
show all
Defined in:
lib/kamal/lint/loader.rb

Overview

Holds all the data a check needs to inspect a single Kamal config: the parsed YAML, the source lines, helper to look up source lines for a given path (for finding line numbers), the destination override, the secrets file contents, and a flag indicating whether Kamal’s own loader rejected the config (in which case some checks are skipped to avoid cascading false positives).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_parsedObject

Returns the value of attribute base_parsed

Returns:

  • (Object)

    the current value of base_parsed



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def base_parsed
  @base_parsed
end

#config_fileObject

Returns the value of attribute config_file

Returns:

  • (Object)

    the current value of config_file



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def config_file
  @config_file
end

#destinationObject

Returns the value of attribute destination

Returns:

  • (Object)

    the current value of destination



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def destination
  @destination
end

#gitignore_pathObject

Returns the value of attribute gitignore_path

Returns:

  • (Object)

    the current value of gitignore_path



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def gitignore_path
  @gitignore_path
end

#kamal_load_errorObject

Returns the value of attribute kamal_load_error

Returns:

  • (Object)

    the current value of kamal_load_error



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def kamal_load_error
  @kamal_load_error
end

#kamal_loadedObject

Returns the value of attribute kamal_loaded

Returns:

  • (Object)

    the current value of kamal_loaded



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def kamal_loaded
  @kamal_loaded
end

#kamal_versionObject

Returns the value of attribute kamal_version

Returns:

  • (Object)

    the current value of kamal_version



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def kamal_version
  @kamal_version
end

#line_indexObject

Returns the value of attribute line_index

Returns:

  • (Object)

    the current value of line_index



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def line_index
  @line_index
end

#override_parsedObject

Returns the value of attribute override_parsed

Returns:

  • (Object)

    the current value of override_parsed



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def override_parsed
  @override_parsed
end

#parsedObject

Returns the value of attribute parsed

Returns:

  • (Object)

    the current value of parsed



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def parsed
  @parsed
end

#secretsObject

Returns the value of attribute secrets

Returns:

  • (Object)

    the current value of secrets



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def secrets
  @secrets
end

#secrets_pathObject

Returns the value of attribute secrets_path

Returns:

  • (Object)

    the current value of secrets_path



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def secrets_path
  @secrets_path
end

#source_linesObject

Returns the value of attribute source_lines

Returns:

  • (Object)

    the current value of source_lines



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def source_lines
  @source_lines
end

#working_dirObject

Returns the value of attribute working_dir

Returns:

  • (Object)

    the current value of working_dir



15
16
17
# File 'lib/kamal/lint/loader.rb', line 15

def working_dir
  @working_dir
end

Instance Method Details

#file_for_findingObject



32
33
34
35
36
37
# File 'lib/kamal/lint/loader.rb', line 32

def file_for_finding
  return config_file unless destination

  override_path = override_file
  File.exist?(override_path) ? override_path : config_file
end

#line_for(path) ⇒ Object



43
44
45
# File 'lib/kamal/lint/loader.rb', line 43

def line_for(path)
  line_index[Array(path).join(".")]
end

#override_fileObject



39
40
41
# File 'lib/kamal/lint/loader.rb', line 39

def override_file
  File.join(File.dirname(config_file), "deploy.#{destination}.yml")
end