Skip to content

Commit

Permalink
Merge pull request #25 from replicatedhq/names
Browse files Browse the repository at this point in the history
CollectorName is optional
  • Loading branch information
divolgin authored Jul 24, 2019
2 parents c6d16b7 + 7951c1c commit ad14283
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion cmd/preflight/cli/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,5 @@ func removeServiceAccount(name string, namespace string, clientset *kubernetes.C
return err
}


return nil
}
1 change: 0 additions & 1 deletion cmd/troubleshoot/cli/run_nocrd.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func runCollectors(v *viper.Viper, collector troubleshootv1beta1.Collector) (str
s := runtime.NewScheme()
s.AddKnownTypes(schema.GroupVersion{Group: "", Version: "v1"}, &corev1.ConfigMap{})
for _, collect := range desiredCollectors {
fmt.Printf("creating collector\n")
_, pod, err := collectrunner.CreateCollector(client, s, &owner, collector.Name, v.GetString("namespace"), serviceAccountName, "troubleshoot", collect, v.GetString("image"), v.GetString("pullpolicy"))
if err != nil {
fmt.Printf("A collector pod cannot be created: %v\n", err)
Expand Down
15 changes: 12 additions & 3 deletions pkg/collect/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@ func DeterministicIDForCollector(collector *troubleshootv1beta1.Collect) string
}

if collector.Run != nil {
unsafeID = fmt.Sprintf("run-%s", strings.ToLower(collector.Run.CollectorName))
unsafeID = "run"
if collector.Run.CollectorName != "" {
unsafeID = fmt.Sprintf("%s-%s", unsafeID, strings.ToLower(collector.Run.CollectorName))
}
}

if collector.Exec != nil {
unsafeID = fmt.Sprintf("exec-%s", strings.ToLower(collector.Exec.CollectorName))
unsafeID = "exec"
if collector.Exec.CollectorName != "" {
unsafeID = fmt.Sprintf("%s-%s", unsafeID, strings.ToLower(collector.Exec.CollectorName))
}
}

if collector.Copy != nil {
unsafeID = fmt.Sprintf("copy-%s-%s", selectorToString(collector.Copy.Selector), pathToString(collector.Copy.ContainerPath))
}

if collector.HTTP != nil {
unsafeID = fmt.Sprintf("http-%s", strings.ToLower(collector.HTTP.CollectorName))
unsafeID = "http"
if collector.HTTP.CollectorName != "" {
unsafeID = fmt.Sprintf("%s-%s", unsafeID, strings.ToLower(collector.HTTP.CollectorName))
}
}

return rfc1035(unsafeID)
Expand Down

0 comments on commit ad14283

Please sign in to comment.