Refactor Target Repository (#3092)
- Refactor the Target domain repository functions so that they no longer return 4 different types. `Target` struct now contains `HostSource` & `CredentialSources` with Getters & Setters - Extending `Target` to contain `HostSource` & `CredentialSources` enables `funcs` to just return `Target` instead of multiple return types. This also allows easy future refactors and extensions of `Target`
This commit is contained in:
1 parent
743bbf88ac
commit
16f48686a7
20 files changed
+335
-173
No files matched your search
@@ -461,7 +461,7 @@ func (b *Server) CreateInitialTargetWithAddress(ctx context.Context) (target.Tar
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create target object: %w", err)
|
||||
}
|
||||
tt, _, _, err := targetRepo.CreateTarget(ctx, t, opts...)
|
||||
tt, err := targetRepo.CreateTarget(ctx, t, opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to save target to the db: %w", err)
|
||||
}
|
||||
@@ -525,11 +525,11 @@ func (b *Server) CreateInitialTargetWithHostSources(ctx context.Context) (target
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create target object: %w", err)
|
||||
}
|
||||
tt, _, _, err := targetRepo.CreateTarget(ctx, t, opts...)
|
||||
tt, err := targetRepo.CreateTarget(ctx, t, opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to save target to the db: %w", err)
|
||||
}
|
||||
tt, _, _, err = targetRepo.AddTargetHostSources(ctx, tt.GetPublicId(), tt.GetVersion(), []string{b.DevHostSetId})
|
||||
tt, err = targetRepo.AddTargetHostSources(ctx, tt.GetPublicId(), tt.GetVersion(), []string{b.DevHostSetId})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to add host source %q to target: %w", b.DevHostSetId, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user