Skip to content
Open
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
2 changes: 1 addition & 1 deletion commands/pkg/init/cmdinit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"testing"

initialization "github.com/kptdev/kpt/commands/pkg/init"
"github.com/kptdev/kpt/internal/builtins"
"github.com/kptdev/kpt/internal/testutil"
"github.com/kptdev/kpt/internal/util/man"
"github.com/kptdev/kpt/pkg/lib/builtins"
"github.com/kptdev/kpt/pkg/printer/fake"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion commands/pkg/update/cmdupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/kptdev/kpt/commands/pkg/get"
"github.com/kptdev/kpt/commands/pkg/update"
"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/testutil"
"github.com/kptdev/kpt/internal/testutil/pkgbuilder"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/printer/fake"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion internal/errors/resolver/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"fmt"
"strings"

"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/pkg/lib/gitutil"
)

//nolint:gochecknoinits
Expand Down
2 changes: 1 addition & 1 deletion internal/fnruntime/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"time"

"github.com/google/shlex"
"github.com/kptdev/kpt/internal/builtins"
"github.com/kptdev/kpt/internal/errors"
"github.com/kptdev/kpt/internal/pkg"
fnresult "github.com/kptdev/kpt/pkg/api/fnresult/v1"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/fn"
"github.com/kptdev/kpt/pkg/lib/builtins"
"github.com/kptdev/kpt/pkg/lib/types"
"github.com/kptdev/kpt/pkg/printer"
"sigs.k8s.io/kustomize/kyaml/filesys"
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/setup_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"path/filepath"
"testing"

"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/testutil/pkgbuilder"
"github.com/kptdev/kpt/internal/util/get"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/printer/fake"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/kustomize/kyaml/yaml"
Expand Down
2 changes: 1 addition & 1 deletion internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"strings"
"testing"

"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/util/addmergecomment"
"github.com/kptdev/kpt/internal/util/git"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/printer/fake"
toposort "github.com/philopon/go-toposort"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion internal/util/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (
"path/filepath"
"strings"

"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/pkg"
"github.com/kptdev/kpt/internal/util/addmergecomment"
"github.com/kptdev/kpt/internal/util/fetch"
"github.com/kptdev/kpt/internal/util/pkgutil"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/filesys"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/util/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
"sigs.k8s.io/kustomize/kyaml/filesys"

"github.com/kptdev/kpt/internal/errors"
"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/pkg"
"github.com/kptdev/kpt/internal/util/git"
"github.com/kptdev/kpt/internal/util/pkgutil"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/printer"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/util/parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"regexp"
"strings"

"github.com/kptdev/kpt/internal/gitutil"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"sigs.k8s.io/kustomize/kyaml/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/util/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"strings"

"github.com/kptdev/kpt/internal/errors"
"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/pkg"
"github.com/kptdev/kpt/internal/util/addmergecomment"
"github.com/kptdev/kpt/internal/util/fetch"
Expand All @@ -33,6 +32,7 @@ import (
"github.com/kptdev/kpt/internal/util/stack"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/kptfile/kptfileutil"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/lib/types"
"github.com/kptdev/kpt/pkg/printer"
"sigs.k8s.io/kustomize/kyaml/copyutil"
Expand Down
2 changes: 1 addition & 1 deletion pkg/kptpkg/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"path/filepath"
"strings"

"github.com/kptdev/kpt/internal/builtins"
"github.com/kptdev/kpt/internal/pkg"
"github.com/kptdev/kpt/internal/util/man"
kptfilev1 "github.com/kptdev/kpt/pkg/api/kptfile/v1"
"github.com/kptdev/kpt/pkg/lib/builtins"
"github.com/kptdev/kpt/pkg/printer"
"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/filesys"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (pc *PackageContextGenerator) Process(resourceList *framework.ResourceList)

// This loop does the following:
// - Filters out package context resources from the input resources
// - Generates a package context resource for each kpt package (i.e Kptfile)
// - Generates a package context resource for the root kpt package (i.e Kptfile)
for _, resource := range resourceList.Items {
gvk := resid.GvkFromNode(resource)
if gvk.Equals(configMapGVK) && resource.GetName() == PkgContextName {
Expand All @@ -95,7 +95,11 @@ func (pc *PackageContextGenerator) Process(resourceList *framework.ResourceList)
}
return resourceList.Results
}
contextResources = append(contextResources, pkgContext)

// Only add package context to the root kpt package
if pkgContext != nil {
contextResources = append(contextResources, pkgContext)
}
}
}

Expand All @@ -121,6 +125,12 @@ func pkgContextResource(kptfile *yaml.RNode, packageConfig *PackageConfig) (*yam
if err != nil {
return nil, err
}

// We only want one "package-context.yaml" in each kpt package
if kptfilePath != kptfilev1.KptFileGVK().Kind {
return nil, nil
}

annotations := map[string]string{
kioutil.PathAnnotation: path.Join(path.Dir(kptfilePath), PkgContextFile),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,8 @@ items:
internal.config.kubernetes.io/path: 'package-context.yaml'
data:
name: order-service
- apiVersion: v1
kind: ConfigMap
metadata:
name: kptfile.kpt.dev
annotations:
config.kubernetes.io/local-config: "true"
internal.config.kubernetes.io/path: 'subpkg/package-context.yaml'
data:
name: subpkg
results:
- message: generated package context
severity: info
file:
path: package-context.yaml
- message: generated package context
severity: info
file:
path: subpkg/package-context.yaml
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ func (g *GitLocalRunner) RunVerbose(ctx context.Context, command string, args ..
func (g *GitLocalRunner) run(ctx context.Context, verbose bool, command string, args ...string) (RunResult, error) {
const op errors.Op = "gitutil.run"

fullArgs := append(
[]string{"-c", "user.name=Kpt", "-c", "user.email=kpt@kpt.dev", command},
args...,
)
fullArgs := append([]string{command}, args...)
cmd := exec.CommandContext(ctx, g.gitPath, fullArgs...)
cmd.Dir = g.Dir
// Disable git prompting the user for credentials.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"testing"

"github.com/kptdev/kpt/internal/errors"
"github.com/kptdev/kpt/internal/gitutil"
"github.com/kptdev/kpt/internal/testutil"
"github.com/kptdev/kpt/internal/testutil/pkgbuilder"
"github.com/kptdev/kpt/pkg/lib/gitutil"
"github.com/kptdev/kpt/pkg/printer/fake"
"github.com/stretchr/testify/assert"
)
Expand Down
Loading