Go-rancher client project id

Hi!, I’m using the go-rancher library to build a terraform provider for rancher.

I’m setting the url for the client as http://localhost:8080/v1, I’m able to create new environments, but now I want to create resources within an environment (e.g. registries).

Is it possible to use the same client to get to the correct environment (project) using go-rancher???

I have

client, err := rancher.NewRancherClient(&rancher.ClientOpts{
    Url: "http://localhost:8080/v1",
    AccessKey: "my_access_key",
    SecretKey: "my_secret_key",

I would like to be able to do something like

client.Url = "http://localhost:8080/v1/projects/1a23/schemas"

And then use the same client but pointing to the correct environment.
I also understand that there is a special header x-api-project-id that I can set but I don’t know if the go client support passing this header or how to do it.


Hi @blackjid,

Take a look at this project, it does similar calls so it shoud provide some examples.


The version of Go Rancher is slightly dated, but it should still work. I need to finish this thing up one of these days :slight_smile: