UNPKG

5.2 kBTypeScriptView Raw
1import { Position, Range } from 'vscode-languageserver-types';
2export { Argument } from './argument';
3export { JSONArgument } from './jsonArgument';
4import { Comment } from './comment';
5export { Comment };
6export interface ImageTemplate {
7 getComments(): Comment[];
8 getInstructions(): Instruction[];
9 getARGs(): Arg[];
10 getCMDs(): Cmd[];
11 getCOPYs(): Copy[];
12 getENTRYPOINTs(): Entrypoint[];
13 getENVs(): Env[];
14 getFROMs(): From[];
15 getHEALTHCHECKs(): Healthcheck[];
16 getOnbuildTriggers(): Instruction[];
17 contains(position: Position): boolean;
18 /**
19 * Retrieves an array of variable names that are valid at the
20 * given line in the Dockerfile (zero-based). If the
21 * line is outside the range of the parsed Dockerfile, an empty
22 * array will be returned.
23 *
24 * @param line the interested line, zero-based
25 * @return the array of variables that may be used by an
26 * instruction at the specified line
27 */
28 getAvailableVariables(line: number): string[];
29 getRange(): Range | null;
30}
31export interface Dockerfile extends ImageTemplate {
32 getAvailableWorkingDirectories(line: number): string[];
33 getEscapeCharacter(): string;
34 getInitialARGs(): Arg[];
35 getComments(): Comment[];
36 /**
37 * Returns the set of instructions that include the given position.
38 *
39 * @param position the position to search in
40 * @return the set of instructions that the given position is in,
41 * or null if the position is invalid and is not contained
42 * within the Dockerfile
43 */
44 getContainingImage(position: Position): ImageTemplate | null;
45 /**
46 * @deprecated As of 0.0.18, replaced by getDirectives(). If there
47 * is more than one parser directive defined in the
48 * Dockerfile, the first one will be returned.
49 */
50 getDirective(): ParserDirective | null;
51 /**
52 * Retrieves the list of parser directives that have been defined
53 * in this Dockerfile. It will be in the order it was defined in
54 * the file with the first line of the file being the first
55 * directive in the returned array.
56 *
57 * @return the list of parser directives defined in this
58 * Dockerfile in the order they are defined
59 * @since 0.0.18
60 */
61 getDirectives(): ParserDirective[];
62 /**
63 * Resolves a variable with the given name at the specified line
64 * to its value. If null is returned, then the variable has been
65 * defined but no value was given. If undefined is returned, then
66 * a variable with the given name has not been defined yet as of
67 * the given line.
68 *
69 * @param variable the name of the variable to resolve
70 * @param line the line number that the variable is on, zero-based
71 * @return the value of the variable as defined by an ARG or ENV
72 * instruction, or null if no value has been specified, or
73 * undefined if a variable with the given name has not
74 * been defined or if the document does not contain the
75 * given line number
76 */
77 resolveVariable(variable: string, line: number): string | null | undefined;
78}
79export { Flag } from './flag';
80import { Instruction } from './instruction';
81export { Instruction };
82export { Line } from './line';
83import { ParserDirective } from './parserDirective';
84export { ParserDirective };
85export { Property } from './property';
86export { Variable } from './variable';
87export { Add } from './instructions/add';
88import { Arg } from './instructions/arg';
89export { Arg };
90import { Cmd } from './instructions/cmd';
91export { Cmd };
92import { Copy } from './instructions/copy';
93export { Copy };
94import { Entrypoint } from './instructions/entrypoint';
95export { Entrypoint };
96import { Env } from './instructions/env';
97export { Env };
98import { From } from './instructions/from';
99export { From };
100import { Healthcheck } from './instructions/healthcheck';
101export { Healthcheck };
102export { JSONInstruction } from './jsonInstruction';
103export { Label } from './instructions/label';
104export { ModifiableInstruction } from './modifiableInstruction';
105export { Onbuild } from './instructions/onbuild';
106export { PropertyInstruction } from './propertyInstruction';
107export { Shell } from './instructions/shell';
108export { Stopsignal } from './instructions/stopsignal';
109export { User } from './instructions/user';
110export { Volume } from './instructions/volume';
111import { Workdir } from './instructions/workdir';
112export { Workdir };
113export declare enum Keyword {
114 ADD = "ADD",
115 ARG = "ARG",
116 CMD = "CMD",
117 COPY = "COPY",
118 ENTRYPOINT = "ENTRYPOINT",
119 ENV = "ENV",
120 EXPOSE = "EXPOSE",
121 FROM = "FROM",
122 HEALTHCHECK = "HEALTHCHECK",
123 LABEL = "LABEL",
124 MAINTAINER = "MAINTAINER",
125 ONBUILD = "ONBUILD",
126 RUN = "RUN",
127 SHELL = "SHELL",
128 STOPSIGNAL = "STOPSIGNAL",
129 USER = "USER",
130 VOLUME = "VOLUME",
131 WORKDIR = "WORKDIR"
132}
133export declare enum Directive {
134 escape = "escape",
135 syntax = "syntax"
136}
137export declare const DefaultVariables: string[];
138export declare namespace DockerfileParser {
139 function parse(content: string): Dockerfile;
140}