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

Empty, non-nil sync = sync all the files and infer destination #3496

Merged
merged 1 commit into from
Jan 21, 2020
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
40 changes: 24 additions & 16 deletions docs/content/en/schemas/v2alpha3.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -100,8 +101,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -135,8 +137,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -170,8 +173,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -205,8 +209,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -240,8 +245,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -275,8 +281,9 @@
},
"sync": {
"$ref": "#/definitions/Sync",
"description": "*beta* local files synced to pods instead of triggering an image build when modified.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified."
"description": "*beta* local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> local files synced to pods instead of triggering an image build when modified. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
}
},
"preferredOrder": [
Expand Down Expand Up @@ -1904,8 +1911,9 @@
"infer"
],
"additionalProperties": false,
"description": "*beta* specifies what files to sync into the container. This is a list of sync rules indicating the intent to sync for source files.",
"x-intellij-html-description": "<em>beta</em> specifies what files to sync into the container. This is a list of sync rules indicating the intent to sync for source files."
"description": "*beta* specifies what files to sync into the container. This is a list of sync rules indicating the intent to sync for source files. If no files are listed, sync all the files and infer the destination.",
"x-intellij-html-description": "<em>beta</em> specifies what files to sync into the container. This is a list of sync rules indicating the intent to sync for source files. If no files are listed, sync all the files and infer the destination.",
"default": "infer: [\"**/*\"]"
},
"SyncRule": {
"required": [
Expand Down
7 changes: 7 additions & 0 deletions pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func Set(c *latest.SkaffoldConfig) error {

for _, a := range c.Build.Artifacts {
setDefaultWorkspace(a)
setDefaultSync(a)

if c.Build.Cluster != nil && a.CustomArtifact == nil && a.BuildpackArtifact == nil {
defaultToKanikoArtifact(a)
Expand Down Expand Up @@ -213,6 +214,12 @@ func setDefaultWorkspace(a *latest.Artifact) {
a.Workspace = valueOrDefault(a.Workspace, ".")
}

func setDefaultSync(a *latest.Artifact) {
if a.Sync != nil && len(a.Sync.Manual) == 0 && len(a.Sync.Infer) == 0 {
a.Sync.Infer = []string{"**/*"}
}
}

func withClusterConfig(c *latest.SkaffoldConfig, opts ...func(*latest.ClusterDetails) error) error {
clusterDetails := c.Build.BuildType.Cluster
if clusterDetails == nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/schema/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestSetDefaults(t *testing.T) {
ArtifactType: latest.ArtifactType{
BuildpackArtifact: &latest.BuildpackArtifact{},
},
Sync: &latest.Sync{},
},
},
},
Expand All @@ -81,6 +82,7 @@ func TestSetDefaults(t *testing.T) {
testutil.CheckDeepEqual(t, "fourth", cfg.Build.Artifacts[3].ImageName)
testutil.CheckDeepEqual(t, []string{"."}, cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Paths)
testutil.CheckDeepEqual(t, []string(nil), cfg.Build.Artifacts[3].BuildpackArtifact.Dependencies.Ignore)
testutil.CheckDeepEqual(t, []string{"**/*"}, cfg.Build.Artifacts[3].Sync.Infer)
}

func TestSetDefaultsOnCluster(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ type Artifact struct {

// Sync *beta* lists local files synced to pods instead
// of triggering an image build when modified.
// If no files are listed, sync all the files and infer the destination.
// Defaults to `infer: ["**/*"]`.
Sync *Sync `yaml:"sync,omitempty"`

// ArtifactType describes how to build an artifact.
Expand All @@ -568,6 +570,8 @@ type Artifact struct {

// Sync *beta* specifies what files to sync into the container.
// This is a list of sync rules indicating the intent to sync for source files.
// If no files are listed, sync all the files and infer the destination.
// Defaults to `infer: ["**/*"]`.
type Sync struct {
// Manual lists manual sync rules indicating the source and destination.
Manual []*SyncRule `yaml:"manual,omitempty" yamltags:"oneOf=sync"`
Expand Down