npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hugojosefson/docker-git-inventory

v2.0.2

Published

Extract Docker Stack's running services' versions, pushing named refs to git repos

Downloads

77

Readme

docker-inventory-git

Build Status npm page License MIT SemVer 2.0.0 JavaScript Style Guide

Introduction

This is a library and a service for extracting information from a Docker Swarm about currently running services, and pushing custom named refs to git repos. That means you can see the deployment status from your Docker Swarm, in your development git tools.

Prerequisite

Node.js, v13.7.0 or higher, ideally at least v14.0.0.

Recommended to install latest via nvm:

nvm install stable

Usage

Get an inventory

npx --package @hugojosefson/docker-git-inventory docker-git-inventory

Start an HTTP API server

PORT=3000 \
npx --package @hugojosefson/docker-git-inventory docker-git-inventory-server

Push refs to git

The docker-git-inventory-push-refs command takes an inventory on stdin as JSON lines.

curl -s localhost:3000/inventory | \
  USERNAME=mygitusername \
  PASSWORD=mygitpassword \
  npx --package @hugojosefson/docker-git-inventory \
    docker-git-inventory-push-refs

Programmatic access

You can also import the module, and use its exported functions programmatically.

API

inventoryHandlers

pushRefsHandlers

defaultRemoteRef

Reasonable calculation of remoteRef, based on milieu, serviceName and git url.

Parameters
  • prefix string prefix for the remoteRef (optional, default 'refs/deployed/')

Returns (function ({milieu, serviceName, url}): string | undefined) function for calculating a reasonable remoteRef

defaultServiceToPush

Reasonable conversion from service (via inventory), to arguments to pushRef.

Parameters

Returns function ({serviceName: string, labels: {GIT_URL: (string | undefined), GIT_COMMIT: (string | undefined), milieu: (string | undefined)}}?): {ref: (string | undefined), url: (string | undefined), remoteRef: (string | undefined)}

inventory

Takes an inventory of currently running Docker stacks.

Returns Highland.Stream<{stack: string, taskId: string, image: string, serviceId: string, serviceNameLong: string, serviceName: string, labels: object}> A Highland stream of objects, each describing one service.

inventoryToPushes

Converts a Highland stream of inventory objects, into a stream of argument objects for pushRef.

Parameters
  • serviceToPush (function ({stack, taskId, image, serviceId, serviceName, serviceNameLong, labels}): Highland.Stream<{username, password, url, ref, remoteRef}> | Promise<{username, password, url, ref, remoteRef}> | Array<{username, password, url, ref, remoteRef}> | {username, password, url, ref, remoteRef})

Returns function (Highland.Stream<{stack, taskId, image, serviceId, serviceName, serviceNameLong, labels}>): Highland.Stream<{username, password, url, ref, remoteRef}>

app

HTTP API for working with docker-inventory-git.

Parameters
  • options object (optional, default {})

    • options.app (Express | Application | IRouter) Express.js Application instance or Router on which to apply paths. (optional, default express())

Returns (Express | Application | IRouter) app, mutated.

pushRef

Pushes a git commit to its repo, with a specific remoteRef.

Parameters
  • options object

    • options.username string username for git authentication
    • options.password string password for authentication
    • options.url string git repo url
    • options.ref string the commit to push
    • options.remoteRef string name of the remote ref, for example refs/deployed/stage

Returns Promise<void> resolves when done