You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of now, as.*_name functions are a bit of a if/else mess that looks quite garbled and inaccessible. It would be good to go through a round of refactoring to get them more accessible and reduce code duplication. If too much effort, adding some comments to explain the logic might be another way to go.
The following function is how we currently check and format strings to make sure they're a valid subscription name. I am not proud of this:
as.sub_name<-function(x, project= ps_project_get()) {
# Can it be done with a switch case?if (is.character(x) &&x!="") {
if (already_formatted(x)) {
out<-x
} else {
out<- paste(c("projects", project, "subscriptions", x), collapse="/")
}
return(out)
} elseif (inherits(x, "Subscription")) {
if (already_formatted(x$name)) {
out<-x$name
} else {
out<- paste(c("projects", project, "subscriptions", x$name), collapse="/")
}
return(out)
} elseif (is.null(x)) {
return(NULL)
} else {
stop("Subscription name is invalid!", call.=FALSE)
}
}
An avenue that might be worth exploring is to have a nameValidator class that will handle name formatting for all entities (topics, subscriptions, schemas, snapshots).
Functions in need of refactoring:
as.sub_name
as.topic_name
as.schema_name
as.snapshot_name
The text was updated successfully, but these errors were encountered:
As of now,
as.*_name
functions are a bit of a if/else mess that looks quite garbled and inaccessible. It would be good to go through a round of refactoring to get them more accessible and reduce code duplication. If too much effort, adding some comments to explain the logic might be another way to go.The following function is how we currently check and format strings to make sure they're a valid subscription name. I am not proud of this:
An avenue that might be worth exploring is to have a
nameValidator
class that will handle name formatting for all entities (topics, subscriptions, schemas, snapshots).Functions in need of refactoring:
as.sub_name
as.topic_name
as.schema_name
as.snapshot_name
The text was updated successfully, but these errors were encountered: