Skip to content

Commit

Permalink
changed to use --use-src-site=-oldsitename
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtkanaskie committed Dec 18, 2023
1 parent 0f7829f commit b284bfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cmd/apidocs/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_<siteid>.json and apidocs_<siteid>_<id>.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")
}
11 changes: 5 additions & 6 deletions internal/client/apidocs/apidocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand All @@ -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")
Expand Down

0 comments on commit b284bfe

Please sign in to comment.