-
Notifications
You must be signed in to change notification settings - Fork 324
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
add sameness group to exported services #2075
Merged
malizz
merged 8 commits into
main
from
malizz/NET-3442/add-samenessgroup-to-exported-services
Apr 24, 2023
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
03c7303
add sameness group to exported services
02664c0
update CRDs
dcd69cc
update deep copy
7a34ad0
re add license line
39a0d45
check if sameness group is wildcard
71886f1
remove experimental tag on peering fields
e748820
update error message case
d465ae0
update error message case in webhook test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
) | ||
|
||
const ExportedServicesKubeKind = "exportedservices" | ||
const WildcardSpecifier = "*" | ||
|
||
func init() { | ||
SchemeBuilder.Register(&ExportedServices{}, &ExportedServicesList{}) | ||
|
@@ -73,6 +74,8 @@ type ServiceConsumer struct { | |
Partition string `json:"partition,omitempty"` | ||
// [Experimental] Peer is the name of the peer to export the service to. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this isn't you, but can you verify if Peering is still |
||
Peer string `json:"peer,omitempty"` | ||
// SamenessGroup is the name of the sameness group to export the service to. | ||
SamenessGroup string `json:"samenessGroup,omitempty"` | ||
} | ||
|
||
func (in *ExportedServices) GetObjectMeta() metav1.ObjectMeta { | ||
|
@@ -169,8 +172,9 @@ func (in *ExportedService) toConsul() capi.ExportedService { | |
var consumers []capi.ServiceConsumer | ||
for _, consumer := range in.Consumers { | ||
consumers = append(consumers, capi.ServiceConsumer{ | ||
Partition: consumer.Partition, | ||
Peer: consumer.Peer, | ||
Partition: consumer.Partition, | ||
Peer: consumer.Peer, | ||
SamenessGroup: consumer.SamenessGroup, | ||
}) | ||
} | ||
return capi.ExportedService{ | ||
|
@@ -230,14 +234,31 @@ func (in *ExportedService) validate(path *field.Path, consulMeta common.ConsulMe | |
} | ||
|
||
func (in *ServiceConsumer) validate(path *field.Path, consulMeta common.ConsulMeta) *field.Error { | ||
if in.Partition != "" && in.Peer != "" { | ||
return field.Invalid(path, *in, "both partition and peer cannot be specified.") | ||
count := 0 | ||
|
||
if in.Partition != "" { | ||
count++ | ||
} | ||
if in.Peer != "" { | ||
count++ | ||
} | ||
if in.SamenessGroup != "" { | ||
count++ | ||
} | ||
if in.Partition == "" && in.Peer == "" { | ||
return field.Invalid(path, *in, "either partition or peer must be specified.") | ||
if count > 1 { | ||
return field.Invalid(path, *in, "Service consumer must define at most one of Peer, Partition, or SamenessGroup") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: errors should start with a lower case |
||
} | ||
if count == 0 { | ||
return field.Invalid(path, *in, "Service consumer must define at least one of Peer, Partition, or SamenessGroup") | ||
} | ||
if !consulMeta.PartitionsEnabled && in.Partition != "" { | ||
return field.Invalid(path.Child("partitions"), in.Partition, "Consul Admin Partitions need to be enabled to specify partition.") | ||
return field.Invalid(path.Child("partition"), in.Partition, "Consul Admin Partitions need to be enabled to specify partition.") | ||
} | ||
if in.Partition == WildcardSpecifier { | ||
return field.Invalid(path.Child("partition"), "", "exporting to all partitions (wildcard) is not supported") | ||
} | ||
if in.Peer == WildcardSpecifier { | ||
wilkermichael marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return field.Invalid(path.Child("peer"), "", "exporting to all peers (wildcard) is not supported") | ||
} | ||
return 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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking that you ran
make ctrl-manifests
because I see changes when I run it locallyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I ran both
make ctrl-manifests ctrl-generate
and i saw multiple local changes as well. Maybe something needs changing here Mali?