Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make service alias unique #619

Merged
merged 7 commits into from
Dec 6, 2018
Merged

make service alias unique #619

merged 7 commits into from
Dec 6, 2018

Conversation

ilgooz
Copy link
Contributor

@ilgooz ilgooz commented Dec 4, 2018

a part of #618

@NicolasMahe NicolasMahe changed the base branch from dev to feature/auto-remove-volume December 4, 2018 10:15
database/service_db.go Outdated Show resolved Hide resolved
@ilgooz
Copy link
Contributor Author

ilgooz commented Dec 5, 2018

I'm freezing this PR for now. Discussion needs to be finalized first.

@NicolasMahe
Copy link
Member

Anthony suggest to put the logic if the service alias already exist in the api.deploy function.
In this function, we have access to the service def, and the database. We also have a 2 way stream, so we can send the replace confirmation to the cli and wait for confirmation.
The deploy should not rely on database error but should call the database.get function to check if the alias already exist

@NicolasMahe NicolasMahe changed the base branch from feature/auto-remove-volume to dev December 6, 2018 02:30
@NicolasMahe
Copy link
Member

This PR is only about adding a new behavior to the database package.
When saving a service with an alias that already exist in the db, existing service with same alias get deleted.
Result: only 1 service per alias can exist in the db

NicolasMahe
NicolasMahe previously approved these changes Dec 6, 2018
NicolasMahe
NicolasMahe previously approved these changes Dec 6, 2018
krhubert
krhubert previously approved these changes Dec 6, 2018
@NicolasMahe NicolasMahe dismissed stale reviews from krhubert and themself via 80fdbe5 December 6, 2018 08:18
s3 := &service.Service{ID: "02", Alias: "2", Name: "test-service"}
require.NoError(t, db.Save(s3))
ss, _ = db.All()
require.Len(t, ss, 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be better also to compare received services here with Equal so we can make sure that we really overwrite the service with new one(s2) correctly.

@ilgooz
Copy link
Contributor Author

ilgooz commented Dec 6, 2018

LGTM

@NicolasMahe NicolasMahe merged commit 556c1ea into dev Dec 6, 2018
@NicolasMahe NicolasMahe deleted the feature/unique-alias branch December 6, 2018 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants