Skip to content

Commit

Permalink
Merge branch 'main' into issue294
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Sep 19, 2023
2 parents 5c763d0 + 8991204 commit df04201
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/keyaliases/crtka.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var CreateCmd = &cobra.Command{
ignoreExpiry,
ignoreNewLine,
selfFile)
case "pem":
case "keycertfile", "pem":
_, err = keyaliases.CreateOrUpdateKeyCert(keystoreName,
name,
false,
Expand Down Expand Up @@ -93,7 +93,7 @@ func init() {
CreateCmd.Flags().StringVarP(&name, "alias", "s",
"", "Name of the key alias")
CreateCmd.Flags().StringVarP(&format, "format", "f",
"", "Format of the certificate; selfsignedcert, pem or pkcs12 (file extn is .pfx)")
"", "Format of the certificate; selfsignedcert, keycertfile (a.k.a pem), or pkcs12 (file extn is .pfx)")
CreateCmd.Flags().StringVarP(&password, "password", "p",
"", "PKCS12 password")
CreateCmd.Flags().BoolVarP(&ignoreExpiry, "exp", "x",
Expand Down
2 changes: 1 addition & 1 deletion cmd/keyaliases/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
CsrCmd.Flags().StringVarP(&keystoreName, "key", "k",
"", "Name of the key store")
CsrCmd.Flags().StringVarP(&aliasName, "alias", "s",
"", "Name of the key store")
"", "Name of the key alias")

_ = CsrCmd.MarkFlagRequired("alias")
_ = CsrCmd.MarkFlagRequired("key")
Expand Down
2 changes: 1 addition & 1 deletion cmd/keyaliases/getcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
GetctCmd.Flags().StringVarP(&keystoreName, "key", "k",
"", "Name of the key store")
GetctCmd.Flags().StringVarP(&aliasName, "alias", "s",
"", "Name of the key store")
"", "Name of the key alias")

_ = GetctCmd.MarkFlagRequired("alias")
_ = GetctCmd.MarkFlagRequired("key")
Expand Down
3 changes: 1 addition & 2 deletions cmd/keyaliases/getka.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ var GetCmd = &cobra.Command{
func init() {
GetCmd.Flags().StringVarP(&keystoreName, "key", "k",
"", "Name of the key store")

GetCmd.Flags().StringVarP(&aliasName, "alias", "s",
"", "Name of the key store")
"", "Name of the key alias")

_ = GetCmd.MarkFlagRequired("alias")
_ = GetCmd.MarkFlagRequired("key")
Expand Down
2 changes: 1 addition & 1 deletion cmd/keystores/impks.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (

func init() {
ImpCmd.Flags().StringVarP(&filePath, "file", "f",
"", "File containing API Products")
"", "File containing keystores")
ImpCmd.Flags().IntVarP(&conn, "conn", "c",
4, "Number of connections")

Expand Down
11 changes: 9 additions & 2 deletions cmd/preferences/setpref.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ var SetCmd = &cobra.Command{
return err
}

if err = apiclient.SetGithubURL(gitHubURL); err != nil {
return err
}

if nocheck {
if err = apiclient.SetNoCheck(nocheck); err != nil {
return err
Expand All @@ -45,8 +49,8 @@ var SetCmd = &cobra.Command{
}

var (
org, proxyURL string
usestage, nocheck bool
org, proxyURL, gitHubURL string
usestage, nocheck bool
)

func init() {
Expand All @@ -61,4 +65,7 @@ func init() {

SetCmd.Flags().BoolVarP(&nocheck, "nocheck", "",
false, "Don't check for newer versions of cmd")

SetCmd.Flags().StringVarP(&gitHubURL, "github", "g",
"", "On premises Github URL")
}
32 changes: 28 additions & 4 deletions internal/apiclient/clifile.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ type apigeeCLI struct {
LastCheck string `json:"lastCheck,omitempty"`
Org string `json:"defaultOrg,omitempty"`
Staging bool `json:"staging,omitempty"`
ProxyUrl string `json:"proxyUrl,omitempty"`
ProxyURL string `json:"proxyUrl,omitempty"`
GithubURL string `json:"githubURL,omitempty"`
Nocheck bool `json:"nocheck,omitempty" default:"false"`
}

Expand Down Expand Up @@ -69,8 +70,12 @@ func ReadPreferencesFile() (err error) {
UseStaging()
}

if cliPref.ProxyUrl != "" {
SetProxyURL(cliPref.ProxyUrl)
if cliPref.ProxyURL != "" {
SetProxyURL(cliPref.ProxyURL)
}

if cliPref.GithubURL != "" {
SetGithubURL(cliPref.GithubURL)
}

if cliPref.Org != "" {
Expand Down Expand Up @@ -195,7 +200,7 @@ func SetProxy(url string) (err error) {
return nil
}

cliPref.ProxyUrl = url
cliPref.ProxyURL = url
data, err := json.Marshal(&cliPref)
if err != nil {
clilog.Debug.Printf("Error marshalling: %v\n", err)
Expand All @@ -205,6 +210,25 @@ func SetProxy(url string) (err error) {
return WritePerferencesFile(data)
}

func SetGithubURL(url string) (err error) {
if url == "" {
return nil
}

cliPref.GithubURL = url
data, err := json.Marshal(&cliPref)
if err != nil {
clilog.Debug.Printf("Error marshalling: %v\n", err)
return err
}
clilog.Debug.Println("Writing ", string(data))
return WritePerferencesFile(data)
}

func GetGithubURL() string {
return cliPref.GithubURL
}

func GetPreferences() (err error) {
output, err := json.Marshal(&cliPref)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions internal/bundlegen/proxybundle/proxybundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"regexp"
"strings"

"internal/apiclient"
"internal/clilog"

"internal/bundlegen"
Expand Down Expand Up @@ -652,6 +654,15 @@ func GitHubImportBundle(owner string, repo string, repopath string, sharedflow b
client = github.NewClient(nil)
}

// set the url for on premises versions
if apiclient.GetGithubURL() != "" {
u, err := url.Parse(apiclient.GetGithubURL())
if err != nil {
return err
}
client.BaseURL = u
}

// 1. download the proxy
if err := downloadProxyFromRepo(client, ctx, owner, repo, repopath, sharedflow); err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions internal/client/keystores/keystores.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ func importKeystores(wg *sync.WaitGroup, jobs <-chan string, errs chan<- error)
errs <- err
continue
}
req, err = apiclient.SetAuthHeader(req)
if err != nil {
errs <- err
continue
}

resp, err := apiclient.ApigeeAPIClient.Do(req)
if err != nil {
Expand Down

0 comments on commit df04201

Please sign in to comment.