Skip to content

Commit

Permalink
Merge pull request #126 from zowe/users/jstruga/missing-logic-staging
Browse files Browse the repository at this point in the history
Add missing logic in staging
  • Loading branch information
1000TurquoisePogs authored Aug 16, 2024
2 parents 7e962bf + 5c18c44 commit a103587
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
2 changes: 1 addition & 1 deletion manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: launcher
# Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/.
id: org.zowe.launcher
# Component version
version: 2.19.0
version: 2.18.0
# Human readable component name
title: Zowe Launcher
# Human readable component description
Expand Down
76 changes: 60 additions & 16 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,41 +1575,85 @@ static int get_component_list(char *buf, size_t buf_size,ConfigManager *configmg
bool enabled;
bool wasMissing = false;

bool checkHaSection = false;

Json *haInstancesJson = NULL;
int getStatus = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &haInstancesJson, 1, "haInstances");
if (!getStatus) {
if ((!strcmp(zl_context.ha_instance_id, "__ha_instance_id__")) || (!strcmp(zl_context.ha_instance_id, "{{ha_instance_id}}"))) {
int rc = 0;
int rsn = 0;
char *resolvedName = resolveSymbol("&SYSNAME", &rc, &rsn);
if (!rc) {
//ha instance name is always lowercase if derived from sysname automatically.
int nameLength = strlen(resolvedName);
for(int i = 0; i < nameLength; i++){
resolvedName[i] = tolower(resolvedName[i]);
}

// Resolves ha instance id for downstream as well.
snprintf(zl_context.ha_instance_id, 8+1, "%s", resolvedName);
checkHaSection = true;
} else {
ERROR("Could not resolve SYSNAME for HA instance lookup, rc=0x%x, rsn=0x%x\n", rc, rsn);
}
} else {
checkHaSection = true;
}
}

DEBUG("about to get component list\n");
int rc = cfgGetAnyC(configmgr, ZOWE_CONFIG_NAME, &result, 1, "components");
if (jsonIsObject(result)) {
JsonObject *resultObj = jsonAsObject(result);
JsonProperty *prop = resultObj->firstProperty;
int getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory");
if (getStatus) {
getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &runtimeDirectory, 2, "zowe", "runtimeDirectory");
if (!getStatus) {
getStatus = cfgGetStringC(configmgr, ZOWE_CONFIG_NAME, &extensionDirectory, 2, "zowe", "extensionDirectory");
if (getStatus) {
ERROR(" failed to get runtimeDirectory and extensionDirectory");
ERROR("failed to get extensionDirectory\n");
return -1;
}
} else {
ERROR("failed to get runtimeDirectory\n");
return -1;
}



while (prop!=NULL) {
enabled = false;
// check if component is enabled
getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled");
if (checkHaSection) {
getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled, 5, "haInstances", zl_context.ha_instance_id, "components", prop->key, "enabled");
if (getStatus) {
getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled");
}
} else {
getStatus = cfgGetBooleanC(configmgr, ZOWE_CONFIG_NAME, &enabled,3, "components", prop->key, "enabled");
}

if (getStatus) { // failed to get enabled value of the component
DEBUG("failed to get enabled value of the component %s\n", prop->key);
prop = prop->next;
continue;
}
snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key);
DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath);

// check if manifest.yaml is in instance/components/component-name/manifest.yaml
yamlExists = true;
if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) {
yamlExists = false;
// if not check instance/extensions/component/manifest.yaml
snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", extensionDirectory, prop->key);

yamlExists = true; //unused if not enabled. otherwise set to false if not found.
if (enabled) {
snprintf(manifestPath, PATH_MAX, "%s/components/%s/manifest.yaml", runtimeDirectory, prop->key);
DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath);
if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML"))
yamlExists = true;

// check if manifest.yaml is in <runtimeDirectory>/components/<component-name>/manifest.yaml
if (check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) {
yamlExists = false;
// if not check <extensionDirectory>/<component-name>/manifest.yaml
snprintf(manifestPath, PATH_MAX, "%s/%s/manifest.yaml", extensionDirectory, prop->key);
DEBUG("manifest path for component %s is %s\n", prop->key, manifestPath);
if(!check_if_yaml_exists(manifestPath, "MANIFEST.YAML")) {
yamlExists = true;
}
}
}

// read the yaml and check for item 'commands.start', if present then add enabled component to component list
Expand Down Expand Up @@ -1946,4 +1990,4 @@ int main(int argc, char **argv) {
SPDX-License-Identifier: EPL-2.0
Copyright Contributors to the Zowe Project.
*/
*/

0 comments on commit a103587

Please sign in to comment.