Skip to content

Commit

Permalink
Fix/airflow settings update (#389)
Browse files Browse the repository at this point in the history
* Check for airflow version to change command

* WIP Test case

* Update tests

* Add EOF line

* Default to Airflow 1 command without image tag
  • Loading branch information
Adam Vandover committed Nov 24, 2020
1 parent 9fd909d commit e3c74b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion airflow/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func airflowVersionFromDockerFile(airflowHome string, dockerfile string) (uint64
semVer, err := semver.NewVersion(airflowTag)

if err != nil {
return 0, errors.Wrapf(err, "failed to parse dockerfile Airflow tag: %s", airflowTag)
return uint64(0x1), nil // Default to Airflow 1 if the user has a custom image without a semVer tag
}

return semVer.Major(), nil
Expand Down
13 changes: 8 additions & 5 deletions airflow/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,18 @@ func Test_airflowVersionFromDockerFile(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, expected, version)

// Invalid Dockerfile
dockerfile = "Dockerfile.not.real"
// Default to Airflow 1 when there is an invalid Tag
expected = uint64(0x1)
dockerfile = "Dockerfile.tag.invalid"
version, err = airflowVersionFromDockerFile(airflowHome, dockerfile)

assert.Error(t, err)
assert.NoError(t, err)
assert.Equal(t, expected, version)

// Invalid Airflow Tag
dockerfile = "Dockerfile.tag.invalid"
// Invalid Dockerfile
dockerfile = "Dockerfile.not.real"
version, err = airflowVersionFromDockerFile(airflowHome, dockerfile)

assert.Error(t, err)

}

0 comments on commit e3c74b0

Please sign in to comment.