Git Product home page Git Product logo

dockerfile-language-server's Issues

Create a validator setting to toggle the deprecated MAINTAINER instruction

The MAINTAINER instruction is currently deprecated so the validator should warn the client about this. However, some clients may wish to ignore the fact that it is deprecated. Alternatively, they may wish to have errors created if such an instruction exists in the Dockerfile. We should introduce a setting in the validator to allow this to be toggled if desired.

Fix compilation error in Travis Build #84

Travis Build #84 is broken.

$ npm run build;
> [email protected] build /home/travis/build/rcjsuen/dockerfile-language-server-nodejs
> tsc -p .
parser/dockerfile.ts(10,21): error TS2307: Cannot find module './instructions/arg'.
parser/dockerfileParser.ts(12,21): error TS2307: Cannot find module './instructions/arg'.

Consolidate validation messages about a missing FROM

When a file does not have a FROM instruction as its first instruction or when the Dockerfile doesn't have any instructions, we should use one common error to notify the user that a source image must be specified.

Rewrite the document symbols code to create an AST

At the moment, every response handler parses a Dockerfile with its own unique code. While a Dockerfile's syntax is not exactly very complicated, a lot of code that is very similar is replicated across the entire codebase. We should rewrite a parser from scratch that will create an AST of sorts that knows where a comment, directive, and instruction line starts and ends (including any escaped newlines in the case of instructions).

To validate that this parser is working as intended, it will first be used to replace dockerSymbols.ts before further refactorings across the entire codebase.

textDocument/documentHighlight fails trying to read property of a null object

FROM node AS bootstrap
COPY bootstrap /git/build/

If you have a Dockerfile with COPY instructions that don't specify a --from= flag, an error will be thrown.

[Error - 7:52:20 PM] Request textDocument/documentHighlight failed.
  Message: Request textDocument/documentHighlight failed with message: Cannot read property 'start' of null
  Code: -32603 

Travis CI build has failed

The first build has failed. It seems that it's because the .travis.yml file is referencing an environment variable that doesn't exist.

Allow FROM instructions to have either one or three arguments

Originally, FROM instructions only took a single argument of the following forms:

  1. FROM <image>
  2. FROM <image>[:<tag>]
  3. FROM <image>[@<digest>]

However, a new AS keyword has been introduced and a FROM instruction can now be defined by something like FROM node AS bootstrap.

As the validator currently validates FROM as an instruction that may only have one argument, we need to update it to to accept either one or three arguments (with the second being an AS).

Ranged formatting returns unnecessary edit on a well-formed line

FROM node

If you try to format this document with a valid range, the server will return one TextEdit that replaces content from Position(0, 0) to Position(0, 0) to the empty string "". This is extraneous and we should simply return an empty TextEdit[] in this case.

Migrate existing code to use the new parser

A new general-purpose parser for creating an AST-like structure for a Dockerfile was implemented in #24. We should migrate our existing parsing code to use this generic parser instead.

ARG instructions may precede a FROM instruction

If the first instruction is not a FROM, the validator will flag it as an error. However, if it seems that FROM instructions can actually be preceded by an ARG.

We need to fix the validator to consider this case so that ARG instruments that appear before a FROM do not get flagged as an error.

Missing arguments from MAINTAINER not flagged as a diagnostic

Travis CI Build #32

  Docker Validator Tests
    missing argument
      ✓ ADD
      ✓ ARG
      ✓ CMD
      ✓ COPY
      ✓ ENTRYPOINT
      ✓ ENV
      ✓ EXPOSE
      ✓ FROM
      ✓ HEALTHCHECK
      ✓ LABEL
      1) MAINTAINER
      ✓ ONBUILD
      ✓ RUN
      ✓ SHELL
      ✓ STOPSIGNAL
      ✓ USER
      ✓ WORKDIR

  1) Docker Validator Tests missing argument MAINTAINER:
      AssertionError [ERR_ASSERTION]: 0 == 3
      + expected - actual
      -0
      +3
      
      at assertInstructionMissingArgument (out/test/dockerValidator.tests.js:1:46748)
      at testMissingArgument (out/test/dockerValidator.tests.js:1:59678)
      at Context.<anonymous> (out/test/dockerValidator.tests.js:1:62522)

The MAINTAINER-specific parsing code only flags the keyword itself as being deprecated. It should also check to see if it's actually followed by an argument and to create a MISSING_ARGUMENT diagnostic if it's not.

Completion items should suggest build stage names

FROM alpine as setup
FROM alpine
COPY --from=

Given this Dockerfile, we should suggest setup as a completion item. Suggesting 1 is questionable as you're not supposed to refer to the current build stage but perhaps it is worth suggesting for the sake of completeness.

Add missing tests for implemented features

For the initial pass, we will need tests that test the actual leg work of each underlying feature. In the future, a separate set of tests should be created to make sure that the server is returning the right responses back to the client.

  • code actions
  • command execution
  • completion
  • diagnostics
  • document symbols
  • formatting
  • hover

Add support for textDocument/documentHighlight

If a user has build stages defined (as of Docker 17.06 CE), we should provide highlighting support if the build stage declaration itself in the FROM instruction or the name in the --from=name of the COPY instruction is currently selected.

Formatter doesn't consider \r characters properly

On ranged selection formatting, if \r or \r\n are used for newlines and are actually escaped, the start of the line is not being calculated correctly and the formatter deems that no formatting is required.

FROM node
EXPOSE 8080\
8081

Here, 8081 should get indented if it is selected but the formatter gets confused and doesn't return a TextEdit for this scenario.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.