lib/topological_inventory/orchestrator/config_map.rb
def upsert_one!(source)
        raise "Missing openshift object" if openshift_object.nil?

        custom_yml_data = custom_yml_content

        # Update Source
        logger.debug("UpdateOne: YAML: #{custom_yml_data[:sources]} | Source: #{source}")
        found = (idx = custom_yml_data[:sources].index { |yaml_source| yaml_source[:source] == source['uid'] }).present?

        new_digest = source.digest(:reload => true)
        if found
          old_digest = custom_yml_data[:sources][idx][:digest]
          custom_yml_data[:sources][idx] = source_to_yaml(source)
        else
          custom_yml_data[:sources] << source_to_yaml(source)
        end

        # Update Digests
        digests.delete(old_digest) if found
        digests << new_digest

        # Update Time
        custom_yml_data[:updated_at] = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S")

        save_config_map(digests.to_json, custom_yml_data.to_yaml)

        # Update Secret
        secret&.upsert_one!(source)
      end
# Insert or update for targeted update
# @param source [Orchestrator::Source]
Insert or update for targeted update
Insert or update for targeted update
def upsert_one!(source)
        raise "Missing openshift object" if openshift_object.nil?
        custom_yml_data = custom_yml_content
        logger.debug("UpdateOne: YAML: #{custom_yml_data[:sources]} | Source: #{source}")
        found = (idx = custom_yml_data[:sources].index { |yaml_source| yaml_source[:source] == source['uid'] }).present?
        new_digest = source.digest(:reload => true)
        if found
          old_digest = custom_yml_data[:sources][idx][:digest]
          custom_yml_data[:sources][idx] = source_to_yaml(source)
        else
          custom_yml_data[:sources] << source_to_yaml(source)
        end
        digests.delete(old_digest) if found
        digests << new_digest
        custom_yml_data[:updated_at] = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S")
        save_config_map(digests.to_json, custom_yml_data.to_yaml)
        secret&.upsert_one!(source)
      end
def upsert_one! ( source ) raise "Missing openshift object" if openshift_object . nil? custom_yml_data = custom_yml_content logger . debug ( "UpdateOne: YAML: #{custom_yml_data[:sources]} | Source: #{source}" ) found = ( idx = custom_yml_data [ :sources ] . index { | yaml_source | yaml_source [ :source ] == source [ 'uid' ] } ) . present? new_digest = source . digest ( :reload => true ) if found old_digest = custom_yml_data [ :sources ] [ idx ] [ :digest ] custom_yml_data [ :sources ] [ idx ] = source_to_yaml ( source ) else custom_yml_data [ :sources ] << source_to_yaml ( source ) end digests . delete ( old_digest ) if found digests << new_digest custom_yml_data [ :updated_at ] = Time . now . utc . strftime ( "%Y-%m-%d %H:%M:%S" ) save_config_map ( digests . to_json , custom_yml_data . to_yaml ) secret &. upsert_one! ( source ) end
Insert or update for targeted update
Insert or update for targeted update
# Update Source # Update Digests # Update Time # Update Secret
source
None