Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warning about .mesgingnore close #494 #498

Merged
merged 5 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions api/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ func TestDeployService(t *testing.T) {
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "[DEPRECATED] Please use .dockerignore instead of .mesgignore",
Type: DoneNegative,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Building Docker image...",
Type: Running,
Expand Down
24 changes: 19 additions & 5 deletions container/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/docker/docker/api/types"
"github.com/docker/docker/builder/dockerignore"
"github.com/docker/docker/pkg/archive"
)

Expand All @@ -21,12 +23,11 @@ type BuildResponse struct {

// Build builds a docker image.
func (c *Container) Build(path string) (tag string, err error) {
excludeFiles := []string{}
// TODO: remove .mesgignore for a future release
for _, file := range []string{".mesgignore", ".dockerignore"} {
excludeFilesBytes, _ := ioutil.ReadFile(filepath.Join(path, file))
excludeFiles = append(excludeFiles, strings.Fields(string(excludeFilesBytes))...)
excludeFiles, err := dockerignoreFiles(path)
if err != nil {
return "", err
}

buildContext, err := archive.TarWithOptions(path, &archive.TarOptions{
Compression: archive.Gzip,
ExcludePatterns: excludeFiles,
Expand All @@ -46,6 +47,19 @@ func (c *Container) Build(path string) (tag string, err error) {
return parseBuildResponse(response)
}

// dockerignoreFiles reads exlcuded files from .dockerignore.
func dockerignoreFiles(path string) ([]string, error) {
f, err := os.Open(filepath.Join(path, ".dockerignore"))
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
defer f.Close()
return dockerignore.ReadAll(f)
}

func parseBuildResponse(response types.ImageBuildResponse) (tag string, err error) {
lastOutput, err := extractLastOutputFromBuildResponse(response)
if err != nil {
Expand Down
Empty file removed service-test/task/.mesgignore
Empty file.
13 changes: 0 additions & 13 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"io/ioutil"
"os"
"path/filepath"
"time"

"github.com/cnf/structhash"
Expand Down Expand Up @@ -95,9 +94,6 @@ func New(tarball io.Reader, options ...Option) (*Service, error) {
if err := s.saveContext(tarball); err != nil {
return nil, err
}
if err := s.checkDeprecations(); err != nil {
return nil, err
}

def, err := importer.From(s.tempPath)
if err != nil {
Expand Down Expand Up @@ -220,15 +216,6 @@ func (s *Service) deploy() error {
return nil
}

// checkDeprecations checks deprecated usages in service.
func (s *Service) checkDeprecations() error {
if _, err := os.Stat(filepath.Join(s.tempPath, ".mesgignore")); err == nil {
// TODO: remove for a future release
s.sendStatus("[DEPRECATED] Please use .dockerignore instead of .mesgignore", DDoneNegative)
}
return nil
}

// sendStatus sends a status message.
func (s *Service) sendStatus(message string, typ DStatusType) {
if s.statuses != nil {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.