UNPKG

5.28 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 { Heredoc } from './heredoc';
103export { JSONInstruction } from './jsonInstruction';
104export { Label } from './instructions/label';
105export { ModifiableInstruction } from './modifiableInstruction';
106export { Onbuild } from './instructions/onbuild';
107export { PropertyInstruction } from './propertyInstruction';
108export { Run } from './instructions/run';
109export { Shell } from './instructions/shell';
110export { Stopsignal } from './instructions/stopsignal';
111export { User } from './instructions/user';
112export { Volume } from './instructions/volume';
113import { Workdir } from './instructions/workdir';
114export { Workdir };
115export declare enum Keyword {
116 ADD = "ADD",
117 ARG = "ARG",
118 CMD = "CMD",
119 COPY = "COPY",
120 ENTRYPOINT = "ENTRYPOINT",
121 ENV = "ENV",
122 EXPOSE = "EXPOSE",
123 FROM = "FROM",
124 HEALTHCHECK = "HEALTHCHECK",
125 LABEL = "LABEL",
126 MAINTAINER = "MAINTAINER",
127 ONBUILD = "ONBUILD",
128 RUN = "RUN",
129 SHELL = "SHELL",
130 STOPSIGNAL = "STOPSIGNAL",
131 USER = "USER",
132 VOLUME = "VOLUME",
133 WORKDIR = "WORKDIR"
134}
135export declare enum Directive {
136 escape = "escape",
137 syntax = "syntax"
138}
139export declare const DefaultVariables: string[];
140export declare namespace DockerfileParser {
141 function parse(content: string): Dockerfile;
142}