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

C3 version schema #9986

Merged
merged 4 commits into from
Feb 21, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
const (
composerEnvironmentEnvVariablesRegexp = "[a-zA-Z_][a-zA-Z0-9_]*."
composerEnvironmentReservedAirflowEnvVarRegexp = "AIRFLOW__[A-Z0-9_]+__[A-Z0-9_]+"
composerEnvironmentVersionRegexp = `composer-(([0-9]+)(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-(([0-9]+)((\.[0-9]+)(\.[0-9]+)?)?)`
composerEnvironmentVersionRegexp = `composer-(([0-9]+)(\.[0-9]+\.[0-9]+(-preview\.[0-9]+)?)?|latest)-airflow-(([0-9]+)((\.[0-9]+)(\.[0-9]+)?)?(-build\.[0-9]+)?)`
spapi17 marked this conversation as resolved.
Show resolved Hide resolved
)

var composerEnvironmentReservedEnvVar = map[string]struct{}{
Expand Down Expand Up @@ -2827,7 +2827,7 @@ func composerImageVersionDiffSuppress(_, old, new string, _ *schema.ResourceData
versionRe := regexp.MustCompile(composerEnvironmentVersionRegexp)
oldVersions := versionRe.FindStringSubmatch(old)
newVersions := versionRe.FindStringSubmatch(new)
if oldVersions == nil || len(oldVersions) < 10 {
if oldVersions == nil || len(oldVersions) < 11 {
// Somehow one of the versions didn't match the regexp or didn't
// have values in the capturing groups. In that case, fall back to
// an equality check.
Expand All @@ -2836,7 +2836,7 @@ func composerImageVersionDiffSuppress(_, old, new string, _ *schema.ResourceData
}
return old == new
}
if newVersions == nil || len(newVersions) < 10 {
if newVersions == nil || len(newVersions) < 11 {
// Somehow one of the versions didn't match the regexp or didn't
// have values in the capturing groups. In that case, fall back to
// an equality check.
Expand All @@ -2849,9 +2849,11 @@ func composerImageVersionDiffSuppress(_, old, new string, _ *schema.ResourceData
oldAirflow := oldVersions[5]
oldAirflowMajor := oldVersions[6]
oldAirflowMajorMinor := oldVersions[6] + oldVersions[8]
oldAirflowMajorMinorPatch := oldVersions[6] + oldVersions[8] + oldVersions[9]
newAirflow := newVersions[5]
newAirflowMajor := newVersions[6]
newAirflowMajorMinor := newVersions[6] + newVersions[8]
newAirflowMajorMinorPatch := newVersions[6] + newVersions[8] + newVersions[9]
// Check Airflow versions.
if oldAirflow == oldAirflowMajor || newAirflow == newAirflowMajor {
// If one of the Airflow versions specifies only major version
Expand All @@ -2873,8 +2875,18 @@ func composerImageVersionDiffSuppress(_, old, new string, _ *schema.ResourceData
if !eq {
return false
}
} else if oldAirflow == oldAirflowMajorMinorPatch || newAirflow == newAirflowMajorMinorPatch {
// If one of the Airflow versions specifies only major, minor and patch version
// (like 1.10.15), we can only compare major, minor and patch versions.
eq, err := versionsEqual(oldAirflowMajorMinorPatch, newAirflowMajorMinorPatch)
if err != nil {
log.Printf("[WARN] Could not parse airflow version, %s", err)
}
if !eq {
return false
}
} else {
// Otherwise, we compare the full Airflow versions (like 1.10.15).
// Otherwise, we compare the full Airflow versions (like 1.10.15-build.5).
eq, err := versionsEqual(oldAirflow, newAirflow)
if err != nil {
log.Printf("[WARN] Could not parse airflow version, %s", err)
Expand Down
Loading