func clear() error { if err := filepath.Walk("public", func(path string, info os.FileInfo, err error) error { if err != nil { return err } if m, _ := regexp.MatchString("~$", path); m { return nil } // Remove auto-generated html files. m, err := regexp.MatchString(".html$", path) if err != nil { return err } if m { return os.Remove(path) } // Remove example resources that are copied. m, err = regexp.MatchString("^public/examples/_resources/images$", path) if err != nil { return err } if m { if err := os.RemoveAll(path); err != nil { return err } return filepath.SkipDir } return nil }); err != nil { return err } return nil }
func newProjectStep(data *WizardData) { fmt.Print("Enter name of new project: ") projectParam := &phraseapp.ProjectParams{} fmt.Scanln(&projectParam.Name) res, err := phraseapp.ProjectCreate(projectParam) if err != nil { success, match_err := regexp.MatchString("401", err.Error()) if match_err != nil { fmt.Println(err.Error()) panic(match_err.Error()) } if success { data.AccessToken = "" DisplayWizard(data, "", fmt.Sprintf("Argument Error: Your AccessToken '%s' has no write scope. Please create a new Access Token with read and write scope.", data.AccessToken)) } else { success, match_err := regexp.MatchString("Validation failed", err.Error()) if match_err != nil { fmt.Println(err.Error()) panic(match_err.Error()) } if success { DisplayWizard(data, "newProject", err.Error()) return } else { panic(err.Error()) } } } else { data.ProjectId = res.Id DisplayWizard(data, next(data), "") return } }
// 根据网址 获取内容,确定是否需要进一步处理 func getBody(url string) (string, string, error) { //根据url首先判断是否读取 if strings.Contains(url, ".hqew.com/ic") { res, err := http.Get(url) if err != nil { fmt.Println("connect error") log.Fatal(err) } robots, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println("connect error") log.Fatal(err) } res.Body.Close() body := string(robots) if len(body) == 0 { fmt.Println("null body") } // isMatch_stock, _ := regexp.MatchString( `xh ic_ico1`, body) isMatch_black, _ := regexp.MatchString( `target="_blank" class="g_fb"`, body) //isMatch := isMatch_stock || isMatch_black if isMatch_stock == true { return body, "stock", nil } else if isMatch_black == true { return "NotStock", "black", nil } return "", "false", nil } else { return "", "false", nil } }
func main() { if len(os.Args) != 2 { fmt.Println("Please select one picture to makeascii...") return } fileName := os.Args[1] isJpeg, _ := regexp.MatchString(".+\\.jpg", fileName) isPng, _ := regexp.MatchString(".+\\.png", fileName) var picture image.Image var imageErr error fileIn, errIn := os.Open(fileName) if errIn != nil { fmt.Println(errIn.Error()) return } if isJpeg { picture, imageErr = jpeg.Decode(fileIn) } else if isPng { picture, imageErr = png.Decode(fileIn) } else { fmt.Println("File type is not supported...") return } if imageErr != nil { fmt.Println(imageErr.Error()) return } fmt.Print(MakeAscii(GetImage(picture))) }
func TestAudit(t *testing.T) { var buf bytes.Buffer attributeGetter := apiserver.NewRequestAttributeGetter(&fakeRequestContextMapper{}, &apiserver.RequestInfoResolver{APIPrefixes: sets.NewString("api", "apis"), GrouplessAPIPrefixes: sets.NewString("api")}) handler := WithAudit(&fakeHTTPHandler{}, attributeGetter, &buf) req, _ := http.NewRequest("GET", "/api/v1/namespaces/default/pods", nil) req.RemoteAddr = "127.0.0.1" handler.ServeHTTP(httptest.NewRecorder(), req) line := strings.Split(strings.TrimSpace(buf.String()), "\n") if len(line) != 2 { t.Fatalf("Unexpected amount of lines in audit log: %d", len(line)) } match, err := regexp.MatchString(`[\d\:\-\.\+TZ]+ AUDIT: id="[\w-]+" ip="127.0.0.1" method="GET" user="******" as="<self>" asgroups="<lookup>" namespace="default" uri="/api/v1/namespaces/default/pods"`, line[0]) if err != nil { t.Errorf("Unexpected error matching first line: %v", err) } if !match { t.Errorf("Unexpected first line of audit: %s", line[0]) } match, err = regexp.MatchString(`[\d\:\-\.\+TZ]+ AUDIT: id="[\w-]+" response="200"`, line[1]) if err != nil { t.Errorf("Unexpected error matching second line: %v", err) } if !match { t.Errorf("Unexpected second line of audit: %s", line[1]) } }
func TestMutexProfile(t *testing.T) { old := runtime.SetMutexProfileFraction(1) defer runtime.SetMutexProfileFraction(old) if old != 0 { t.Fatalf("need MutexProfileRate 0, got %d", old) } blockMutex() var w bytes.Buffer Lookup("mutex").WriteTo(&w, 1) prof := w.String() if !strings.HasPrefix(prof, "--- mutex:\ncycles/second=") { t.Errorf("Bad profile header:\n%v", prof) } prof = strings.Trim(prof, "\n") lines := strings.Split(prof, "\n") if len(lines) != 6 { t.Errorf("expected 6 lines, got %d %q\n%s", len(lines), prof, prof) } if len(lines) < 6 { return } // checking that the line is like "35258904 1 @ 0x48288d 0x47cd28 0x458931" r2 := `^\d+ 1 @(?: 0x[[:xdigit:]]+)+` //r2 := "^[0-9]+ 1 @ 0x[0-9a-f x]+$" if ok, err := regexp.MatchString(r2, lines[3]); err != nil || !ok { t.Errorf("%q didn't match %q", lines[3], r2) } r3 := "^#.*runtime/pprof_test.blockMutex.*$" if ok, err := regexp.MatchString(r3, lines[5]); err != nil || !ok { t.Errorf("%q didn't match %q", lines[5], r3) } }
func checkFunParam(fun type_sqlfun) { switch fun.name { case "regsub": if len(fun.params) != 3 { parseError(fun.name + " function params error") } re := regexp.MustCompile("^\\$\\d{1,3}") if !re.MatchString(fun.params[0]) { parseError(fun.name + " function params error") } case "strsub": if len(fun.params) > 3 || len(fun.params) < 2 { parseError(fun.name + " function params num error") } m, _ := regexp.MatchString("^\\$\\d{1,3}", fun.params[0]) fp("^\\$\\d{1,3}") if !m { parseError(fun.name + " function params error") } case "count,sum,avg,max,min": if len(fun.params) != 1 { parseError(fun.name + " function params error") } m, _ := regexp.MatchString("^\\$\\d{1,3}", fun.params[0]) if !m { parseError(fun.name + " function params error") } } }
func (c *CollectdJSON) GetMetricName(index int) string { metricName := c.Host + "_" + c.Plugin if len(c.PluginInstance) > 0 { if matched, _ := regexp.MatchString(`^\d+$`, c.PluginInstance); matched { metricName += c.PluginInstance } else { metricName += "_" + c.PluginInstance } } tSize := len(c.Type) pSize := len(c.Plugin) if tSize > 0 { if pSize <= tSize && c.Type[:pSize] == c.Plugin { metricName += c.Type[pSize:] } else { metricName += "." + c.Type } } if len(c.TypeInstance) > 0 { if matched, _ := regexp.MatchString(`^\d+$`, c.TypeInstance); matched { metricName += c.TypeInstance } else { metricName += "_" + c.TypeInstance } } if c.DataSetNames[index] != "value" { metricName += "." + c.DataSetNames[index] } return metricName }
func detectProdConfig(useosxt bool) string { var levelUp string var curDir string sep := string(filepath.Separator) if useosxt { curDir, _ = os.Getwd() } else { curDir, _ = osext.ExecutableFolder() } //detect from test or console match, _ := regexp.MatchString("_test", curDir) matchArgs, _ := regexp.MatchString("arguments", curDir) matchTestsDir, _ := regexp.MatchString("tests", curDir) if match || matchArgs || matchTestsDir { if matchTestsDir { levelUp = ".." } curDir, _ = filepath.Abs(curDir + sep + levelUp + sep) } CurrDirectory = curDir configDir, _ := filepath.Abs(curDir + sep + CONFIG_DIR + sep) appConfig := configDir + sep + CONFIG_FILE appProdConfig := configDir + sep + PRODUCTION_FOLDER + sep + CONFIG_FILE if fileExists(appProdConfig) { appConfig = appProdConfig } else if !useosxt { appConfig = detectProdConfig(true) } return appConfig }
func TestUserSetRoleWithNoVal_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "no username test", "username test role network-admin nopassword", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } user := User(dut) config := user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1 role network-admin nopassword`, config); !found { t.Fatalf("\"username test privilege 1\" expected but not seen under "+ "user section.\n[%s]", config) } if ok := user.SetRole("test", ""); !ok { t.Fatalf("SetRole config for user failed") } config = user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1 role network-admin nopassword`, config); found { t.Fatalf("\"username test privilege 1 role network-admin nopasswd\" expected but not seen under "+ "user section.\n[%s]", config) } } }
func TestUserSetSSHKeyWithNoVal_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "no username test", "username test nopassword", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } user := User(dut) config := user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1 nopassword`, config); !found { t.Fatalf("\"username test privilege 1\" expected but not seen under "+ "user section.\n[%s]", config) } if ok := user.SetSshkey("test", ""); !ok { t.Fatalf("SetSshkey config for user failed") } config = user.GetSection() configStr := "username test sshkey " + regexp.QuoteMeta(testSSHKey) if found, _ := regexp.MatchString(configStr, config); found { t.Fatalf("\"%s\" NOT expected but not seen under "+ "user section.\n[%s]", configStr, config) } } }
func TestUserSetPrivWithInvalidVal_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "no username test", "username test privilege 8 nopassword", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } user := User(dut) config := user.GetSection() if found, _ := regexp.MatchString(`username test privilege 8 nopassword`, config); !found { t.Fatalf("\"username test privilege 8\" expected but not seen under "+ "user section.\n[%s]", config) } if ok, err := user.SetPrivilege("test", 65535); ok || err == nil { t.Fatalf("SetPrivilege config for user failed") } config = user.GetSection() if found, _ := regexp.MatchString(`username test privilege 8 nopassword`, config); !found { t.Fatalf("\"username test privilege 8 nopasswd\" expected but not seen under "+ "user section.\n[%s]", config) } } }
func TestUserDelete_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "no username test", "username test nopassword", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } user := User(dut) config := user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1 nopassword`, config); !found { t.Fatalf("\"username test privilege 1\" expected but not seen under "+ "user section.\n[%s]", config) } if ok := user.Delete("test"); !ok { t.Fatalf("Delete of user failed") } config = user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1 nopassword`, config); found { t.Fatalf("\"username test privilege 1\" expected but not seen under "+ "user section.\n[%s]", config) } } }
func TestUserCreateWithSecret_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "no username test", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } user := User(dut) config := user.GetSection() if found, _ := regexp.MatchString(`username test privilege 1`, config); found { t.Fatalf("\"username test privilege 1\" NOT expected but not seen under "+ "user section.\n[%s]", config) } if ok, err := user.CreateWithSecret("test", "password", "cleartext"); !ok || err != nil { t.Fatalf("CreateWithSecret of user failed") } config = user.GetSection() if found, _ := regexp.MatchString(`username test`, config); !found { t.Fatalf("\"username test privilege 1\" expected but not seen under "+ "user section.\n[%s]", config) } } }
func parseStartLink() { fmt.Println("Input url: ") fmt.Scanf("%s", &url) firstDoc, err := goquery.NewDocument(url) checkerr(err) firstDoc.Find("tbody").Each(func(i int, tbody *goquery.Selection) { tbody.Find(".description").Each(func(j int, s *goquery.Selection) { link, _ := s.Find("a").Attr("href") x, _ := regexp.MatchString(`https://www.exploit-db.com/exploits/.....`, link) if x == true { file, err := os.OpenFile("temp.txt", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666) checkerr(err) _, err = file.WriteString(link + "\n") checkerr(err) file.Close() } y, _ := regexp.MatchString(`/docs/......pdf`, link) if y == true { wasteUrl, err := os.OpenFile("waste.txt", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0666) checkerr(err) _, err = wasteUrl.WriteString(link) checkerr(err) wasteUrl.Close() } }) }) }
// This method implements binding.Validator and is executed by the binding.Validate middleware func (up UserPost) Validate(errors *binding.Errors, req *http.Request) { if len(up.UName) < 4 { errors.Fields["uname"] = "Too short; minimum 4 characters" } else if len(up.UName) > 30 { errors.Fields["uname"] = "Too long; maximum 30 characters" } if m, _ := regexp.MatchString("^[0-9a-zA-Z]+$", up.UName); !m { errors.Fields["uname"] = "only alpha number" } if len(up.UPwd) < 4 { errors.Fields["upwd"] = "Too short; minimum 4 characters" } else if len(up.UPwd) > 30 { errors.Fields["upwd"] = "Too long; maximum 30 characters" } if m, _ := regexp.MatchString("^[0-9a-zA-Z]+$", up.UPwd); !m { errors.Fields["upwd"] = "only alpha number" } if len(up.UEmail) < 4 { errors.Fields["uemail"] = "Too short; minimum 4 characters" } else if len(up.UEmail) > 30 { errors.Fields["uemail"] = "Too long; maximum 30 characters" } if m, _ := regexp.MatchString(`^([\w\.\_]{2,10})@(\w{1,}).([a-z]{2,4})$`, up.UEmail); !m { errors.Fields["uemail"] = "It is not correct email adress" } }
func TestAclRemoveEntry_SystemTest(t *testing.T) { cmds := []string{ "no ip access-list standard test", "ip access-list standard test", "10 permit any log", } for _, dut := range duts { if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } acl := Acl(dut) ret, _ := acl.Get("test") if ret == nil { t.Fatalf("Expecting non-nil value from acl.Get().") } section := acl.GetSection("test") if found, _ := regexp.MatchString("10 permit any log", section); !found { t.Fatalf("Acl section is missing [10 permit any log].") } if ok := acl.RemoveEntry("test", 10); !ok { t.Fatalf("acl.RemoveEntry failure.") } section = acl.GetSection("test") if found, _ := regexp.MatchString("10 permit any log", section); found { t.Fatalf("Config seen in section after RemoveEntry().") } } }
func handleFileChange(event fsnotify.Event) { validC, _ := regexp.MatchString(validCString, event.Name) validH, _ := regexp.MatchString(validHString, event.Name) db := <-writer defer func() { writer <- db }() switch { case validC: switch { case event.Op&(fsnotify.Create|fsnotify.Write) != 0: files <- event.Name case event.Op&(fsnotify.Remove|fsnotify.Rename) != 0: db.RemoveFileReferences(event.Name) } case validH: exist, uptodate, _, err := db.UptodateFile(event.Name) switch { case err != nil: return case event.Op&(fsnotify.Write) != 0: if exist && !uptodate { removeFileAndReparseDepends(filepath.Clean(event.Name), db) } case event.Op&(fsnotify.Remove|fsnotify.Rename) != 0: if exist { removeFileAndReparseDepends(filepath.Clean(event.Name), db) } } } }
// invalidBucketToError - invalid bucket to errorResponse func invalidBucketError(bucket string) error { // verify bucket name in accordance with // - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html isValidBucket := func(bucket string) bool { if len(bucket) < 3 || len(bucket) > 63 { return false } if bucket[0] == '.' || bucket[len(bucket)-1] == '.' { return false } if match, _ := regexp.MatchString("\\.\\.", bucket); match == true { return false } // We don't support buckets with '.' in them match, _ := regexp.MatchString("^[a-zA-Z][a-zA-Z0-9\\-]+[a-zA-Z0-9]$", bucket) return match } if !isValidBucket(strings.TrimSpace(bucket)) { // no resource since bucket is empty string errorResponse := ErrorResponse{ Code: "InvalidBucketName", Message: "The specified bucket is not valid.", RequestID: "minio", } return errorResponse } return nil }
//ReadTxt ... func ReadTxt(logPath string) ([]byte, error) { var r string var flag bool = false file, err := os.OpenFile(logPath, os.O_RDONLY, 0666) if err != nil { panic(err) } defer file.Close() reader := bufio.NewReader(file) for { str, err := reader.ReadSlice('\n') if m, _ := regexp.MatchString("^\\/\\*", string(str)); m { flag = false continue } if m, _ := regexp.MatchString("^\\*\\/", string(str)); m { flag = true continue } if flag { r = r + " " + string(str) } if err != nil { break } } return []byte(r), err }
func (u RegisterInput) IsValid() (err error) { //Empty Fields if u.Email == "" { err = errors.New("Error: Missing Email") return } if u.Username == "" { err = errors.New("Error: Missing Username") return } if u.Password == "" { err = errors.New("Error: Missing Password") return } //RegExp Check //Valid Email email, _ := regexp.MatchString(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`, u.Email) if email == false { err = errors.New("Invalid email") return } //Username user, _ := regexp.MatchString(`^[A-Za-z0-9_-]{0,25}$`, u.Username) if user == false { err = errors.New("Invalid email") return } return nil }
//遍历所有文件及文件夹 func getSha(listpath string, pathpass []string, filepass []string) { infos, _ := ioutil.ReadDir(listpath) for _, info := range infos { if info.IsDir() { //isDir=true path := listpath + "/" + info.Name() b := false for _, pass := range pathpass { b, _ = regexp.MatchString(pass, path) } if !b { getSha(path, pathpass, filepass) } } else { str := listpath + "/" + info.Name() + "," + getSHA1(listpath) + "," + getSize(info) b := false for _, pass := range filepass { b, _ = regexp.MatchString(pass, info.Name()) } if b { continue } listfile = append(listfile, str) } } }
func (r rssMatcher) Search(feed *search.Feed, term string) ([]*search.Result, error) { var results []*search.Result log.Printf("%s\n", feed) document, err := r.retrieve(feed) if err != nil { return nil, err } for _, channelItem := range document.Channel.Item { matched, err := regexp.MatchString(term, channelItem.Title) if err != nil { return nil, err } if matched { results = append(results, &search.Result{ Field: "Title", Content: channelItem.Title, }) } matched, err = regexp.MatchString(term, channelItem.Description) if err != nil { return nil, err } if matched { results = append(results, &search.Result{ Field: "Description", Content: channelItem.Description, }) } } return results, nil }
//只要两个的groupId和topic相同就认为是重复了, //因为不应该存在一个groupId对应多个messagetype的情况 func (self *Binding) conflict(bind *Binding) bool { if self.GroupId == bind.GroupId && self.Topic == bind.Topic { //如果两个都是正则类型的、或者其中一个是fanout的则直接返回冲突, if (bind.BindType == self.BindType && bind.BindType == BIND_REGX) || (bind.BindType == BIND_FANOUT || self.BindType == BIND_FANOUT) { return true } else { //self 或者bind 其中有一个是正则,则匹配是否有交叉 if bind.BindType == BIND_REGX { conflict, err := regexp.MatchString(bind.MessageType, self.MessageType) if nil != err { return true } return conflict } else { conflict, err := regexp.MatchString(self.MessageType, bind.MessageType) if nil != err { return true } return conflict } } } return false }
func TestDialError(t *testing.T) { if !*runErrorTest { t.Logf("test disabled; use -run_error_test to enable") return } for i, tt := range dialErrorTests { c, err := Dial(tt.Net, tt.Raddr) if c != nil { c.Close() } if err == nil { t.Errorf("#%d: nil error, want match for %#q", i, tt.Pattern) continue } s := err.Error() match, _ := regexp.MatchString(tt.Pattern, s) if !match { t.Errorf("#%d: %q, want match for %#q", i, s, tt.Pattern) } match, _ = regexp.MatchString(duplicateErrorPattern, s) if match { t.Errorf("#%d: %q, duplicate error return from Dial", i, s) } } }
func createReviewPost(json []byte, token string, baseUrl string) (string, bool) { restUrl := fmt.Sprintf(urls["crucible-create-review"], baseUrl, token) client := &http.Client{} req, err := http.NewRequest("POST", restUrl, bytes.NewBuffer(json)) req.Header.Add("Content-Type", "application/json") req.Header.Add("Accept", "application/json") resp, err := client.Do(req) if err != nil { exitError(msg["unable-to-create"], err) } body, err := ioutil.ReadAll(resp.Body) if err != nil { exitError(msg["bad-response"], err) } if hasStatus, _ := regexp.MatchString("status-code", string(body)); hasStatus { re := regexp.MustCompile(regex["status-code"]) status := re.FindStringSubmatch(string(body)) if status != nil && len(status) > 1 { return status[1], false } } if hasPermaId, _ := regexp.MatchString("permaId", string(body)); hasPermaId { re := regexp.MustCompile(regex["perma-id"]) permaId := re.FindStringSubmatch(string(body)) if permaId != nil && len(permaId) > 1 { return permaId[1], true } } return "", false }
func (s *DockerServer) handlerWrapper(f func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { return func(w http.ResponseWriter, r *http.Request) { for errorID, urlRegexp := range s.failures { matched, err := regexp.MatchString(urlRegexp, r.URL.Path) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } if !matched { continue } http.Error(w, errorID, http.StatusBadRequest) return } for i, failure := range s.multiFailures { matched, err := regexp.MatchString(failure["url"], r.URL.Path) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } if !matched { continue } http.Error(w, failure["error"], http.StatusBadRequest) s.multiFailures = append(s.multiFailures[:i], s.multiFailures[i+1:]...) return } f(w, r) } }
// computeErrorLocation implements a heuristic to find the location in the user // code where the error occurred. It walks back the callstack until the file // doesn't match "/goa/design/*.go". // When successful it returns the file name and line number, empty string and // 0 otherwise. func computeErrorLocation() (file string, line int) { depth := 2 _, file, line, _ = runtime.Caller(depth) ok := strings.HasSuffix(file, "_test.go") // Be nice with tests if !ok { nok, _ := regexp.MatchString(`/goa/design/.+\.go$`, file) ok = !nok } for !ok { depth++ _, file, line, _ = runtime.Caller(depth) ok = strings.HasSuffix(file, "_test.go") if !ok { nok, _ := regexp.MatchString(`/goa/design/.+\.go$`, file) ok = !nok } } wd, err := os.Getwd() if err != nil { return } wd, err = filepath.Abs(wd) if err != nil { return } f, err := filepath.Rel(wd, file) if err != nil { return } file = f return }
// LoadCluster fetches the latest data/state for specific cluster func (s *StateEtcd) LoadCluster(instanceID structs.ClusterID) (cluster structs.ClusterState, err error) { ctx := context.Background() s.logger.Info("state.load-cluster") key := fmt.Sprintf("%s/service/%s", s.prefix, instanceID) resp, err := s.etcdApi.Get(ctx, key, &etcd.GetOptions{Recursive: true}) if err != nil { s.logger.Error("state.load-cluster.error", err) return } nodes := []*structs.Node{} for _, path := range resp.Node.Nodes { if match, _ := regexp.MatchString(fmt.Sprintf("%s/state", key), path.Key); match == true { json.Unmarshal([]byte(path.Value), &cluster) } if match, _ := regexp.MatchString(fmt.Sprintf("%s/nodes", key), path.Key); match == true { for _, member := range path.Nodes { var node structs.Node json.Unmarshal([]byte(member.Value), &node) if node.ID != "" && node.CellGUID != "" { nodes = append(nodes, &node) } } } } cluster.Nodes = nodes return }
func TestMlagPeerLinkPortChannel_SystemTest(t *testing.T) { for _, dut := range duts { cmds := []string{ "default mlag configuration", "interface Port-Channel5", } if ok := dut.Config(cmds...); !ok { t.Fatalf("dut.Config() failure") } mlag := Mlag(dut) section := mlag.GetSection() if found, _ := regexp.MatchString("no peer-link", section); !found { t.Fatalf("\"no peer-link\" expected but not seen in Mlag "+ "configuration.\n[%s]", section) } if ok := mlag.SetPeerLink("Port-Channel5"); !ok { t.Fatalf("Failure setting Port-Channel5 for peer-link") } section = mlag.GetSection() if found, _ := regexp.MatchString("peer-link Port-Channel5", section); !found { t.Fatalf("\"peer-link Port-Channel5\" expected but not seen "+ "under mlag section.\n[%s]", section) } } }