Skip to content

Commit 0f61670

Browse files
authored
fixes issue where the wrong tranfsormation is returned (#62)
This commit fixes an issue where the wrong transformation is returned. This situation can happen when a transformation in a project and a transformation in the global space both have the same name.
1 parent 300c563 commit 0f61670

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

pkg/services/transformations.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"net/http"
11+
"strings"
1112

1213
"github.com/itential/ipctl/pkg/client"
1314
"github.com/itential/ipctl/pkg/logger"
@@ -144,7 +145,20 @@ func (svc *TransformationService) GetByName(name string) (*Transformation, error
144145
return nil, errors.New("transformation not found")
145146
}
146147

147-
return &res.Results[0], nil
148+
var selected *Transformation
149+
150+
for _, ele := range res.Results {
151+
if !strings.HasPrefix(ele.Name, "@") {
152+
selected = &ele
153+
break
154+
}
155+
}
156+
157+
if selected == nil {
158+
return nil, errors.New("transformation not found")
159+
}
160+
161+
return selected, nil
148162
}
149163

150164
// Create all attempt to create a new transformation on the server. This

0 commit comments

Comments
 (0)