rancher: set environment_id on import (#11594)
This commit is contained in:
parent
d421829aaa
commit
acd7320e1f
|
@ -16,7 +16,7 @@ func resourceRancherRegistrationToken() *schema.Resource {
|
|||
Read: resourceRancherRegistrationTokenRead,
|
||||
Delete: resourceRancherRegistrationTokenDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceRancherRegistrationTokenImport,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -204,6 +204,16 @@ func resourceRancherRegistrationTokenDelete(d *schema.ResourceData, meta interfa
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceRancherRegistrationTokenImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
client := meta.(*Config)
|
||||
regT, err := client.RegistrationToken.ById(d.Id())
|
||||
if err != nil {
|
||||
return []*schema.ResourceData{}, err
|
||||
}
|
||||
d.Set("environment_id", regT.AccountId)
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
// RegistrationTokenStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// a Rancher RegistrationToken.
|
||||
func RegistrationTokenStateRefreshFunc(client *rancherClient.RancherClient, regTID string) resource.StateRefreshFunc {
|
||||
|
|
|
@ -17,7 +17,7 @@ func resourceRancherRegistry() *schema.Resource {
|
|||
Update: resourceRancherRegistryUpdate,
|
||||
Delete: resourceRancherRegistryDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceRancherRegistryImport,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -210,6 +210,16 @@ func resourceRancherRegistryDelete(d *schema.ResourceData, meta interface{}) err
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceRancherRegistryImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
client := meta.(*Config)
|
||||
reg, err := client.Registry.ById(d.Id())
|
||||
if err != nil {
|
||||
return []*schema.ResourceData{}, err
|
||||
}
|
||||
d.Set("environment_id", reg.AccountId)
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
// RegistryStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// a Rancher Environment.
|
||||
func RegistryStateRefreshFunc(client *rancherClient.RancherClient, registryID string) resource.StateRefreshFunc {
|
||||
|
|
|
@ -17,7 +17,7 @@ func resourceRancherRegistryCredential() *schema.Resource {
|
|||
Update: resourceRancherRegistryCredentialUpdate,
|
||||
Delete: resourceRancherRegistryCredentialDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceRancherRegistryCredentialImport,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -232,6 +232,16 @@ func resourceRancherRegistryCredentialDelete(d *schema.ResourceData, meta interf
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceRancherRegistryCredentialImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
client := meta.(*Config)
|
||||
regC, err := client.RegistryCredential.ById(d.Id())
|
||||
if err != nil {
|
||||
return []*schema.ResourceData{}, err
|
||||
}
|
||||
d.Set("environment_id", regC.AccountId)
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
// RegistryCredentialStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// a Rancher Environment.
|
||||
func RegistryCredentialStateRefreshFunc(client *rancherClient.RancherClient, registryCredID string) resource.StateRefreshFunc {
|
||||
|
|
|
@ -19,7 +19,7 @@ func resourceRancherStack() *schema.Resource {
|
|||
Update: resourceRancherStackUpdate,
|
||||
Delete: resourceRancherStackDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceRancherStackImport,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
|
@ -333,6 +333,16 @@ func resourceRancherStackDelete(d *schema.ResourceData, meta interface{}) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceRancherStackImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
client := meta.(*Config)
|
||||
stack, err := client.Environment.ById(d.Id())
|
||||
if err != nil {
|
||||
return []*schema.ResourceData{}, err
|
||||
}
|
||||
d.Set("environment_id", stack.AccountId)
|
||||
return []*schema.ResourceData{d}, nil
|
||||
}
|
||||
|
||||
// StackStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
|
||||
// a Rancher Stack.
|
||||
func StackStateRefreshFunc(client *rancherClient.RancherClient, stackID string) resource.StateRefreshFunc {
|
||||
|
|
Loading…
Reference in New Issue