From 34c10f0aa18c355ac0489a25faa7c3c7efcff3fa Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 Nov 2024 19:14:25 +0300 Subject: [PATCH] update deps --- go.mod | 2 +- go.sum | 4 ++-- plugin.go | 35 ++++------------------------------- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/go.mod b/go.mod index 00a17b9..4487db1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.2 require ( github.com/launchrctl/launchr v0.16.4 - github.com/skilld-labs/plasmactl-bump/v2 v2.0.4 + github.com/skilld-labs/plasmactl-bump/v2 v2.0.7-0.20241101125551-8e6c6264dbc2 github.com/spf13/cobra v1.8.1 ) diff --git a/go.sum b/go.sum index 25f5f29..178388e 100644 --- a/go.sum +++ b/go.sum @@ -388,8 +388,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= -github.com/skilld-labs/plasmactl-bump/v2 v2.0.4 h1:dB4R1NftC8wl5zgvijbFKvFWTb82GPyp43SnXUAWL3Q= -github.com/skilld-labs/plasmactl-bump/v2 v2.0.4/go.mod h1:HgdOmf7bgc3Q38b05RezpADcLGsBvso396tGmQnc4CM= +github.com/skilld-labs/plasmactl-bump/v2 v2.0.7-0.20241101125551-8e6c6264dbc2 h1:iZFtCP4lwwKFc3bOBCcQVGVpT20xYB8Z/IPhm5zF+ts= +github.com/skilld-labs/plasmactl-bump/v2 v2.0.7-0.20241101125551-8e6c6264dbc2/go.mod h1:HgdOmf7bgc3Q38b05RezpADcLGsBvso396tGmQnc4CM= github.com/sosedoff/ansible-vault-go v0.2.0 h1:XqkBdqbXgTuFQ++NdrZvSdUTNozeb6S3V5x7FVs17vg= github.com/sosedoff/ansible-vault-go v0.2.0/go.mod h1:wMU54HNJfY0n0KIgbpA9m15NBfaUDlJrAsaZp0FwzkI= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= diff --git a/plugin.go b/plugin.go index 76cf4d9..cc457bf 100644 --- a/plugin.go +++ b/plugin.go @@ -123,24 +123,22 @@ func dependencies(target, source string, toPath, showTree bool, depth int8) erro if err != nil { return err } - requiredMap := inv.GetRequiredMap() - parents := lookupDependencies(searchMrn, requiredMap, depth) + parents := inv.GetRequiredByResources(searchMrn, depth) if len(parents) > 0 { launchr.Term().Info().Println("Dependent resources:") if showTree { - var parentsTree forwardTree = requiredMap + var parentsTree forwardTree = inv.GetRequiredByMap() parentsTree.print(header, "", 1, depth, searchMrn, toPath) } else { printList(parents, toPath) } } - dependenciesMap := inv.GetDependenciesMap() - children := lookupDependencies(searchMrn, dependenciesMap, depth) + children := inv.GetDependsOnResources(searchMrn, depth) if len(children) > 0 { launchr.Term().Info().Println("Dependencies:") if showTree { - var childrenTree forwardTree = dependenciesMap + var childrenTree forwardTree = inv.GetDependsOnMap() childrenTree.print(header, "", 1, depth, searchMrn, toPath) } else { printList(children, toPath) @@ -167,31 +165,6 @@ func printList(items map[string]bool, toPath bool) { } } -func lookupDependencies(resourceName string, resourcesMap map[string]*sync.OrderedMap[bool], depth int8) map[string]bool { - result := make(map[string]bool) - if m, ok := resourcesMap[resourceName]; ok { - for _, item := range m.Keys() { - result[item] = true - lookupDependenciesRecursively(item, resourcesMap, result, 1, depth) - } - } - - return result -} - -func lookupDependenciesRecursively(resourceName string, resourcesMap map[string]*sync.OrderedMap[bool], result map[string]bool, depth, limit int8) { - if depth == limit { - return - } - - if m, ok := resourcesMap[resourceName]; ok { - for _, item := range m.Keys() { - result[item] = true - lookupDependenciesRecursively(item, resourcesMap, result, depth+1, limit) - } - } -} - type forwardTree map[string]*sync.OrderedMap[bool] func (t forwardTree) print(header, indent string, depth, limit int8, parent string, toPath bool) {