Closes #11053. Use environment specific client for accessing resources. (#11503)

When using access control, the Rancher global API may return 404 for
resources that exist and are accessible via the environment API.
This commit is contained in:
John Engelman 2017-01-30 11:08:21 -06:00 committed by Paul Stack
parent 9b17d57332
commit 0152a79b90
4 changed files with 17 additions and 4 deletions

View File

@ -97,7 +97,11 @@ func resourceRancherRegistrationTokenCreate(d *schema.ResourceData, meta interfa
func resourceRancherRegistrationTokenRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing RegistrationToken: %s", d.Id())
client := meta.(*Config)
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
// client := meta.(*Config)
regT, err := client.RegistrationToken.ById(d.Id())
if err != nil {

View File

@ -90,7 +90,10 @@ func resourceRancherRegistryCreate(d *schema.ResourceData, meta interface{}) err
func resourceRancherRegistryRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing Registry: %s", d.Id())
client := meta.(*Config)
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
registry, err := client.Registry.ById(d.Id())
if err != nil {

View File

@ -104,7 +104,10 @@ func resourceRancherRegistryCredentialCreate(d *schema.ResourceData, meta interf
func resourceRancherRegistryCredentialRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing RegistryCredential: %s", d.Id())
client := meta.(*Config)
client, err := meta.(*Config).RegistryClient(d.Get("registry_id").(string))
if err != nil {
return err
}
registryCred, err := client.RegistryCredential.ById(d.Id())
if err != nil {

View File

@ -122,7 +122,10 @@ func resourceRancherStackCreate(d *schema.ResourceData, meta interface{}) error
func resourceRancherStackRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Refreshing Stack: %s", d.Id())
client := meta.(*Config)
client, err := meta.(*Config).EnvironmentClient(d.Get("environment_id").(string))
if err != nil {
return err
}
stack, err := client.Environment.ById(d.Id())
if err != nil {