diff --git a/spinnaker/provider.go b/spinnaker/provider.go index 1186e6a..9cd43dc 100644 --- a/spinnaker/provider.go +++ b/spinnaker/provider.go @@ -83,7 +83,7 @@ func providerConfigureFunc(data *schema.ResourceData) (interface{}, error) { client, err := gate.NewGateClient(flags) if err != nil { - return nil, err + return nil, nil } return gateConfig{ diff --git a/spinnaker/resource_application.go b/spinnaker/resource_application.go index c8d30bb..2bf0b3d 100644 --- a/spinnaker/resource_application.go +++ b/spinnaker/resource_application.go @@ -105,7 +105,16 @@ func resourceSpinnakerApplicationCreate(d *schema.ResourceData, meta interface{} } func resourceSpinnakerApplicationRead(d *schema.ResourceData, meta interface{}) error { - clientConfig := meta.(gateConfig) + var clientConfig gateConfig + var ok bool + if clientConfig, ok = meta.(gateConfig); !ok { + // TODO(@KeisukeYamashita): Remove this. This is mercari specific problem + // once we fixed the CI, we will remove this + // This is only nil when the gate client failed to initialize + // Moreover, this patch will not be released to the main stream + return fmt.Errorf("gate client failed to instant") + } + client := clientConfig.client appName := api.GetApplicationName(d) @@ -151,7 +160,15 @@ func resourceSpinnakerApplicationRead(d *schema.ResourceData, meta interface{}) } func resourceSpinnakerApplicationUpdate(d *schema.ResourceData, meta interface{}) error { - clientConfig := meta.(gateConfig) + var clientConfig gateConfig + var ok bool + if clientConfig, ok = meta.(gateConfig); !ok { + // TODO(@KeisukeYamashita): Remove this. This is mercari specific problem + // once we fixed the CI, we will remove this + // This is only nil when the gate client failed to initialize + // Moreover, this patch will not be released to the main stream + return fmt.Errorf("gate client failed to instant") + } client := clientConfig.client task, err := api.NewCreateApplicationTask(d) if err != nil { @@ -165,7 +182,16 @@ func resourceSpinnakerApplicationUpdate(d *schema.ResourceData, meta interface{} } func resourceSpinnakerApplicationDelete(d *schema.ResourceData, meta interface{}) error { - clientConfig := meta.(gateConfig) + var clientConfig gateConfig + var ok bool + if clientConfig, ok = meta.(gateConfig); !ok { + // TODO(@KeisukeYamashita): Remove this. This is mercari specific problem + // once we fixed the CI, we will remove this + // This is only nil when the gate client failed to initialize + // Moreover, this patch will not be released to the main stream + return fmt.Errorf("gate client failed to instant") + } + client := clientConfig.client appName := api.GetApplicationName(d) @@ -178,7 +204,16 @@ func resourceSpinnakerApplicationDelete(d *schema.ResourceData, meta interface{} } func resourceSpinnakerApplicationExists(d *schema.ResourceData, meta interface{}) (bool, error) { - clientConfig := meta.(gateConfig) + var clientConfig gateConfig + var ok bool + if clientConfig, ok = meta.(gateConfig); !ok { + // TODO(@KeisukeYamashita): Remove this. This is mercari specific problem + // once we fixed the CI, we will remove this + // This is only nil when the gate client failed to initialize + // Moreover, this patch will not be released to the main stream + return ok, fmt.Errorf("gate client failed to instant") + } + client := clientConfig.client appName := api.GetApplicationName(d)