Skip to content

Commit

Permalink
Address minor feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
annasong20 committed Jun 9, 2022
1 parent d07e0f4 commit 8d332fd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
1 change: 0 additions & 1 deletion api/internal/target/kusttarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kustomize/api/ifc"
"sigs.k8s.io/kustomize/api/internal/accumulator"
"sigs.k8s.io/kustomize/api/internal/builtins"
Expand Down
3 changes: 1 addition & 2 deletions api/krusty/kustomizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func MakeKustomizer(o *Options) *Kustomizer {
// a kustomization.yaml file, perform the kustomization it represents,
// and return the resulting resources.
//
// Any files referenced by the kustomization must be present on the
// filesystem. One may call Run any number of times, on any number
// One may call Run any number of times, on any number
// of internal paths (e.g. the filesystem may contain multiple overlays,
// and Run can be called on each of them).
func (b *Kustomizer) Run(
Expand Down
9 changes: 4 additions & 5 deletions api/loader/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ import (
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kustomize/api/ifc"
"sigs.k8s.io/kustomize/api/internal/git"
"sigs.k8s.io/kustomize/kyaml/filesys"
)

// DemandDirectoryRoot assures that the given path is in fact a directory.
func DemandDirectoryRoot(
fSys filesys.FileSystem, path string) (filesys.ConfirmedDir, error) {
// DemandDirectoryRoot returns an error if path is not an existing directory on fSys.
// Otherwise, DemandDirectoryRoot returns path as a ConfirmedDir and all that it implies.
func DemandDirectoryRoot(fSys filesys.FileSystem, path string) (filesys.ConfirmedDir, error) {
if path == "" {
return "", filesys.ErrEmptyDir
}
Expand All @@ -36,7 +35,7 @@ func DemandDirectoryRoot(
}

// HasRemoteFileScheme returns whether path has a url scheme that kustomize allows for
// remote files. See examples/remoteBuild.md
// remote files. See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md
func HasRemoteFileScheme(path string) bool {
u, err := url.Parse(path)
return err == nil && (u.Scheme == "http" || u.Scheme == "https")
Expand Down
2 changes: 1 addition & 1 deletion api/loader/fileloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/kustomize/kyaml/filesys"
)

func TestHasFileScheme(t *testing.T) {
func TestHasRemoteFileScheme(t *testing.T) {
cases := map[string]struct {
url string
valid bool
Expand Down
42 changes: 23 additions & 19 deletions api/localizer/writer.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0

// See proposals/localize-command
// This package contains utilities for the command kustomize localize, which is
// documented under proposals/localize-command or at
// https://github.com/kubernetes-sigs/kustomize/blob/master/proposals/22-04-localize-command.md
package localizer

import (
Expand All @@ -10,7 +12,6 @@ import (
"strings"

"github.com/pkg/errors"

"sigs.k8s.io/kustomize/api/loader"
"sigs.k8s.io/kustomize/kyaml/filesys"
)
Expand All @@ -22,6 +23,26 @@ const alpha = "alpha"
var errNewDirRef = errors.New("target references newDir")
var errAbsPath = errors.New("absolute paths not yet supported")

// Writer takes care of writing localized files to their appropriate destination
// in newDir for command kustomize localize. Each Writer is associated with a
// kustomization root, either remote or local, referenced by target and writes
// files that the root directly references.
//
// Writer is meant to work with loader, which performs the path checks.
type Writer struct {
fSys filesys.FileSystem

// newDir argument, as defined by kustomize localize
newDir filesys.ConfirmedDir

// path to local copy of kustomization root for which Writer writes referenced
// files
root filesys.ConfirmedDir

// directory in newDir that mirrors root
dstDir filesys.ConfirmedDir
}

func makeAndClean(path string, fSys filesys.FileSystem) (filesys.ConfirmedDir, error) {
var cleanPath filesys.ConfirmedDir
var err error
Expand Down Expand Up @@ -52,23 +73,6 @@ func NewWriter(target filesys.ConfirmedDir, scope filesys.ConfirmedDir, newDir f
}, nil
}

// Writer takes care of writing localized files to their appropriate destination
// in newDir for command kustomize localize. Each Writer is associated with a
// kustomization root, either remote or local, referenced by target and writes
// files that the root directly references.
//
// Writer is meant to work with loader, which performs the path checks.
type Writer struct {
fSys filesys.FileSystem
// newDir argument, as defined by kustomize localize
newDir filesys.ConfirmedDir
// path to local copy of kustomization root for which Writer writes referenced
// files
root filesys.ConfirmedDir
// directory in newDir that mirrors root
dstDir filesys.ConfirmedDir
}

func (wr *Writer) getLocalizePath(u *url.URL) string {
pathParts := strings.Split(strings.Trim(u.Path, urlSeparator), urlSeparator)
return filepath.Join(localizeDir, u.Hostname(), filepath.Join(pathParts...))
Expand Down
1 change: 0 additions & 1 deletion api/localizer/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"

"github.com/stretchr/testify/require"

lclzr "sigs.k8s.io/kustomize/api/localizer"
"sigs.k8s.io/kustomize/kyaml/filesys"
)
Expand Down

0 comments on commit 8d332fd

Please sign in to comment.