Skip to content
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

Check for cluster name in annotations #134

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

kinarashah
Copy link
Member

No description provided.

@@ -30,6 +30,13 @@ func ObjectInCluster(cluster string, obj interface{}) bool {
}
}
}
if clusterName == "" {
if c := getValue(obj, "Annotations").MapIndex(reflect.ValueOf("field.cattle.io/projectId")); c.IsValid() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the object does not have Annotations field this may panic. Just happens that all objects have it, but I'd rather check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @ibuildthecloud, updated

if clusterName == "" {
if a := getValue(obj, "Annotations"); a.IsValid() {
if c := a.MapIndex(reflect.ValueOf("field.cattle.io/projectId")); c.IsValid() {
logrus.Info(c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

if parts := strings.SplitN(c.String(), ":", 2); len(parts) == 2 {
clusterName = parts[0]
}
logrus.Info(clusterName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there

@kinarashah
Copy link
Member Author

@ibuildthecloud done

@ibuildthecloud ibuildthecloud merged commit 93bfc4e into rancher:master Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants