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

internal/controller: generate hash of declarative flow by using "schema inspect" #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

datdao
Copy link
Member

@datdao datdao commented Jan 7, 2025

This PR replaces the hashing mechanism by using schema inspect. This change ensures that the Operator correctly detects changes in the remote schema.

@datdao datdao force-pushed the d/custom-atlas-config branch 3 times, most recently from 6cc9702 to 86989ea Compare January 8, 2025 05:24
@datdao datdao force-pushed the d/custom-atlas-config branch from 86989ea to cb035b4 Compare January 8, 2025 06:03
@datdao datdao requested review from giautm and rotemtam January 8, 2025 06:04
@datdao datdao marked this pull request as ready for review January 8, 2025 06:05
// Calculate the hash of the current schema.
hash, err := cli.SchemaInspect(ctx, &atlasexec.SchemaInspectParams{
Env: data.EnvName,
URL: "env://schema.src",
Copy link
Member

Choose a reason for hiding this comment

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

This may not correct, the user can define the src in the env block.

env {
   src = "file://schema.hcl"
}

hash, err := cli.SchemaInspect(ctx, &atlasexec.SchemaInspectParams{
Env: data.EnvName,
URL: "env://schema.src",
Format: `{{ .Hash | base64url }}`,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just use the raw .Hash. base64url is used for schema's tag.

Comment on lines +836 to +837
schema := envBody.AppendNewBlock("schema", nil).Body()
schema.SetAttributeValue("src", cty.StringVal(d.Desired.String()))
Copy link
Member

Choose a reason for hiding this comment

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

also set this schema.src to file://schema.hcl or file://schema.sql

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