You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by geomacy <gi...@git.apache.org> on 2017/06/26 16:40:29 UTC

[GitHub] brooklyn-server pull request #737: Clean up inference around parsing `name:v...

Github user geomacy commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/737#discussion_r124033012
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java ---
    @@ -855,24 +893,50 @@ private boolean attemptType(String key, CatalogItemType candidateCiType) {
                 }
                 // first look in collected items, if a key is given
                 String type = (String) item.get("type");
    -            String version = null;
    -            if (CatalogUtils.looksLikeVersionedId(type)) {
    -                version = CatalogUtils.getVersionFromVersionedId(type);
    -                type = CatalogUtils.getSymbolicNameFromVersionedId(type);
    -            }
    +            
                 if (type!=null && key!=null) {
                     for (CatalogItemDtoAbstract<?,?> candidate: itemsDefinedSoFar) {
                         if (candidateCiType == candidate.getCatalogItemType() &&
                                 (type.equals(candidate.getSymbolicName()) || type.equals(candidate.getId()))) {
    -                        if (version==null || version.equals(candidate.getVersion())) {
    -                            // matched - exit
    -                            catalogItemType = candidateCiType;
    -                            planYaml = candidateYaml;
    -                            resolved = true;
    -                            return true;
    +                        // matched - exit
    +                        catalogItemType = candidateCiType;
    +                        planYaml = candidateYaml;
    +                        resolved = true;
    +                        return true;
    +                    }
    +                }
    +            }
    +            {
    +                // legacy routine; should be the same as above code added in 0.12 because:
    +                // if type is symbolic_name, the type will match below, and version will be null so any version allowed to match 
    +                // if type is symbolic_name:version, the id will match, and the version will also have to match 
    +                // SHOULD NEVER NEED THIS - remove during or after 0.13
    +                String typeWithId = type;
    +                String version = null;
    +                if (CatalogUtils.looksLikeVersionedId(type)) {
    +                    version = CatalogUtils.getVersionFromVersionedId(type);
    +                    type = CatalogUtils.getSymbolicNameFromVersionedId(type);
    +                }
    +                if (type!=null && key!=null) {
    +                    for (CatalogItemDtoAbstract<?,?> candidate: itemsDefinedSoFar) {
    +                        if (candidateCiType == candidate.getCatalogItemType() &&
    +                                (type.equals(candidate.getSymbolicName()) || type.equals(candidate.getId()))) {
    +                            if (version==null || version.equals(candidate.getVersion())) {
    +                                log.warn("Lookup of '"+type+"' version '"+version+"' only worked using legacy routines; please advise Brooklyn community so they understand why");
    --- End diff --
    
    Maybe we should even make this an `error` to highlight it more?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---