Skip to content

feat: Changes to support external credentials in envgene#1375

Open
tesmarishy wants to merge 1 commit into
Netcracker:mainfrom
tesmarishy:feature/external-cred-support
Open

feat: Changes to support external credentials in envgene#1375
tesmarishy wants to merge 1 commit into
Netcracker:mainfrom
tesmarishy:feature/external-cred-support

Conversation

@tesmarishy
Copy link
Copy Markdown
Contributor

Pull Request

Summary

Provide a concise description of what this pull request does and why it is needed.

Changes in EnvGene to support management of Credentials that reside in external secret stores.

Issue

Link to the issue(s) this PR addresses (e.g., Fixes #123 or Closes #456). If no issue exists, explain why this change is necessary.

No Github issue.
EnvGene cannot be used in projects where policy prohibits storing secrets in Git, even in encrypted form.
It is necessary to extend EnvGene to support management of Credentials that reside in external secret stores.

Breaking Change?

  • Yes
  • No
    No

If yes, describe the breaking change and its impact (e.g., API changes, behavior changes, or required updates for users).

Scope / Project

Specify the component, module, or project area affected by this change (e.g., docs, actions, workflows).

Env builder job.

Implementation Notes

Provide details on how the change was implemented, including any technical considerations, trade-offs, or notable design decisions. Leave blank if not applicable.

  1. If the external_credential_template field is present in the environment template file, load the referenced template, render it, and mark the environment as an External Credential Environment.(render_config_env.py).

  2. In cloud_passport.py, give precedence to the SECRET_FLOW parameter from cloud.yml over the value defined in the cloud passport.

  3. Existing logic extracts credential IDs from patterns such as:
    ${creds.get("app-sidecar-token").} for MaaS, DBaaS, Consul, and similar credentials. Enhance the logic to additionally support the following structure:
    $type: "credRef"
    credId: "app-dbaas-cred"
    property: "username"
    Extract credId from this structure. If this format is not present, fall back to the existing macro-based extraction logic (cloud_passport.py).

  4. While processing credentials from entities, if an environment is identified as an external-only environment (based on point 1), collect and validate((create_credentials.py):
    o Credential IDs referenced from MaaS, DBaaS, Consul, etc.
    o Parameters using the credRef structure

  5. Validate the final credentials.yml to ensure no mixed credential types are present.

Tests / Evidence

Describe how the changes were verified, including:

  • Tests added or updated (e.g., unit, integration, end-to-end)
  • Manual testing steps or results
  • Screenshots, logs, or other evidence (if applicable)

Testing is done in Instance pipeline .

Additional Notes

Include any extra information, such as:

  • Dependencies introduced
  • Future work or follow-up tasks
  • Reviewer instructions or context
  • References to related PRs or discussions

Leave blank if not applicable.

)
return sort_data

def validateSchema(yaml_data, schema_path):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schema_data = json.load(f)
logger.debug(f'Checking yaml with schema: {schema_path}')
jsonschema.validate(yaml_data, schema_data)
schema_data = validateSchema(yaml_data, schema_path)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schema validation should remain separate method and not be encapsulated in sorting or sm else


def build_env(env_name, env_instances_dir, parameters_dir, env_template_dir, resource_profiles_dir,
env_specific_resource_profile_map, all_instances_dir, render_context, templates_dirs=None):
env_specific_resource_profile_map, all_instances_dir, render_context, templates_dirs=None, isExternalCredEnv=False):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls no some camel case in python

if cred_map.get("$type") != "credRef":
return None
cred_id = cred_map.get("credId")
if not cred_id or not str(cred_id).strip():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why cast to string? it may be worth falling if what is passed is not of correct str type(int)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants