Skip to content

Conversation

@Mladen-Karadimov
Copy link

@Mladen-Karadimov Mladen-Karadimov commented Aug 20, 2025

Description

Adding the flexibility to overwrite current startup commands for flexibility.

What problem is being solved?

#101

How is it being solved?

Simply by making command and args parameters

What changes are made to solve it?

add an option to change the startup command/args for the app

Wanted Behaviour:

    datastore:
      engine: postgres
      migrationType: initContainer
      migrations:
        command:
          - /bin/sh
          - "-c"
        args:
          - source /vault/secrets/db.env && exec /openfga migrate
    podAnnotations:
      vault.hashicorp.com/agent-inject: "true"
      vault.hashicorp.com/role: "app-role"
      vault.hashicorp.com/agent-pre-populate-only: "true"
      vault.hashicorp.com/agent-inject-secret-db.env: "kv/data/openfga/db"
      vault.hashicorp.com/agent-inject-template-db.env: |
        {{- with secret "kv/data/openfga/db" -}}
        export OPENFGA_DATASTORE_URI="postgres://{{ .Data.data.user }}:{{ .Data.data.pass }}@postgres.postgres.svc.cluster.local:5432/openfga"
        {{- end }}
    command:
      - /bin/sh
      - "-c"
    args:
      - source /vault/secrets/db.env && exec /openfga run

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features

    • Added Helm values to configure startup command and arguments for the main application container and database migration jobs.
    • Defaults preserve prior behavior (command: /openfga; args: run for app, migrate for migrations), while enabling overrides as needed.
  • Chores

    • Updated chart templates and values schema to support the new configurable command and args options.

add an option to change the startup command/args for the app
@Mladen-Karadimov Mladen-Karadimov requested review from a team as code owners August 20, 2025 16:37
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 20, 2025

CLA Not Signed

@coderabbitai
Copy link

coderabbitai bot commented Aug 20, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Helm chart templates were updated to replace static container args with value-driven command and args for the main container and migration tasks. Corresponding values and schema entries were added to values.yaml and values.schema.json to define command and args for both the main application and datastore migrations.

Changes

Cohort / File(s) Summary of Changes
Helm templates: configurable command/args
charts/openfga/templates/deployment.yaml, charts/openfga/templates/job.yaml
Replaced fixed args with templated command and args. Deployment: main container uses .Values.command/.Values.args; init/migrate uses .Values.migrations.command/.Values.migrations.args. Job: migrate container uses .Values.migrations.command/.Values.migrations.args.
Values and schema additions
charts/openfga/values.yaml, charts/openfga/values.schema.json
Added top-level command and args (defaults: ["/openfga"], ["run"]). Added datastore.migrations.command and datastore.migrations.args (defaults: ["/openfga"], ["migrate"]). Schema defines command and args as arrays with object items.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Operator
  participant Helm as Helm (Chart Render)
  participant K8s as Kubernetes API
  participant Pod as Pod/Job
  participant Ctr as Container

  Operator->>Helm: helm install/upgrade with values
  Helm->>K8s: Rendered Deployment/Job (command, args from values)
  K8s->>Pod: Schedule Pod/Job
  Pod->>Ctr: Start container with command/args
  Note right of Ctr: Main: .Values.command/.Values.args<br/>Migrate: .Values.migrations.command/.Values.migrations.args
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
charts/openfga/values.yaml (1)

121-122: Top-level command/args defaults look good; consider quoting for clarity

The defaults match the current image’s expected entrypoint/cmd. Optional: quote the strings to avoid surprises with YAML parsing if users extend them with flags containing special chars.

Apply this diff if you want clearer quoting:

-command: ["/openfga"]
-args: ["run"]
+command: ["/openfga"]
+args: ["run"]
charts/openfga/templates/deployment.yaml (1)

94-96: JSON-encode command/args arrays for robust rendering

Using toJson ensures valid YAML for lists and correct quoting if values contain spaces or special characters.

Apply this diff:

-          command: {{ .Values.command }}
-          args: {{ .Values.args }}
+          command: {{ .Values.command | toJson }}
+          args: {{ .Values.args | toJson }}
charts/openfga/templates/job.yaml (1)

1-83: Optional: guard command/args only when non-empty to allow image defaults

If you want to allow users to rely on the image’s default ENTRYPOINT/CMD, render these fields conditionally when non-empty. Not required for this PR since you provide defaults, but improves flexibility.

Example:

-          command: {{ .Values.datastore.migrations.command | toJson }}
-          args: {{ .Values.datastore.migrations.args | toJson }}
+          {{- if .Values.datastore.migrations.command }}
+          command: {{ .Values.datastore.migrations.command | toJson }}
+          {{- end }}
+          {{- if .Values.datastore.migrations.args }}
+          args: {{ .Values.datastore.migrations.args | toJson }}
+          {{- end }}

And similarly for the main container in deployment.yaml.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 30f74d8 and e8a89ba.

📒 Files selected for processing (4)
  • charts/openfga/templates/deployment.yaml (2 hunks)
  • charts/openfga/templates/job.yaml (1 hunks)
  • charts/openfga/values.schema.json (1 hunks)
  • charts/openfga/values.yaml (2 hunks)

@Mladen-Karadimov
Copy link
Author

The next problem is that the image is distroless and can't make my magic trick work :)

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.

1 participant