Skip to content

Commit

Permalink
fix namespace issue
Browse files Browse the repository at this point in the history
  • Loading branch information
choffmeister committed Dec 6, 2021
1 parent 8842f75 commit 7944831
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 24 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ This generator allows you to convert a remote kustomization into a locally store
```yaml
# kustomization-generator.yaml
type: kustomize
namespace: namespace
url: github.com/CrunchyData/postgres-operator-examples/kustomize/install?ref=main
args:
- --reorder
Expand All @@ -60,7 +59,6 @@ args:
```yaml
# kustomization-generator.yaml
type: download
namespace: longhorn-system
url: https://raw.githubusercontent.com/longhorn/longhorn/v1.2.2/deploy/longhorn.yaml
```
Expand Down
1 change: 0 additions & 1 deletion example/download/kustomization-generator.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
type: download
namespace: namespace
url: https://raw.githubusercontent.com/longhorn/longhorn/v1.2.2/deploy/longhorn.yaml
1 change: 0 additions & 1 deletion example/kustomize/kustomization-generator.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

type: kustomize
namespace: namespace
url: github.com/CrunchyData/postgres-operator-examples/kustomize/install?ref=main
args:
- --reorder
Expand Down
2 changes: 0 additions & 2 deletions internal/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

type Kustomization struct {
Namespace string `yaml:"namespace"`
Resources []string `yaml:"resources"`
}

Expand All @@ -22,7 +21,6 @@ type GeneratorResource struct {
}

type GeneratorResult struct {
Namespace string
Resources []GeneratorResource
}

Expand Down
4 changes: 1 addition & 3 deletions internal/generator_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
)

type DownloadGenerator struct {
Namespace string `yaml:"namespace"`
Url string `yaml:"url"`
Url string `yaml:"url"`
}

func (g DownloadGenerator) Generate() (*GeneratorResult, error) {
Expand All @@ -33,7 +32,6 @@ func (g DownloadGenerator) Generate() (*GeneratorResult, error) {
return nil, fmt.Errorf("splitting helm resources failed: %v", err)
}
result := GeneratorResult{
Namespace: g.Namespace,
Resources: resources,
}
return &result, nil
Expand Down
3 changes: 1 addition & 2 deletions internal/generator_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ func TestLoadGeneratorDownload(t *testing.T) {
c1, err := LoadGenerator("./generator_download_test.yaml")
if assert.NoError(t, err) {
c2 := DownloadGenerator{
Namespace: "namespace",
Url: "https://domain.com/resources.yaml",
Url: "https://domain.com/resources.yaml",
}
assert.Equal(t, c2, *c1)
}
Expand Down
1 change: 0 additions & 1 deletion internal/generator_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func (g HelmGenerator) Generate() (*GeneratorResult, error) {
return nil, fmt.Errorf("splitting helm resources failed: %v", err)
}
result := GeneratorResult{
Namespace: g.Namespace,
Resources: resources,
}
return &result, nil
Expand Down
6 changes: 2 additions & 4 deletions internal/generator_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
)

type KustomizeGenerator struct {
Namespace string `yaml:"namespace"`
Url string `yaml:"url"`
Args []string `yaml:"args"`
Url string `yaml:"url"`
Args []string `yaml:"args"`
}

func (g KustomizeGenerator) Generate() (*GeneratorResult, error) {
Expand All @@ -31,7 +30,6 @@ func (g KustomizeGenerator) Generate() (*GeneratorResult, error) {
return nil, fmt.Errorf("splitting helm resources failed: %v", err)
}
result := GeneratorResult{
Namespace: g.Namespace,
Resources: resources,
}
return &result, nil
Expand Down
5 changes: 2 additions & 3 deletions internal/generator_kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ func TestLoadGeneratorKustomize(t *testing.T) {
c1, err := LoadGenerator("./generator_kustomize_test.yaml")
if assert.NoError(t, err) {
c2 := KustomizeGenerator{
Namespace: "namespace",
Url: "github.com/owner/repo/kustomize?ref=main",
Args: []string{"--reorder", "legacy"},
Url: "github.com/owner/repo/kustomize?ref=main",
Args: []string{"--reorder", "legacy"},
}
assert.Equal(t, c2, *c1)
}
Expand Down
6 changes: 1 addition & 5 deletions internal/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ func write(dir string, result GeneratorResult) error {
},
}

kustomization := Kustomization{
Namespace: result.Namespace,
}
kustomization := Kustomization{}

for i := range buckets {
bucket := &buckets[i]
bucket.kustomization.Namespace = result.Namespace
bucket.dir = path.Join(dir, bucket.name)
err := os.MkdirAll(bucket.dir, 0o755)
if err != nil {
Expand All @@ -106,7 +103,6 @@ func write(dir string, result GeneratorResult) error {
}

for _, bucket := range buckets {
bucket.kustomization.Namespace = result.Namespace
if len(bucket.kustomization.Resources) > 0 {
kustomization.Resources = append(kustomization.Resources, bucket.name)
err := writeYamlFile(path.Join(bucket.dir, "kustomization.yaml"), bucket.kustomization)
Expand Down

0 comments on commit 7944831

Please sign in to comment.