@@ -56,7 +56,7 @@ func ValidateNodeName(name string) error {
5656}
5757
5858// Config returns the config of the node with given name.
59- func Config (name string ) (darknode.GeneralConfig , error ){
59+ func Config (name string ) (darknode.GeneralConfig , error ) {
6060 path := filepath .Join (NodePath (name ), "config.json" )
6161 return darknode .NewConfigFromJSONFile (path )
6262}
@@ -118,21 +118,14 @@ func GetNodesByTags(tags string) ([]string, error) {
118118 if err != nil {
119119 return nil , err
120120 }
121- ts := strings .Split (strings .TrimSpace (tags ), "," )
122121 nodes := make ([]string , 0 )
123122 for _ , f := range files {
124- tagFile := filepath .Join (Directory , "darknodes" , f .Name (), "tags.out" )
125- tags , err := ioutil .ReadFile (tagFile )
123+ path := filepath .Join (Directory , "darknodes" , f .Name (), "tags.out" )
124+ tagFile , err := ioutil .ReadFile (path )
126125 if err != nil {
127126 continue
128127 }
129- haveAllTags := true
130- for i := range ts {
131- if ! strings .Contains (string (tags ), ts [i ]) {
132- haveAllTags = false
133- }
134- }
135- if ! haveAllTags {
128+ if ! ValidateTags (string (tagFile ), tags ) {
136129 continue
137130 }
138131
@@ -145,6 +138,16 @@ func GetNodesByTags(tags string) ([]string, error) {
145138 return nodes , nil
146139}
147140
141+ func ValidateTags (have , required string ) bool {
142+ tagsStr := strings .Split (strings .TrimSpace (required ), "," )
143+ for _ , tag := range tagsStr {
144+ if ! strings .Contains (have , tag ) {
145+ return false
146+ }
147+ }
148+ return true
149+ }
150+
148151func isDeployed (name string ) bool {
149152 path := NodePath (name )
150153 script := fmt .Sprintf ("cd %v && terraform output ip" , path )
0 commit comments