(checks, since, to, write)
Update integration CHANGELOG.md by adding the Agent version.

    Agent version is only added to the integration versions released with a specific Agent release.
Update integration CHANGELOG.md by adding the Agent version.
Update integration CHANGELOG . md by adding the Agent version .
def integrations_changelog(checks, since, to, write):
    """
    Update integration CHANGELOG.md by adding the Agent version.

    Agent version is only added to the integration versions released with a specific Agent release.
    """

    # Process all checks if no check is passed
    if not checks:
        checks = get_valid_checks()

    changes_per_agent = get_changes_per_agent(since, to)

    integrations_versions = defaultdict(dict)
    for agent_version, version_changes in changes_per_agent.items():
        for name, (ver, _) in version_changes.items():
            if name not in checks:
                continue
            integrations_versions[name][ver] = agent_version

    for check, versions in iteritems(integrations_versions):
        changelog_contents = StringIO()
        changelog_file = get_integration_changelog(check)

        for line in read_file_lines(changelog_file):
            match = re.search(INTEGRATION_CHANGELOG_PATTERN, line)
            if match:
                version = match.groups()[0]
                if version in versions:
                    agent_version = versions[version]
                    line = "{} / Agent {}\n".format(line.strip(), agent_version)
                else:
                    echo_debug("Agent version not found for integration {} line {}".format(check, line.strip()))
            changelog_contents.write(line)

        # Save the changelog on disk if --write was passed
        if write:
            echo_info("Writing to {}".format(changelog_file))
            write_file(changelog_file, changelog_contents.getvalue())
        else:
            echo_info(changelog_contents.getvalue())
def integrations_changelog ( checks , since , to , write ) : # Process all checks if no check is passed if not checks : checks = get_valid_checks ( ) changes_per_agent = get_changes_per_agent ( since , to ) integrations_versions = defaultdict ( dict ) for agent_version , version_changes in changes_per_agent . items ( ) : for name , ( ver , _ ) in version_changes . items ( ) : if name not in checks : continue integrations_versions [ name ] [ ver ] = agent_version for check , versions in iteritems ( integrations_versions ) : changelog_contents = StringIO ( ) changelog_file = get_integration_changelog ( check ) for line in read_file_lines ( changelog_file ) : match = re . search ( INTEGRATION_CHANGELOG_PATTERN , line ) if match : version = match . groups ( ) [ 0 ] if version in versions : agent_version = versions [ version ] line = "{} / Agent {}\n" . format ( line . strip ( ) , agent_version ) else : echo_debug ( "Agent version not found for integration {} line {}" . format ( check , line . strip ( ) ) ) changelog_contents . write ( line ) # Save the changelog on disk if --write was passed if write : echo_info ( "Writing to {}" . format ( changelog_file ) ) write_file ( changelog_file , changelog_contents . getvalue ( ) ) else : echo_info ( changelog_contents . getvalue ( ) )