Skip to content

Commit 6bf7b0b

Browse files
author
Phillip Wittrock
authored
Merge pull request #49 from briantkennedy/master
Fix an issue in types.ReconcileKey.String()
2 parents ed1c5d9 + f53d2c3 commit 6bf7b0b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/controller/types/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,17 @@ type ReconcileKey struct {
3737
}
3838

3939
func (r ReconcileKey) String() string {
40+
if r.Namespace == "" {
41+
return r.Name
42+
}
4043
return r.Namespace + "/" + r.Name
4144
}
45+
46+
// ParseReconcileKey returns the ReconcileKey that has been encoded into a string.
47+
func ParseReconcileKey(key string) (ReconcileKey, error) {
48+
namespace, name, err := cache.SplitMetaNamespaceKey(key)
49+
if err != nil {
50+
return ReconcileKey{}, err
51+
}
52+
return ReconcileKey{Name: name, Namespace: namespace}, nil
53+
}

0 commit comments

Comments
 (0)