Skip to content

Commit

Permalink
Merge pull request #1194 from balopat/default-repo-nits
Browse files Browse the repository at this point in the history
default-repo config documentation
  • Loading branch information
balopat authored Oct 23, 2018
2 parents 8741a20 + d2f3e33 commit 3c27520
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ git clone https://github.com/GoogleContainerTools/skaffold
[source,shell]
cd examples/getting-started

. Replace `k8s-project` with your GCP project ID.
. Skaffold needs a repo to push to (unless you are running against a local k8s cluster)

. Run `skaffold dev`.
. Run `skaffold dev --default-repo <your-image-repo>`.
[source,console]
$ skaffold dev
$ skaffold dev --default-repo <your-image-repo>
Starting build...
Found [minikube] context, using local docker daemon.
Sending build context to Docker daemon 6.144kB
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/config/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ limitations under the License.
package config

import (
"fmt"
"io"

"github.com/pkg/errors"
"github.com/spf13/cobra"

yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
)

func NewCmdList(out io.Writer) *cobra.Command {
Expand Down Expand Up @@ -66,7 +67,7 @@ func runList(out io.Writer) error {
return errors.Wrap(err, "marshaling config")
}
}

out.Write([]byte(fmt.Sprintf("skaffold config: %s\n", configFile)))
out.Write(configYaml)
return nil
}
6 changes: 2 additions & 4 deletions cmd/skaffold/app/cmd/config/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ limitations under the License.
package config

import (
"fmt"
"io/ioutil"
"path/filepath"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes/context"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"

homedir "github.com/mitchellh/go-homedir"
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
)

const defaultConfigDir = ".skaffold"
Expand Down Expand Up @@ -63,7 +62,6 @@ func resolveConfigFile() error {
// ReadConfigForFile reads the specified file and returns the contents
// parsed into a Config struct.
func ReadConfigForFile(filename string) (*Config, error) {
fmt.Printf("reading config for file %s\n", filename)
contents, err := ioutil.ReadFile(filename)
if err != nil {
return nil, errors.Wrap(err, "reading global config")
Expand Down
10 changes: 10 additions & 0 deletions docs/concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ In the push phase, Skaffold ensures that your image is uploaded to the registry
Before
running Skaffold you should ensure that you are able to push to your configured image registry.

Skaffold by default will try push the images to the image repository defined by the artifact image names.
When running someone else's project, you can reroute the images to be pushed to your own image repository instead in one of the four ways:

* flag: `skaffold dev --default-repo <myrepo>`
* env var: `SKAFFOLD_DEFAULT_REPO=<myrepo> skaffold dev`
* global skaffold config (one time): `skaffold config set --global default-repo <myrepo>`
* skaffold config for current kubectl context: `skaffold config set default-repo <myrepo>`


When using local Kubernetes clusters like Minikube or Docker for Desktop, the push is skipped
because the image is already available locally.


==== 3. Deploy
The deploy step ensures that the most recent artifacts are running in the cluster.
You can use different
Expand Down
8 changes: 7 additions & 1 deletion integration/examples/README.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
== Examples
:icons: font

To run any of the examples, replace `k8s-project` with your GCP project ID.
To run the examples, you either have to manually replace the image repositories in the examples from gcr.io/k8s-skaffold to yours or you can point skaffold to your default image repository in one of the four ways:

* flag: `skaffold dev --default-repo <myrepo>`
* env var: `SKAFFOLD_DEFAULT_REPO=<myrepo> skaffold dev`
* global skaffold config (one time): `skaffold config set --global default-repo <myrepo>`
* skaffold config for current kubectl context: `skaffold config set default-repo <myrepo>`
These examples are made to work with the latest release of skaffold.

If you are running skaffold at HEAD or have built it from source, please use the examples at integration/examples.
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (h *HelmDeployer) joinTagsToBuildResult(builds []build.Artifact, params map
newImageName := util.SubstituteDefaultRepoIntoImage(h.defaultRepo, imageName)
build, ok := imageToBuildResult[newImageName]
if !ok {
return nil, fmt.Errorf("No build present for %s", imageName)
return nil, fmt.Errorf("no build present for %s", imageName)
}
paramToBuildResult[param] = build
}
Expand Down
1 change: 0 additions & 1 deletion pkg/skaffold/util/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func SubstituteDefaultRepoIntoImage(defaultRepo string, originalImage string) st
// prefixes don't match, concatenate and truncate
return truncate(defaultRepo + "/" + originalImage)
}
// TODO: check defaultRepo is < 256 chars when setting
return truncate(defaultRepo + "/" + escapeRegex.ReplaceAllString(originalImage, "_"))
}

Expand Down

0 comments on commit 3c27520

Please sign in to comment.