Skip to content

Commit

Permalink
cli: fix tls config of api client
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptonist authored Feb 22, 2021
1 parent 867d102 commit 5fb2645
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,15 @@ func (ec *ExecutionContext) Validate() error {
if !strings.HasSuffix(ec.Config.Endpoint, "/") {
ec.Config.Endpoint = fmt.Sprintf("%s/", ec.Config.Endpoint)
}
httpClient, err := httpc.New(nil, ec.Config.Endpoint, headers)
httpClient, err := httpc.New(
&http.Client{
Transport: &http.Transport{
TLSClientConfig: ec.Config.TLSConfig,
},
},
ec.Config.Endpoint,
headers,
)
if err != nil {
return err
}
Expand Down
17 changes: 17 additions & 0 deletions cli/commands/scripts_upgrade_multiple_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"github.com/hasura/graphql-engine/cli/internal/scripts"
"github.com/hasura/graphql-engine/cli/util"
"github.com/spf13/afero"

"github.com/hasura/graphql-engine/cli"
Expand Down Expand Up @@ -38,5 +39,21 @@ func newUpdateMultipleSources(ec *cli.ExecutionContext) *cobra.Command {
return scripts.UpdateProjectV3(opts)
},
}

f := cmd.Flags()

f.String("endpoint", "", "http(s) endpoint for Hasura GraphQL Engine")
f.String("admin-secret", "", "admin secret for Hasura GraphQL Engine")
f.String("access-key", "", "access key for Hasura GraphQL Engine")
f.MarkDeprecated("access-key", "use --admin-secret instead")
f.Bool("insecure-skip-tls-verify", false, "skip TLS verification and disable cert checking (default: false)")
f.String("certificate-authority", "", "path to a cert file for the certificate authority")

// need to create a new viper because https://github.com/spf13/viper/issues/233
util.BindPFlag(v, "endpoint", f.Lookup("endpoint"))
util.BindPFlag(v, "admin_secret", f.Lookup("admin-secret"))
util.BindPFlag(v, "access_key", f.Lookup("access-key"))
util.BindPFlag(v, "insecure_skip_tls_verify", f.Lookup("insecure-skip-tls-verify"))
util.BindPFlag(v, "certificate_authority", f.Lookup("certificate-authority"))
return cmd
}
1 change: 1 addition & 0 deletions cli/internal/scripts/update-project-v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func UpdateProjectV3(opts UpgradeToMuUpgradeProjectToMultipleSourcesOpts) error
}

opts.Logger.Warn("The upgrade process will make some changes to your project directory, It is advised to create a backup project directory before continuing")
opts.Logger.Warn("This script will rewrite the project metadata with metadata on server")
response, err := util.GetYesNoPrompt("continue?")
if err != nil {
return err
Expand Down

0 comments on commit 5fb2645

Please sign in to comment.