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

@codefresh-io/docker-reference

v0.0.11

Published

A node.js package to parse docker image reference

Downloads

25,377

Readme

Docker-Reference

A small package to parse and work with docker images references.

Getting started

To use docker-reference you should start with creating a Reference instance:

const { Reference } = require('@codefresh-io/docker-reference');

const imageReference = new Reference({
    domain: 'r.cfcr.io',
    repository: 'codefresh/demochat',
    tag: 'master',
    digest: 'sha256:58fe87ff24d5a3ac35c887dcef82eb619565987c1083282f876c7c2657a5f94e'
});

console.log(imageReference.repositoryUrl); // r.cfcr.io/codefresh/demochat
console.log(imageReference.toString()); // r.cfcr.io/codefresh/demochat:master@sha256:58fe87ff24d5a3ac35c887dcef82eb619565987c1083282f876c7c2657a5f94e

Using parsers

You can also use parser to create your Reference instance:

const { parseQualifiedName } = require('@codefresh-io/docker-reference');

const imageReference = parseQualifiedName('r.cfcr.io/codefresh/demochat:master@sha256:58fe87ff24d5a3ac35c887dcef82eb619565987c1083282f876c7c2657a5f94e');

console.log(imageReference.domain);     // r.cfcr.io
console.log(imageReference.repository); // codefresh/demochat
console.log(imageReference.tag);        // master
console.log(imageReference.digest);     // sha256:58fe87ff24d5a3ac35c887dcef82eb619565987c1083282f876c7c2657a5f94e

There are 3 parsers in the package:

  1. parseQualifiedName:

    This should be use when parsing a string representing a qualified image reference, meaning the string should contain at least the domain and the repository of the image.

  2. parseFamiliarName:

    This should be use when parsing a string representing a familiar image reference, meaning the string might not contains the domain part and this case the domain part would become docker.io. Also when the domain is missing and the repository contains only one part the repository would be prefixed with library/.

    This parser would parse all qualified image reference the same as parseQualifiedName parser

  3. parseAll:

    This should be use when parsing a string representing a familiar image reference or identifier.

    This parser would parse all qualified image reference the same as parseQualifiedName parser and parse every familiar image reference the same as parseFamiliarName

Grammer for the package

| | pattaren | | --- | --- | | reference | name [ ":" tag ] [ "@" digest ] | | name | [domain '/'] path-component ['/' path-component]* | | domain | domain-component ['.' domain-component]* [':' port-number] | | domain-component | /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/ | | port-number | /[0-9]+/ | | path-component | alpha-numeric [separator alpha-numeric]* | | alpha-numeric | /[a-z0-9]+/ | | separator | /[_.]|__|[-]*/ | | tag | /[\w][\w.-]{0,127}/ | | digest | digest-algorithm ":" digest-hex | | digest-algorithm | digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]* | | digest-algorithm-separator | /[+.-_]/ | | digest-algorithm-component | /[A-Za-z][A-Za-z0-9]*/ | | digest-hex | /[0-9a-fA-F]{32,}/ (At least 128 bit digest value) | | identifier | /[a-f0-9]{64}/ | | short-identifier | /[a-f0-9]{6,64}/ |