Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOD:delete the buildPath code and use k8s native. And add a configGetter struct. #92

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

calmkart
Copy link
Contributor

@calmkart calmkart commented Nov 8, 2019

this pr is about two things.

  1. the code in forwardport to build the path is not required
    u := url.URL{
    Scheme: req.URL().Scheme,
    Host: req.URL().Host,
    Path: buildPath(req),
    RawQuery: "timeout=32s",
    }

    func buildPath(req *restclient.Request) string {
    splitted := strings.Split(req.URL().Path, "/namespaces")
    path := splitted[0] + "/api/v1/namespaces" + splitted[1]
    return path
    }

    just use the k8s native way is well.

replace this

restClient := pfo.ClientSet.RESTClient()

and change the way to get RESTClient with k8s native is better i think.

// GetRestClient return the RESTClient
func (c *ConfigGetter) GetRESTClient() (*restclient.RESTClient, error) {
	matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(c.ConfigFlag)
	f := cmdutil.NewFactory(matchVersionKubeConfigFlags)
	RESTClient, err := f.RESTClient()
	if err != nil {
		return nil, err
	}
	return RESTClient, nil
}
  1. add a struct ConfigGetter in fwdcfg.go, maybe it will makes the code more concise.
  2. I commented this line of code// restClient.Client.Timeout = 32 in fwdport.go#L55
    if we want to set the timeout, set here is well.

test in k8s v1.16.0

@calmkart
Copy link
Contributor Author

calmkart commented Nov 8, 2019

@cjimti
PTAL,thanks.
if there is any question, pls contact me.
I am very happy to discuss it with you.

@cjimti cjimti merged commit 58f1568 into txn2:master Nov 12, 2019
D3-LucaPiombino pushed a commit to CodeCoil/kubefwd that referenced this pull request Jun 13, 2024
MOD:delete the buildPath code and use k8s native. And add a configGetter struct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants