Skip to content

Commit bed3312

Browse files
committed
Fixed code review findings
1 parent 14b3165 commit bed3312

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cmd/servicelog/post.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (o *PostCmdOptions) Run() error {
211211
clusterType := cluster.Product().ID()
212212

213213
if docClusterType != clusterType {
214-
log.Info("The documentation link in the servicelog is for '", docClusterType, "' while the servicelog itself is for cluster type '", clusterType, "'.")
214+
log.Warn("The documentation mentioned in the servicelog is for '", docClusterType, "' while the product is '", clusterType, "'.")
215215
if !ocmutils.ConfirmPrompt() {
216216
log.Info("Skipping cluster ID: ", cluster.ID(), ", Name: ", cluster.Name())
217217
continue
@@ -234,23 +234,23 @@ func (o *PostCmdOptions) Run() error {
234234

235235
// if servicelog description contains documentation link, parse and return the cluster type from the url
236236
func getDocClusterType(message string) string {
237-
descSubstrings := strings.Split(message, " ")
238237

239-
for _, s := range descSubstrings {
240-
if strings.Contains(s, documentationBaseURL) {
241-
t := strings.Split(s, "/")
242-
p := t[3]
243-
if p == "dedicated" {
238+
if strings.Contains(message, documentationBaseURL) {
239+
pattern := `https://docs.openshift.com/([^/]+)/`
240+
re := regexp.MustCompile(pattern)
241+
match := re.FindStringSubmatch(message)
242+
if len(match) >= 2 {
243+
productType := match[1]
244+
if productType == "dedicated" {
244245
// the documentation urls for osd use "dedicated" as the differentiator
245246
// e.g. https://docs.openshift.com/dedicated/welcome/index.html
246247
// for proper comparison with cluster product types, return "osd"
247248
// where "dedicated" is used in the documentation urls
248-
p = "osd"
249+
productType = "osd"
249250
}
250-
return p
251+
return productType
251252
}
252253
}
253-
254254
return ""
255255
}
256256

0 commit comments

Comments
 (0)