Class: Gojira::APIOps::Validations

Inherits:
Object
  • Object
show all
Defined in:
lib/gojira/apiops/validations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gateway_folder, env_dir, cluster_file) ⇒ Validations

Returns a new instance of Validations.



9
10
11
12
13
14
# File 'lib/gojira/apiops/validations.rb', line 9

def initialize(gateway_folder, env_dir, cluster_file)
  @gateway_folder = gateway_folder
  @env_dir = env_dir
  @cluster_file = cluster_file
  @errors = []
end

Instance Attribute Details

#cluster_fileObject (readonly)

Returns the value of attribute cluster_file.



7
8
9
# File 'lib/gojira/apiops/validations.rb', line 7

def cluster_file
  @cluster_file
end

#env_dirObject (readonly)

Returns the value of attribute env_dir.



7
8
9
# File 'lib/gojira/apiops/validations.rb', line 7

def env_dir
  @env_dir
end

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/gojira/apiops/validations.rb', line 6

def errors
  @errors
end

#gateway_folderObject (readonly)

Returns the value of attribute gateway_folder.



7
8
9
# File 'lib/gojira/apiops/validations.rb', line 7

def gateway_folder
  @gateway_folder
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
# File 'lib/gojira/apiops/validations.rb', line 16

def execute
  validate_env
  validate_cluster_file
  validate_env_dir
  validate_service
  validate_upstreams
end

#validate_cluster_fileObject



29
30
31
# File 'lib/gojira/apiops/validations.rb', line 29

def validate_cluster_file
  # Check if all env have defined DCs and each DC have pci and npci control planes
end

#validate_envObject



24
25
26
27
# File 'lib/gojira/apiops/validations.rb', line 24

def validate_env
  Dir.open(@gateway_folder + @env_dir)
  # Check env name if is allowed
end

#validate_env_dirObject



33
34
35
36
37
38
# File 'lib/gojira/apiops/validations.rb', line 33

def validate_env_dir
  # check the structure of the env dir:
    # product_group -> one or more services
    # product_group has a valid upstreams file
  # figure out if any unknown files are present
end

#validate_service(service_file) ⇒ Object



40
41
42
43
44
45
# File 'lib/gojira/apiops/validations.rb', line 40

def validate_service(service_file)
  # Check if only one service is defined per file
  # Check if the correct pci/non-pci tag is present on the service
  # Check if routes don't have tags
  # Check if 
end

#validate_upstreams(upstreams_file) ⇒ Object



47
48
49
50
51
# File 'lib/gojira/apiops/validations.rb', line 47

def validate_upstreams(upstreams_file)
  # Check if upstreams for all services in the product_group is present or not
  # Check if both pci and non-pci upstreams for a service are defined
  # Check if all targets of a given upstream add up to 100
end