From b284bfe1617e7ab4a91baec3a9f53f8740951e64 Mon Sep 17 00:00:00 2001 From: Kurt Kanaskie Date: Mon, 18 Dec 2023 14:58:32 -0500 Subject: [PATCH] changed to use --use-src-site=-oldsitename --- cmd/apidocs/import.go | 8 ++++---- internal/client/apidocs/apidocs.go | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/apidocs/import.go b/cmd/apidocs/import.go index 18f7232d8..65de3598e 100644 --- a/cmd/apidocs/import.go +++ b/cmd/apidocs/import.go @@ -48,16 +48,16 @@ var ImpCmd = &cobra.Command{ return apiclient.SetApigeeOrg(org) }, RunE: func(cmd *cobra.Command, args []string) error { - return apidocs.Import(siteid, useNewSiteID, folder) + return apidocs.Import(siteid, useSrcSiteID, folder) }, } -var useNewSiteID bool +var useSrcSiteID string func init() { ImpCmd.Flags().StringVarP(&folder, "folder", "f", "", "Folder containing site_.json and apidocs__.json files") - ImpCmd.Flags().BoolVarP(&useNewSiteID, "use-new-siteid", "", - false, "Use new siteid when importing; useful whem importing data between two orgs") + ImpCmd.Flags().StringVarP(&useSrcSiteID, "use-src-siteid", "", + "", "Use source siteid when importing; useful whem importing data between two orgs") _ = ImpCmd.MarkFlagRequired("folder") } diff --git a/internal/client/apidocs/apidocs.go b/internal/client/apidocs/apidocs.go index e208694ae..9de5654b1 100644 --- a/internal/client/apidocs/apidocs.go +++ b/internal/client/apidocs/apidocs.go @@ -350,14 +350,13 @@ apigeecli apidocs import -o org2 -s site1 --source-f . --use-new-siteid=true -t */ // Import -func Import(siteid string, useNewSiteID bool, folder string) (err error) { +func Import(siteid string, useSrcSiteID string, folder string) (err error) { var errs []string var respBody []byte var docsList []data - if useNewSiteID { - apiDocsName := fmt.Sprintf("site_%s-%s.json", apiclient.GetApigeeOrg(), siteid) - docsList, err = readAPIDocsDataFile(path.Join(folder, apiDocsName)) + if useSrcSiteID != "" { + docsList, err = readAPIDocsDataFile(path.Join(folder, "site_"+useSrcSiteID+".json")) } else { docsList, err = readAPIDocsDataFile(path.Join(folder, "site_"+siteid+".json")) } @@ -384,8 +383,8 @@ func Import(siteid string, useNewSiteID bool, folder string) (err error) { // 2. find the documentation associated with this site var documentationFileName string - if useNewSiteID { - apiDocsName := fmt.Sprintf("apidocs_%s-%s_%s.json", apiclient.GetApigeeOrg(), siteid, doc.ID) + if useSrcSiteID != "" { + apiDocsName := fmt.Sprintf("apidocs_%s_%s.json", useSrcSiteID, doc.ID) documentationFileName = path.Join(folder, apiDocsName) } else { documentationFileName = path.Join(folder, "apidocs_"+siteid+"_"+doc.ID+".json")