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

Add Watch API and skaffold dev command #15

Merged
merged 12 commits into from
Feb 7, 2018
Merged

Add Watch API and skaffold dev command #15

merged 12 commits into from
Feb 7, 2018

Conversation

r2d4
Copy link
Contributor

@r2d4 r2d4 commented Feb 1, 2018

Fixes #11
Fixes #13

@@ -77,6 +77,11 @@ type Artifact struct {
Workspace string `yaml:"workspace"`
}

// DevelopmentConfig is the default development configuration for skaffold dev mode
var DevelopmentConfig = SkaffoldConfig{
Watch: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just noticed this, but why is Watch on SkaffoldConfig? Would it ever make sense to have it set to true in the yaml itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to use the config object itself to pass "dev mode" vs. "run mode" down to implementations.

While we could use a "Development: true" or something, why not expose some of the functionality to the user and let them toggle on/off development mode features in their skaffold.yaml?

I imagine that "development mode" would really just be a specific configuration of a skaffold.yaml that works great for development and has features turned on that you wouldn't want to use in CI/CD.

)

//TODO(@r2d4): Figure out best UX to support configuring this blacklist
var ignoredPrefixes = []string{"vendor", ".git"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a .skaffoldignore?

Copy link
Contributor Author

@r2d4 r2d4 Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this as an open question and give it a lot more thought. Some preliminary ideas:

  • .skaffoldignore
  • .gitignore (the idea behind this is that if you're doing real git ops, you shouldn't rely on things outside your repo for the build process)
  • skaffold.yaml parameters

We might need a combination of these

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely. Probably worth opening an issue to discuss alternatives.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref #20

// We need to evaluate the symlink if the dependency is a symlink
// inotify will return the final path of the symlink
// so we need to match it to know which dockerfile needs rebuilding
evalPath, err := filepath.EvalSymlinks(dep)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be conditional on whether or not it is a symlink? Can we do a stat to see?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, os.Stat should give us a fileinfo that will let us see fileinfo.Mode().IsRegular()

However, should docker.GetDockerfileDependencies be responsible for evaluating the possible symlinks anyways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

c := make(chan notify.EventInfo, 1)
errCh := make(chan error, 1)
defer notify.Stop(c)
for _, a := range artifacts {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For testability it might be nicer to break this into a function that returns a set of deps per artifact, then a function to add the watches on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats much cleaner, I'll try to refactor it that way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@r2d4
Copy link
Contributor Author

r2d4 commented Feb 6, 2018

@dlorenc moved Watch out of the config. PTAL 749229b

r2d4 and others added 3 commits February 5, 2018 20:51
Purely aesthetic, but it makes the info level debugging much more
easily parsed.
}
}

cleanup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we cleanup before the start? Doesn't ioutil.TempDir give us a clean dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

select {
case ei := <-c:
logrus.Infof("%s %s", ei.Event().String(), ei.Path())
artifact := depsToArtifact[ei.Path()]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but do we need a loop here? Can one dep be part of multiple artifacts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the loop, added slice of changed artifacts

@r2d4
Copy link
Contributor Author

r2d4 commented Feb 6, 2018

ref #36

@r2d4
Copy link
Contributor Author

r2d4 commented Feb 6, 2018

Rebased on the last merges, should be ready for another look @dlorenc

Copy link
Contributor

@dlorenc dlorenc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things. LGTM.

}
}
if ready != nil {
ready <- WatchStartEvent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A logging statement right before this could come in handy.

if err != nil {
return errors.Wrapf(err, "stat %s", dep)
}
if !fi.Mode().IsRegular() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you explicitly check for symlink instead of "!regular"?

What about directories, devices...

@r2d4 r2d4 merged commit 15a418c into GoogleContainerTools:master Feb 7, 2018
@r2d4 r2d4 deleted the watch branch February 7, 2018 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants