Skip to content

Commit

Permalink
final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sanaasy committed May 10, 2024
1 parent b71c4d1 commit 63e5084
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
14 changes: 10 additions & 4 deletions kustomize/commands/localize/localize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package localize
import (
"bytes"
"log"
"path/filepath"

"github.com/spf13/cobra"
lclzr "sigs.k8s.io/kustomize/api/krusty/localizer"
Expand Down Expand Up @@ -69,22 +70,27 @@ kustomize localize https://github.com/kubernetes-sigs/kustomize//api/krusty/test
return errors.Wrap(err)
}

if !f.noVerify && f.scope == "" {
if !f.noVerify {

Check failure on line 73 in kustomize/commands/localize/localize.go

View workflow job for this annotation

GitHub Actions / Lint

`if !f.noVerify` has complex nested blocks (complexity: 5) (nestif)
originalBuild, err := runBuildCmd(buildBuffer, buildCmd, args.target)
if err != nil {
return errors.Wrap(err)
}

localizedBuild, err := runBuildCmd(buildBuffer, buildCmd, dst)
buildDst := dst
if f.scope != "" && f.scope != args.target {
buildDst = filepath.Join(dst, filepath.Base(args.target))
}

localizedBuild, err := runBuildCmd(buildBuffer, buildCmd, buildDst)
if err != nil {
return errors.Wrap(err)
}

if localizedBuild == originalBuild {
log.Printf("VERIFICATION SUCCESS: `kustomize build` for %s and %s are the same after localization.", args.target, dst)
log.Printf("VERIFICATION SUCCESS: `kustomize build` for %s and %s are the same after localization.\n", args.target, dst)
} else {
log.Println(copyutil.PrettyFileDiff(originalBuild, localizedBuild))
log.Fatalf("VERFICATION FAILED: `kustomize build` for %s and %s are different after localization.", args.target, dst)
log.Fatalf("VERFICATION FAILED: `kustomize build` for %s and %s are different after localization.\n", args.target, dst)

Check failure on line 93 in kustomize/commands/localize/localize.go

View workflow job for this annotation

GitHub Actions / Lint

`VERFICATION` is a misspelling of `VERIFICATION` (misspell)
}
}

Expand Down
28 changes: 16 additions & 12 deletions kustomize/commands/localize/localize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ spec:
const helmKustomization = `apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
helmCharts:
- name: helmTest
repo: testRepo
includeCRDs: true
releaseName: example
version: 20.8.0
valuesInline:
deployment:
replicas: 3
logs:
access:
enabled: true
- name: external-dns
repo: oci://registry-1.docker.io/bitnamicharts
version: 6.19.2
releaseName: test
valuesInline:
crd:
create: false
rbac:
create: false
serviceAccount:
create: false
service:
enabled: false
`

func TestScopeFlag(t *testing.T) {
Expand Down Expand Up @@ -84,8 +86,10 @@ func TestScopeFlag(t *testing.T) {

func TestNoVerifyFlag(t *testing.T) {
kustomization := map[string]string{
"kustomization.yaml": `namePrefix: test-
"kustomization.yaml": `resources:
- deployment.yaml
`,
"deployment.yaml": deployment,
}
expected, actual, target := loctest.PrepareFs(t, nil, kustomization)

Expand Down

0 comments on commit 63e5084

Please sign in to comment.