@@ -34,6 +34,8 @@ const (
3434 ErrMalformedConfig
3535 ErrNoAPIs
3636 ErrDuplicateName
37+ ErrDuplicateEndpointInOneDeploy
38+ ErrDuplicateEndpoint
3739 ErrSpecifyAllOrNone
3840 ErrOneOfPrerequisitesNotDefined
3941 ErrMinReplicasGreaterThanMax
@@ -50,7 +52,6 @@ const (
5052 ErrFieldNotSupportedByPredictorType
5153 ErrNoAvailableNodeComputeLimit
5254 ErrAPINotDeployed
53- ErrDuplicateEndpoint
5455)
5556
5657var _errorKinds = []string {
@@ -60,6 +61,8 @@ var _errorKinds = []string{
6061 "err_malformed_config" ,
6162 "err_no_apis" ,
6263 "err_duplicate_name" ,
64+ "err_duplicate_endpoint_in_one_deploy" ,
65+ "err_duplicate_endpoint" ,
6366 "err_specify_all_or_none" ,
6467 "err_one_of_prerequisites_not_defined" ,
6568 "err_min_replicas_greater_than_max" ,
@@ -76,10 +79,9 @@ var _errorKinds = []string{
7679 "err_field_not_supported_by_predictor_type" ,
7780 "err_no_available_node_compute_limit" ,
7881 "err_api_not_deployed" ,
79- "err_duplicate_endpoint" ,
8082}
8183
82- var _ = [1 ]int {}[int (ErrDuplicateEndpoint )- (len (_errorKinds )- 1 )] // Ensure list length matches
84+ var _ = [1 ]int {}[int (ErrAPINotDeployed )- (len (_errorKinds )- 1 )] // Ensure list length matches
8385
8486func (t ErrorKind ) String () string {
8587 return _errorKinds [t ]
@@ -164,6 +166,25 @@ func ErrorDuplicateName(apis []userconfig.API) error {
164166 })
165167}
166168
169+ func ErrorDuplicateEndpointInOneDeploy (apis []userconfig.API ) error {
170+ names := make ([]string , len (apis ))
171+ for i , api := range apis {
172+ names [i ] = api .Name
173+ }
174+
175+ return errors .WithStack (Error {
176+ Kind : ErrDuplicateEndpointInOneDeploy ,
177+ message : fmt .Sprintf ("endpoint %s must be unique across apis (defined in %s)" , s .UserStr (* apis [0 ].Endpoint ), s .StrsAnd (names )),
178+ })
179+ }
180+
181+ func ErrorDuplicateEndpoint (apiName string ) error {
182+ return errors .WithStack (Error {
183+ Kind : ErrDuplicateEndpoint ,
184+ message : fmt .Sprintf ("endpoint is already being used by the %s api" , apiName ),
185+ })
186+ }
187+
167188func ErrorSpecifyAllOrNone (val string , vals ... string ) error {
168189 allVals := append (vals , val )
169190 message := fmt .Sprintf ("please specify all or none of %s" , s .UserStrsAnd (allVals ))
@@ -299,10 +320,3 @@ func ErrorAPINotDeployed(apiName string) error {
299320 message : fmt .Sprintf ("%s api is not deployed" , apiName ), // note: if modifying this string, search the codebase for it and change all occurrences
300321 })
301322}
302-
303- func ErrorDuplicateEndpoint (apiName string ) error {
304- return errors .WithStack (Error {
305- Kind : ErrDuplicateEndpoint ,
306- message : fmt .Sprintf ("endpoint is already being used by the %s api" , apiName ),
307- })
308- }
0 commit comments