Skip to content
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 missing logic in staging #126

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
*/
*/
Loading