-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Update argocd, k8s & kustomize deps #46
Open
svghadi
wants to merge
4
commits into
redhat-developer:master
Choose a base branch
from
svghadi:argo-update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+674
−1,163
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
default: test | ||
|
||
.PHONY: build | ||
build: | ||
go build -v ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test `go list ./... | grep -v test` | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,9 @@ import ( | |
"github.com/go-git/go-git/v5" | ||
|
||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"sigs.k8s.io/kustomize/k8sdeps" | ||
"sigs.k8s.io/kustomize/pkg/fs" | ||
"sigs.k8s.io/kustomize/pkg/loader" | ||
"sigs.k8s.io/kustomize/pkg/resource" | ||
"sigs.k8s.io/kustomize/pkg/target" | ||
"sigs.k8s.io/kustomize/api/krusty" | ||
"sigs.k8s.io/kustomize/api/resource" | ||
fs "sigs.k8s.io/kustomize/kyaml/filesys" | ||
|
||
"github.com/redhat-developer/gitops-backend/pkg/gitfs" | ||
) | ||
|
@@ -24,26 +22,17 @@ func ParseFromGit(path string, opts *git.CloneOptions) ([]*Resource, error) { | |
} | ||
|
||
func parseConfig(path string, files fs.FileSystem) ([]*Resource, error) { | ||
k8sfactory := k8sdeps.NewFactory() | ||
ldr, err := loader.NewLoader(path, files) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer func() { | ||
err = ldr.Cleanup() | ||
if err != nil { | ||
panic(err) | ||
} | ||
}() | ||
kt, err := target.NewKustTarget(ldr, k8sfactory.ResmapF, k8sfactory.TransformerF) | ||
if err != nil { | ||
return nil, err | ||
} | ||
r, err := kt.MakeCustomizedResMap() | ||
Comment on lines
-27
to
-42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Latest kustomize provides a wrapper ref: |
||
|
||
// Run performs a kustomization. | ||
// It reads given path from the given file system, interprets it as | ||
// a kustomization.yaml file, perform the kustomization it represents, | ||
// and return the resulting resources. | ||
kt := krusty.MakeKustomizer(krusty.MakeDefaultOptions()) | ||
r, err := kt.Run(files, path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if len(r) == 0 { | ||
if len(r.Resources()) == 0 { | ||
return nil, nil | ||
} | ||
|
||
|
@@ -52,7 +41,7 @@ func parseConfig(path string, files fs.FileSystem) ([]*Resource, error) { | |
return nil, err | ||
} | ||
resources := []*Resource{} | ||
for _, v := range r { | ||
for _, v := range r.Resources() { | ||
resources = append(resources, extractResource(conv, v)) | ||
} | ||
return resources, nil | ||
|
@@ -82,9 +71,10 @@ func extractResource(conv *unstructuredConverter, res *resource.Resource) *Resou | |
} | ||
|
||
// convert converts a Kustomize resource into a generic Unstructured resource | ||
// which which the unstructured converter uses to create resources from. | ||
// which the unstructured converter uses to create resources from. | ||
func convert(r *resource.Resource) *unstructured.Unstructured { | ||
res, _ := r.Map() | ||
return &unstructured.Unstructured{ | ||
Object: r.Map(), | ||
Object: res, | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigs.k8s.io/kustomize/pkg/fs
package is deprecated in favour ofsigs.k8s.io/kustomize/kyaml/filesys
Ref: https://github.com/kubernetes-sigs/kustomize/blob/afe77936761f8f7ee735a67f167a8382c8406f74/api/filesys/filesys.go#L8-L9