-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#81 create wrapper adapter for new DoguConfigRepository
We need a wrapper because of our specific errors in the blueprint operator. Maybe we can introduce them in the registry-lib as well, so we can completely remove this wrapper adapter. For now, the plan is to replace the old etcd adapter step by step with the new adapter.
- Loading branch information
1 parent
4f3222c
commit f82f16b
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"context" | ||
"github.com/cloudogu/k8s-blueprint-operator/pkg/domain/common" | ||
"github.com/cloudogu/k8s-blueprint-operator/pkg/domainservice" | ||
"github.com/cloudogu/k8s-registry-lib/config" | ||
"github.com/cloudogu/k8s-registry-lib/repository" | ||
) | ||
|
||
type DoguConfigRepository struct { | ||
repo repository.DoguConfigRepository | ||
} | ||
|
||
func NewDoguConfigRepository(repo repository.DoguConfigRepository) *DoguConfigRepository { | ||
return &DoguConfigRepository{repo: repo} | ||
} | ||
|
||
func (e DoguConfigRepository) Get(ctx context.Context, doguName common.SimpleDoguName) (config.DoguConfig, error) { | ||
// TODO: There seems to be no way to know, if we have a NotFoundError or a connection error. | ||
return e.repo.Get(ctx, config.SimpleDoguName(doguName)) | ||
} | ||
|
||
func (e DoguConfigRepository) Update(ctx context.Context, entry config.DoguConfig) (config.DoguConfig, error) { | ||
mergedConfig, err := e.repo.Update(ctx, entry) | ||
// TODO: we cannot see here, if there is a real conflict or there was a connection error. | ||
// With a conflict, we can immediately restart the business process | ||
// With an connection error we need a longer backoff (internalError) | ||
if err != nil { | ||
return entry, domainservice.NewInternalError(err, "failed to save or merge config for %s", entry.DoguName) | ||
} | ||
return mergedConfig, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters