Skip to content

Commit

Permalink
Merge pull request GoogleContainerTools#1237 from dgageot/fix-1236
Browse files Browse the repository at this point in the history
Set Kind on `skaffold init`
  • Loading branch information
r2d4 authored Nov 6, 2018
2 parents 56fb997 + 4d2bd25 commit 72d69cf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/skaffold/app/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func generateSkaffoldPipeline(k8sConfigs []string, dockerfilePairs []dockerfileP

pipeline := &latest.SkaffoldPipeline{
APIVersion: latest.Version,
Kind: "Config",
}
if err := pipeline.SetDefaultValues(); err != nil {
return nil, errors.Wrap(err, "generating default pipeline")
Expand Down
62 changes: 62 additions & 0 deletions cmd/skaffold/app/cmd/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2018 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"fmt"
"testing"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestGenerateEmptySkaffoldPipeline(t *testing.T) {
expectedYaml := fmt.Sprintf(`apiVersion: %s
kind: Config
deploy:
kubectl: {}
`, latest.Version)

buf, err := generateSkaffoldPipeline(nil, nil)

testutil.CheckErrorAndDeepEqual(t, false, err, expectedYaml, string(buf))
}

func TestGenerateSkaffoldPipeline(t *testing.T) {
expectedYaml := fmt.Sprintf(`apiVersion: %s
kind: Config
build:
artifacts:
- image: docker/image
docker:
dockerfile: dockerfile.test
deploy:
kubectl:
manifests:
- k8s/deployment.yaml
`, latest.Version)

k8sConfigs := []string{"k8s/deployment.yaml"}
dockerfilePairs := []dockerfilePair{{
Dockerfile: "dockerfile.test",
ImageName: "docker/image",
}}

buf, err := generateSkaffoldPipeline(k8sConfigs, dockerfilePairs)

testutil.CheckErrorAndDeepEqual(t, false, err, expectedYaml, string(buf))
}

0 comments on commit 72d69cf

Please sign in to comment.