func searchInArtifactory(specFile string) (result []commands.SearchResult, err error) { searchFlags := new(commands.SearchFlags) searchFlags.ArtDetails = artifactoryDetails searchSpec, _ := utils.CreateSpecFromFile(specFile) result, err = commands.Search(searchSpec, searchFlags) return }
func searchCmd(c *cli.Context) { if c.NArg() > 0 && c.IsSet("spec") { cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage()) } if !(c.NArg() == 1 || (c.NArg() == 0 && c.IsSet("spec"))) { cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage()) } var searchSpec *utils.SpecFiles if c.IsSet("spec") { var err error searchSpec, err = getSearchSpec(c) cliutils.ExitOnErr(err) } else { searchSpec = createDefaultSearchSpec(c) } flags, err := createSearchFlags(c) cliutils.ExitOnErr(err) SearchResult, err := commands.Search(searchSpec, flags) cliutils.ExitOnErr(err) result, err := json.Marshal(SearchResult) cliutils.ExitOnErr(err) fmt.Println(string(cliutils.IndentJson(result))) }
func isExistInArtifactoryByProps(expected []string, pattern, props string, t *testing.T) { searchFlags := new(commands.SearchFlags) searchFlags.ArtDetails = artifactoryDetails searchSpec := utils.CreateSpec(pattern, "", props, true, false, false) results, err := commands.Search(searchSpec, searchFlags) if err != nil { t.Error(err) } tests.CompareExpectedVsActuals(expected, results, t) }