files/aerobase-cookbooks/aerobase/libraries/unifiedpush.rb
def parse_database_settings
      # If the user wants to run the internal Postgres service using an alternative
      # DB username, host or port, then those settings should also be applied to
      # unifiedpush.
	  
      # Use either mssql mysql or postgresql props
      db_adapter =  Unifiedpush['aerobase_server']['db_adapter']
      if db_adapter.nil?
        # Use default if no override was specified
        db_adapter =  node['unifiedpush']['aerobase-server']['db_adapter']
      end
      [
        # %w{keycloak_server db_username} corresponds to
        # Unifiedpush['keycloak_server']['db_username'], etc.
        # sql_kc_user is defined only in postgresql section.
        [%w{keycloak_server db_username}, %w{postgresql sql_kc_user}],
        [%w{keycloak_server db_host}, %W{#{db_adapter} server}],
        [%w{keycloak_server db_port}, %W{#{db_adapter} port}]
      ].each do |left, right|
        if ! Unifiedpush[left.first][left.last].nil?
          # If the user explicitly sets a value for e.g.
          # unifiedpush['db_port'] in unifiedpush.rb then we should never override
          # that.
          next
        end
		
        better_value_from_unifiedpush_rb = Unifiedpush[right.first][right.last]
        default_from_attributes = node['unifiedpush'][right.first.gsub('_', '-')][right.last]
        Unifiedpush[left.first][left.last] = better_value_from_unifiedpush_rb || default_from_attributes
      end
    end
# guards against creating secrets on non-bootstrap node
guards against creating secrets on non-bootstrap node
guards against creating secrets on non - bootstrap node
def parse_database_settings
      db_adapter =  Unifiedpush['aerobase_server']['db_adapter']
      if db_adapter.nil?
        db_adapter =  node['unifiedpush']['aerobase-server']['db_adapter']
      end
      [
        [%w{keycloak_server db_username}, %w{postgresql sql_kc_user}],
        [%w{keycloak_server db_host}, %W{#{db_adapter} server}],
        [%w{keycloak_server db_port}, %W{#{db_adapter} port}]
      ].each do |left, right|
        if ! Unifiedpush[left.first][left.last].nil?
          next
        end
        better_value_from_unifiedpush_rb = Unifiedpush[right.first][right.last]
        default_from_attributes = node['unifiedpush'][right.first.gsub('_', '-')][right.last]
        Unifiedpush[left.first][left.last] = better_value_from_unifiedpush_rb || default_from_attributes
      end
    end
def parse_database_settings db_adapter = Unifiedpush [ 'aerobase_server' ] [ 'db_adapter' ] if db_adapter . nil? db_adapter = node [ 'unifiedpush' ] [ 'aerobase-server' ] [ 'db_adapter' ] end [ [ %w{ keycloak_server db_username } , %w{ postgresql sql_kc_user } ] , [ %w{ keycloak_server db_host } , %W{ #{ db_adapter } server } ] , [ %w{ keycloak_server db_port } , %W{ #{ db_adapter } port } ] ] . each do | left , right | if ! Unifiedpush [ left . first ] [ left . last ] . nil? next end better_value_from_unifiedpush_rb = Unifiedpush [ right . first ] [ right . last ] default_from_attributes = node [ 'unifiedpush' ] [ right . first . gsub ( '_' , '-' ) ] [ right . last ] Unifiedpush [ left . first ] [ left . last ] = better_value_from_unifiedpush_rb || default_from_attributes end end
guards against creating secrets on non-bootstrap node
guards against creating secrets on non - bootstrap node
# If the user wants to run the internal Postgres service using an alternative # DB username, host or port, then those settings should also be applied to # unifiedpush. # Use either mssql mysql or postgresql props # Use default if no override was specified # %w{keycloak_server db_username} corresponds to # Unifiedpush['keycloak_server']['db_username'], etc. # sql_kc_user is defined only in postgresql section. # If the user explicitly sets a value for e.g. # unifiedpush['db_port'] in unifiedpush.rb then we should never override # that.