@@ -164,12 +164,16 @@ func (r *TorqueSpaceAdoServerRepositoryResource) Create(ctx context.Context, req
164164 }
165165 }
166166 start := time .Now ()
167- err := r .client .OnboardAdoServerRepoToSpace (data .SpaceName .ValueString (), data .RepositoryName .ValueString (),
167+ onboardErr := r .client .OnboardAdoServerRepoToSpace (data .SpaceName .ValueString (), data .RepositoryName .ValueString (),
168168 data .RepositoryUrl .ValueString (), data .Token .ValueStringPointer (), data .Branch .ValueString (), data .CredentialName .ValueString (), agents , data .UseAllAgents .ValueBool (), data .AutoRegisterEac .ValueBool ())
169- if err != nil {
169+ if onboardErr != nil {
170170 repo , err := r .client .GetRepoDetails (data .SpaceName .ValueString (), data .RepositoryName .ValueString ())
171171 if repo == nil {
172- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to onboard repository to space, got error: %s" , err ))
172+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to onboard repository to space, got error: %s" , onboardErr ))
173+ return
174+ }
175+ if err != nil {
176+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to onboard repository to space, got error: %s" , onboardErr ))
173177 return
174178 }
175179 if repo .Status == StatusSyncing {
@@ -189,7 +193,7 @@ func (r *TorqueSpaceAdoServerRepositoryResource) Create(ctx context.Context, req
189193 resp .Diagnostics .AddError ("Sync Timeout" , "Timed out while syncing repository" )
190194 return
191195 }
192- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to onboard repository to space, got error: %s" , err ))
196+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to onboard repository to space, got error: %s" , onboardErr ))
193197 return
194198 }
195199 resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
0 commit comments