From da1870aec9dabd8168e36275c44ca16c0d0c00b8 Mon Sep 17 00:00:00 2001 From: Nandan Sridhar Date: Wed, 7 Aug 2019 13:25:27 -0700 Subject: [PATCH] dont export types --- cmd/apps/impapps/impapps.go | 34 ++++++++++++++++----------------- cmd/developers/impdev/impdev.go | 24 +++++++++++------------ cmd/products/impprod/impprod.go | 10 +++++----- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cmd/apps/impapps/impapps.go b/cmd/apps/impapps/impapps.go index b1d33828..45a55d03 100644 --- a/cmd/apps/impapps/impapps.go +++ b/cmd/apps/impapps/impapps.go @@ -13,10 +13,10 @@ import ( types "github.com/srinandan/apigeecli/cmd/types" ) -type App struct { +type application struct { Name string `json:"name,omitempty"` Status string `json:"status,omitempty"` - Credentials *[]Credential `json:"credentials,omitempty"` + Credentials *[]credential `json:"credentials,omitempty"` DeveloperID *string `json:"developerId,omitempty"` DisplayName string `json:"displayName,omitempty"` Attributes []types.Attribute `json:"attributes,omitempty"` @@ -24,8 +24,8 @@ type App struct { Scopes []string `json:"scopes,omitempty"` } -type Credential struct { - APIProducts []APIProduct `json:"apiProducts,omitempty"` +type credential struct { + APIProducts []apiProduct `json:"apiProducts,omitempty"` ConsumerKey string `json:"consumerKey,omitempty"` ConsumerSecret string `json:"consumerSecret,omitempty"` ExpiresAt int `json:"expiresAt,omitempty"` @@ -33,11 +33,11 @@ type Credential struct { Scopes []string `json:"scopes,omitempty"` } -type APIProduct struct { +type apiProduct struct { Name string `json:"apiproduct,omitempty"` } -type ImportCredential struct { +type importCredential struct { APIProducts []string `json:"apiProducts,omitempty"` ConsumerKey string `json:"consumerKey,omitempty"` ConsumerSecret string `json:"consumerSecret,omitempty"` @@ -66,7 +66,7 @@ func init() { _ = Cmd.MarkFlagRequired("file") } -func createAsyncApp(app App, wg *sync.WaitGroup) { +func createAsyncApp(app application, wg *sync.WaitGroup) { defer wg.Done() //importing an app will be a two step process. @@ -102,18 +102,18 @@ func createAsyncApp(app App, wg *sync.WaitGroup) { products = append(products, apiProduct.Name) } //create a new credential - importCredential := ImportCredential{} - importCredential.APIProducts = products - importCredential.ConsumerKey = credential.ConsumerKey - importCredential.ConsumerSecret = credential.ConsumerSecret - importCredential.Scopes = credential.Scopes + importCred := importCredential{} + importCred.APIProducts = products + importCred.ConsumerKey = credential.ConsumerKey + importCred.ConsumerSecret = credential.ConsumerSecret + importCred.Scopes = credential.Scopes - impCred, err := json.Marshal(importCredential) + impCredJSON, err := json.Marshal(importCred) if err != nil { shared.Error.Fatalln(err) return } - _, err = shared.HttpClient(true, u.String(), string(impCred)) + _, err = shared.HttpClient(true, u.String(), string(impCredJSON)) if err != nil { shared.Error.Fatalln(err) return @@ -124,7 +124,7 @@ func createAsyncApp(app App, wg *sync.WaitGroup) { } //batch creates a batch of apps to create -func batch(entities []App, pwg *sync.WaitGroup) { +func batch(entities []application, pwg *sync.WaitGroup) { defer pwg.Done() //batch workgroup @@ -180,9 +180,9 @@ func createApps() error { return nil } -func readAppsFile() ([]App, error) { +func readAppsFile() ([]application, error) { - apps := []App{} + apps := []application{} jsonFile, err := os.Open(file) diff --git a/cmd/developers/impdev/impdev.go b/cmd/developers/impdev/impdev.go index c4520260..9ced9152 100644 --- a/cmd/developers/impdev/impdev.go +++ b/cmd/developers/impdev/impdev.go @@ -13,7 +13,7 @@ import ( types "github.com/srinandan/apigeecli/cmd/types" ) -type Developer struct { +type developer struct { EMail string `json:"email,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` @@ -45,9 +45,9 @@ func init() { _ = Cmd.MarkFlagRequired("file") } -func createAsyncDeveloper(url string, developer Developer, wg *sync.WaitGroup) { +func createAsyncDeveloper(url string, dev developer, wg *sync.WaitGroup) { defer wg.Done() - out, err := json.Marshal(developer) + out, err := json.Marshal(dev) if err != nil { shared.Error.Fatalln(err) return @@ -58,11 +58,11 @@ func createAsyncDeveloper(url string, developer Developer, wg *sync.WaitGroup) { return } - shared.Info.Printf("Completed entity: %s", developer.EMail) + shared.Info.Printf("Completed entity: %s", dev.EMail) } //batch creates a batch of developers to create -func batch(url string, entities []Developer, pwg *sync.WaitGroup) { +func batch(url string, entities []developer, pwg *sync.WaitGroup) { defer pwg.Done() //batch workgroup @@ -118,14 +118,14 @@ func createDevelopers(url string) error { return nil } -func readDevelopersFile() ([]Developer, error) { +func readDevelopersFile() ([]developer, error) { - developers := []Developer{} + devs := []developer{} jsonFile, err := os.Open(file) if err != nil { - return developers, err + return devs, err } defer jsonFile.Close() @@ -133,15 +133,15 @@ func readDevelopersFile() ([]Developer, error) { byteValue, err := ioutil.ReadAll(jsonFile) if err != nil { - return developers, err + return devs, err } - err = json.Unmarshal(byteValue, &developers) + err = json.Unmarshal(byteValue, &devs) if err != nil { - return developers, err + return devs, err } - return developers, nil + return devs, nil } diff --git a/cmd/products/impprod/impprod.go b/cmd/products/impprod/impprod.go index 79c93f06..8f85ef15 100644 --- a/cmd/products/impprod/impprod.go +++ b/cmd/products/impprod/impprod.go @@ -13,7 +13,7 @@ import ( types "github.com/srinandan/apigeecli/cmd/types" ) -type Product struct { +type product struct { Name string `json:"name,omitempty"` DisplayName string `json:"displayName,omitempty"` ApprovalType string `json:"approvalType,omitempty"` @@ -47,7 +47,7 @@ func init() { _ = Cmd.MarkFlagRequired("file") } -func createAsyncProduct(url string, entity Product, wg *sync.WaitGroup) { +func createAsyncProduct(url string, entity product, wg *sync.WaitGroup) { defer wg.Done() out, err := json.Marshal(entity) if err != nil { @@ -63,7 +63,7 @@ func createAsyncProduct(url string, entity Product, wg *sync.WaitGroup) { } //batch creates a batch of products to create -func batch(url string, entities []Product, pwg *sync.WaitGroup) { +func batch(url string, entities []product, pwg *sync.WaitGroup) { defer pwg.Done() //batch workgroup @@ -119,9 +119,9 @@ func createProducts(url string) error { return nil } -func readProductsFile() ([]Product, error) { +func readProductsFile() ([]product, error) { - products := []Product{} + products := []product{} jsonFile, err := os.Open(file)