Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DockerParser

Parser for Dockerfiles

This class implements Dockerfile parsing. It extracts meta-data defined in a Dockerfile using the LABEL or deprecated MAINTAINER instructions. Unlike the other parsers in Dockta it does not attempt to parse out dependencies.

Here "label" refers to a key in a LABEL instruction that is un-prefixed or has either the org.opencontainers.image prefix, or the deprecated org.label-schema prefix. In other words, the following are all equivalent:

LABEL version = 1.2.0
LABEL org.opencontainers.image.version = 1.2.0
LABEL org.label-schema.version = 1.2.0

The following schema crosswalk defines how labels in Dockerfiles are translated into JSON-LD properties

Label Property (context:type.property)
authors schema:CreativeWork.author
build
created schema:SoftwareSourceCode.dateCreated
description schema:Thing.description
documentation schema:softwareHelp
licenses schema:CreativeWork.license
maintainer codemeta:SoftwareSourceCode.maintainer
ref-name
revision
schema-version schema:schemaVersion
source schema:SoftwareSourceCode.codeRepository
title schema:Thing.name
url schema:Thing.url
vendor schema:Organization.legalName
version schema:SoftwareApplication.softwareVersion

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

folder

folder: string

The directory to scan for relevant files

Protected Readonly urlFetcher

urlFetcher: UrlFetcher

The instance of IUrlFetcher to fetch URLs

Methods

exists

  • exists(subpath: string): boolean
  • Does a path exist within the project folder?

    Parameters

    • subpath: string

      The path within the folder

    Returns boolean

fetch

  • fetch(url: string, options?: any): Promise<any>
  • Fetch content from a URL

    Parameters

    • url: string

      The URL to fetch

    • Default value options: any = { responseType: 'json' }

      Request options

    Returns Promise<any>

glob

  • glob(pattern: string | Array<string>): Array<string>
  • Get a list of paths that match a pattern in the project folder.

    Parameters

    • pattern: string | Array<string>

      The glob pattern

    Returns Array<string>

parse

  • parse(content?: undefined | string): Promise<SoftwareEnvironment | null>
  • Parse a folder by detecting any Dockerfile and return a SoftwareEnvironment instance

    Parameters

    • Optional content: undefined | string

    Returns Promise<SoftwareEnvironment | null>

read

  • read(subpath: string): string
  • Read a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    Returns string

write

  • write(subpath: string, content: string): void
  • Write to a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    • content: string

      The content to write to the file

    Returns void

Generated using TypeDoc