jrushford commented on a change in pull request #5352:
URL: https://github.com/apache/trafficcontrol/pull/5352#discussion_r536442669



##########
File path: traffic_ops_ort/plugin_verifier/plugin_verifier.go
##########
@@ -0,0 +1,287 @@
+package main
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import (
+       "bufio"
+       "fmt"
+       "github.com/apache/trafficcontrol/lib/go-log"
+       
"github.com/apache/trafficcontrol/traffic_ops_ort/plugin_verifier/config"
+       "io"
+       "io/ioutil"
+       "os"
+       "path/filepath"
+       "regexp"
+       "strings"
+)
+
+var (
+       cfg          config.Cfg
+       atsPlugins   = make(map[string]int)
+       pluginChecks = make(map[string]bool)
+       pluginParams = make(map[string]bool)
+)
+
+// This function accepts config line data from either ATS
+// a 'plugin.config' or a 'remap.config' format.
+//
+// It checks the configuration file line by line and verifies
+// that any specified plugin exists in the file system at the
+// complete file path or relative to the ATS plugins installation
+// directory. Also, any plugin arguments or plugin parameters that
+// end in '.config', '.cfg', or '.txt' are assumed to be plugin
+// configuration files and they will be verified that the exist
+// at the absolute path in the file name or relative to the ATS
+// configuration files directory.
+//
+// Returns '0' if all plugins on the config line successfully verify
+// otherwise, returns the the count of plugins that failed to verify.
+//
+func checkConfigLine(line string, lineNumber int) int {
+
+       pluginErrorCount := 0
+       exists := false
+       verified := false
+
+       log.Debugf("line: %s\n", line)
+
+       // create an array of whitespace delimited fields
+       l := regexp.MustCompile(`\s+`)
+       fields := l.Split(line, -1)
+       length := len(fields)
+
+       log.Debugf("length: %d, fields: %v", length, fields)
+
+       // processing a line from remap.config
+       if length > 3 && (fields[0] == "map" ||
+               fields[0] == "map_with_recv_port" ||
+               fields[0] == "map_with_referer" ||
+               fields[0] == "reverse_map" ||
+               fields[0] == "redirect" ||
+               fields[0] == "redirect_temporary") {
+
+               for ii := 3; ii < len(fields); ii++ {
+                       if strings.HasPrefix(fields[ii], "@plugin=") {
+                               sa := strings.Split(fields[ii], "=")
+                               key := strings.TrimSpace(sa[1])

Review comment:
       thanks good catch @ocket8888 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to