diff --git a/airflow/container.go b/airflow/container.go index bde0d5eef..9109ba08d 100644 --- a/airflow/container.go +++ b/airflow/container.go @@ -124,10 +124,8 @@ func generateConfig(projectName, airflowHome, envFile, buildImage, settingsFile if envFile != "" { if !envExists { - fmt.Printf(envNotFoundMsg, envFile) envFile = "" } else { - fmt.Printf(envFoundMsg, envFile) envFile = fmt.Sprintf("env_file: %s", envFile) } } diff --git a/airflow/docker.go b/airflow/docker.go index f2c3e64fe..92a4d14a0 100644 --- a/airflow/docker.go +++ b/airflow/docker.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "io" "io/fs" "os" "path/filepath" @@ -23,6 +24,7 @@ import ( "github.com/astronomer/astro-cli/pkg/ansi" "github.com/astronomer/astro-cli/pkg/fileutil" "github.com/astronomer/astro-cli/pkg/logger" + "github.com/astronomer/astro-cli/pkg/spinner" "github.com/astronomer/astro-cli/pkg/util" "github.com/astronomer/astro-cli/settings" "github.com/compose-spec/compose-go/v2/interpolation" @@ -68,9 +70,7 @@ const ( composeUserPasswordMsg = "The default Airflow UI credentials are: %s" postgresUserPasswordMsg = "The default Postgres DB credentials are: %s" - envPathMsg = "Error looking for \"%s\"" - envFoundMsg = "Env file \"%s\" found. Loading...\n" - envNotFoundMsg = "Env file \"%s\" not found. Skipping...\n" + envPathMsg = "Error looking for \"%s\"" ) var ( @@ -166,7 +166,20 @@ func DockerComposeInit(airflowHome, envFile, dockerfile, imageName string) (*Doc imageHandler := DockerImageInit(ImageName(imageName, "latest")) composeFile := Composeyml - dockerCli, err := command.NewDockerCli() + // Determine if we should output to terminal or buffer. + output := logger.GetLevel() >= logrus.DebugLevel + + // Route output streams according to verbosity. + var stdout, stderr io.Writer + if output { + stdout = os.Stdout + stderr = os.Stderr + } else { + stdout = io.Discard + stderr = io.Discard + } + + dockerCli, err := command.NewDockerCli(command.WithOutputStream(stdout), command.WithErrorStream(stderr)) if err != nil { logger.Fatalf("error creating compose client %s", err) } @@ -219,7 +232,7 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS fmt.Printf("Adding 'astro-run-dag' package to requirements.txt unsuccessful: %s\nManually add package to requirements.txt", err.Error()) } } - imageBuildErr := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true, NoCache: noCache}) + imageBuildErr := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, NoCache: noCache}) if !config.CFG.DisableAstroRun.GetBool() { // remove astro-run-dag from requirments.txt err = fileutil.RemoveLineFromFile("./requirements.txt", "astro-run-dag", " # This package is needed for the astro run command. It will be removed before a deploy") @@ -243,6 +256,15 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS return err } + // Determine if we should output to terminal or buffer. + output := logger.GetLevel() >= logrus.DebugLevel + + s := spinner.NewSpinner("Project is starting up…") + if !output { + s.Start() + defer s.Stop() + } + // Create a compose project project, err := createDockerProject(d.projectName, d.airflowHome, d.envFile, "", settingsFile, composeFile, imageLabels) if err != nil { @@ -251,7 +273,9 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS // Start up our project err = d.composeService.Up(context.Background(), project, api.UpOptions{ - Create: api.CreateOptions{}, + Create: api.CreateOptions{ + QuietPull: output, + }, Start: api.StartOptions{ Project: project, }, @@ -260,13 +284,15 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS return errors.Wrap(err, composeRecreateErrMsg) } - fmt.Println("\n\nAirflow is starting up!") - airflowDockerVersion, err := d.checkAiflowVersion() if err != nil { return err } + // If we're logging the output, only start the spinner for waiting on the webserver healthcheck. + s.Start() + defer s.Stop() + // Airflow webserver should be hosted at localhost // from the perspective of the CLI running on the host machine. webserverPort := config.CFG.WebserverPort.GetString() @@ -279,6 +305,8 @@ func (d *DockerCompose) Start(imageName, settingsFile, composeFile, buildSecretS return err } + spinner.StopWithCheckmark(s, "Project has been started") + // If we've successfully gotten a healthcheck response, print the status. err = printStatus(settingsFile, envConns, project, d.composeService, airflowDockerVersion, noBrowser) if err != nil { @@ -321,6 +349,10 @@ func (d *DockerCompose) ComposeExport(settingsFile, composeFile string) error { // Stop a running docker project func (d *DockerCompose) Stop(waitForExit bool) error { + s := spinner.NewSpinner("Stopping project…") + s.Start() + defer s.Stop() + imageLabels, err := d.imageHandler.ListLabels() if err != nil { return err @@ -339,6 +371,7 @@ func (d *DockerCompose) Stop(waitForExit bool) error { } if !waitForExit { + spinner.StopWithCheckmark(s, "Project has been stopped") return nil } @@ -403,6 +436,10 @@ func (d *DockerCompose) PS() error { // Kill stops a local airflow development cluster func (d *DockerCompose) Kill() error { + s := spinner.NewSpinner("Killing project…") + s.Start() + defer s.Stop() + // Killing an already killed project produces an unsightly warning, // so we briefly switch to a higher level before running the kill command. // We then swap back to the original level. @@ -416,6 +453,8 @@ func (d *DockerCompose) Kill() error { return errors.Wrap(err, composeStopErrMsg) } + spinner.StopWithCheckmark(s, "Project has been killed") + return nil } @@ -488,7 +527,7 @@ func (d *DockerCompose) Pytest(pytestFile, customImageName, deployImageName, pyt if deployImageName == "" { // build image if customImageName == "" { - err := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + err := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if err != nil { return "", err } @@ -514,7 +553,7 @@ func (d *DockerCompose) Pytest(pytestFile, customImageName, deployImageName, pyt } // run pytests - exitCode, err := d.imageHandler.Pytest(pytestFile, d.airflowHome, d.envFile, "", pytestArgs, false, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + exitCode, err := d.imageHandler.Pytest(pytestFile, d.airflowHome, d.envFile, "", pytestArgs, false, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if err != nil { return exitCode, err } @@ -548,7 +587,7 @@ func (d *DockerCompose) UpgradeTest(newAirflowVersion, deploymentID, newImageNam } else { // build image for current Airflow version to get current Airflow version fmt.Println("\nBuilding image for current Airflow version") - imageBuildErr := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + imageBuildErr := d.imageHandler.Build(d.dockerfile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if imageBuildErr != nil { return imageBuildErr } @@ -643,7 +682,7 @@ func (d *DockerCompose) conflictTest(testHomeDirectory, newImageName, newAirflow return err } - exitCode, conflictErr := d.imageHandler.ConflictTest(d.airflowHome, testHomeDirectory, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + exitCode, conflictErr := d.imageHandler.ConflictTest(d.airflowHome, testHomeDirectory, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if conflictErr != nil { return conflictErr } @@ -673,7 +712,7 @@ func (d *DockerCompose) versionTest(testHomeDirectory, currentAirflowVersion, de return err } fmt.Println("\nBuilding image for new Airflow version") - imageBuildErr := d.imageHandler.Build(newDockerFile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + imageBuildErr := d.imageHandler.Build(newDockerFile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if imageBuildErr != nil { return imageBuildErr } @@ -711,7 +750,7 @@ func (d *DockerCompose) dagTest(testHomeDirectory, newAirflowVersion, newDockerF fmt.Printf("Adding 'pytest-html' package to requirements.txt unsuccessful: %s\nManually add package to requirements.txt", err.Error()) } fmt.Println("\nBuilding image for new Airflow version") - imageBuildErr := d.imageHandler.Build(newDockerFile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + imageBuildErr := d.imageHandler.Build(newDockerFile, buildSecretString, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) // remove pytest-html to the requirements err = fileutil.RemoveLineFromFile(reqFile, "pytest-html", " # This package is needed for the upgrade dag test. It will be removed once the test is over") @@ -738,7 +777,7 @@ func (d *DockerCompose) dagTest(testHomeDirectory, newAirflowVersion, newDockerF htmlReportArgs := "--html=dag-test-report.html --self-contained-html" // compare pip freeze files fmt.Println("\nRunning DAG parse test with the new Airflow version") - exitCode, err := d.imageHandler.Pytest(pytestFile, d.airflowHome, d.envFile, testHomeDirectory, strings.Fields(htmlReportArgs), true, airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true}) + exitCode, err := d.imageHandler.Pytest(pytestFile, d.airflowHome, d.envFile, testHomeDirectory, strings.Fields(htmlReportArgs), true, airflowTypes.ImageBuildConfig{Path: d.airflowHome}) if err != nil { if strings.Contains(exitCode, "1") { // exit code is 1 meaning tests failed fmt.Println("See above for errors detected in your DAGs") @@ -1256,7 +1295,7 @@ func (d *DockerCompose) RunDAG(dagID, settingsFile, dagFile, executionDate strin fmt.Printf("Removing line 'astro-run-dag' package from requirements.txt unsuccessful: %s\n", err.Error()) } }() - err = d.imageHandler.Build(d.dockerfile, "", airflowTypes.ImageBuildConfig{Path: d.airflowHome, Output: true, NoCache: noCache}) + err = d.imageHandler.Build(d.dockerfile, "", airflowTypes.ImageBuildConfig{Path: d.airflowHome, NoCache: noCache}) if err != nil { return err } @@ -1378,13 +1417,13 @@ func printStatus(settingsFile string, envConns map[string]astrocore.EnvironmentO } } } - fmt.Println("\nProject is running! All components are now available.") parts := strings.Split(config.CFG.WebserverPort.GetString(), ":") webserverURL := "http://localhost:" + parts[len(parts)-1] - fmt.Printf("\n"+composeLinkWebserverMsg+"\n", ansi.Bold(webserverURL)) - fmt.Printf(composeLinkPostgresMsg+"\n", ansi.Bold("localhost:"+config.CFG.PostgresPort.GetString()+"/postgres")) - fmt.Printf(composeUserPasswordMsg+"\n", ansi.Bold("admin:admin")) - fmt.Printf(postgresUserPasswordMsg+"\n", ansi.Bold("postgres:postgres")) + bullet := ansi.Blue("+ ") + fmt.Printf(bullet+composeLinkWebserverMsg+"\n", ansi.Bold(webserverURL)) + fmt.Printf(bullet+composeLinkPostgresMsg+"\n", ansi.Bold("postgresql://localhost:"+config.CFG.PostgresPort.GetString()+"/postgres")) + fmt.Printf(bullet+composeUserPasswordMsg+"\n", ansi.Bold("admin:admin")) + fmt.Printf(bullet+postgresUserPasswordMsg+"\n", ansi.Bold("postgres:postgres")) if !(noBrowser || util.CheckEnvBool(os.Getenv("ASTRONOMER_NO_BROWSER"))) { err = openURL(webserverURL) if err != nil { diff --git a/airflow/docker_image.go b/airflow/docker_image.go index e2aecd2e5..107536e13 100644 --- a/airflow/docker_image.go +++ b/airflow/docker_image.go @@ -17,7 +17,9 @@ import ( "github.com/astronomer/astro-cli/airflow/runtimes" airflowTypes "github.com/astronomer/astro-cli/airflow/types" "github.com/astronomer/astro-cli/config" + "github.com/astronomer/astro-cli/pkg/ansi" "github.com/astronomer/astro-cli/pkg/logger" + "github.com/astronomer/astro-cli/pkg/spinner" "github.com/astronomer/astro-cli/pkg/util" cliConfig "github.com/docker/cli/cli/config" cliTypes "github.com/docker/cli/cli/config/types" @@ -25,6 +27,7 @@ import ( "github.com/docker/docker/api/types/image" "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" + "github.com/sirupsen/logrus" ) const ( @@ -71,6 +74,17 @@ func shouldAddPullFlag(dockerfilePath string) (bool, error) { } func (d *DockerImage) Build(dockerfilePath, buildSecretString string, buildConfig airflowTypes.ImageBuildConfig) error { + // Determine if we should output to terminal or buffer. + output := logger.GetLevel() >= logrus.DebugLevel + + // Start the spinner. + s := spinner.NewSpinner("Building project image…") + s.FinalMSG = ansi.Green("\u2714") + " Project image has been updated\n" + if !output { + s.Start() + defer s.Stop() + } + containerRuntime, err := runtimes.GetContainerRuntimeBinary() if err != nil { return err @@ -118,24 +132,34 @@ func (d *DockerImage) Build(dockerfilePath, buildSecretString string, buildConfi } args = append(args, buildSecretArgs...) } - // Build image + + // Route output streams according to verbosity. var stdout, stderr io.Writer - if buildConfig.Output { + var outBuff bytes.Buffer + if output { stdout = os.Stdout stderr = os.Stderr } else { - stdout = nil - stderr = nil + stdout = &outBuff + stderr = &outBuff } - fmt.Println(args) + + // Build the image err = cmdExec(containerRuntime, stdout, stderr, args...) if err != nil { - return fmt.Errorf("command '%s build -t %s failed: %w", containerRuntime, d.imageName, err) + s.FinalMSG = "" + s.Stop() + fmt.Println(strings.TrimSpace(outBuff.String()) + "\n") + return errors.New("an error was encountered while building the image, see the build logs for details") } - return err + + return nil } func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory string, pytestArgs []string, htmlReport bool, buildConfig airflowTypes.ImageBuildConfig) (string, error) { + // Determine if we should output to terminal or buffer. + output := logger.GetLevel() >= logrus.DebugLevel + // delete container containerRuntime, err := runtimes.GetContainerRuntimeBinary() if err != nil { @@ -167,7 +191,7 @@ func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory args = append(args, pytestArgs...) // run pytest image var stdout, stderr io.Writer - if buildConfig.Output { + if output { stdout = os.Stdout stderr = os.Stderr } else { diff --git a/airflow/docker_image_test.go b/airflow/docker_image_test.go index b22d1d21d..b63c62391 100644 --- a/airflow/docker_image_test.go +++ b/airflow/docker_image_test.go @@ -41,7 +41,6 @@ func (s *Suite) TestDockerImageBuild() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: true, } s.Run("build success", func() { @@ -54,7 +53,6 @@ func (s *Suite) TestDockerImageBuild() { s.Run("build --no-cache", func() { options.NoCache = true - options.Output = false cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error { s.Contains(args, "--no-cache") return nil @@ -117,14 +115,13 @@ FROM quay.io/astronomer/astro-runtime:12.0.0` return errMock } err = handler.Build("", "", options) - s.Contains(err.Error(), errMock.Error()) + s.Errorf(err, "expected build error") }) s.Run("unable to read file error", func() { options := airflowTypes.ImageBuildConfig{ Path: "incorrect-path", TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: false, } err = handler.Build("", "", options) @@ -148,7 +145,6 @@ func (s *Suite) TestDockerImagePytest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: true, } s.Run("pytest success", func() { @@ -207,7 +203,6 @@ func (s *Suite) TestDockerImagePytest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: false, } cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error { @@ -244,7 +239,6 @@ func (s *Suite) TestDockerImageConflictTest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: true, } s.Run("conflict test success", func() { @@ -260,7 +254,6 @@ func (s *Suite) TestDockerImageConflictTest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: false, } cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error { @@ -275,7 +268,6 @@ func (s *Suite) TestDockerImageConflictTest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: false, } cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error { @@ -295,7 +287,6 @@ func (s *Suite) TestDockerImageConflictTest() { Path: cwd, TargetPlatforms: []string{"linux/amd64"}, NoCache: false, - Output: false, } cmdExec = func(cmd string, stdout, stderr io.Writer, args ...string) error { diff --git a/airflow/docker_test.go b/airflow/docker_test.go index e806cf9c5..7eb708864 100644 --- a/airflow/docker_test.go +++ b/airflow/docker_test.go @@ -359,7 +359,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("success", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: airflowVersionLabel}, nil).Times(4) imageHandler.On("TagLocalImage", mock.Anything).Return(nil).Once() @@ -388,7 +388,7 @@ func (s *Suite) TestDockerComposeStart() { defaultTimeOut := 1 * time.Minute noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: airflowVersionLabel}, nil).Times(2) composeMock := new(mocks.DockerComposeAPI) @@ -414,7 +414,7 @@ func (s *Suite) TestDockerComposeStart() { expectedTimeout := 10 * time.Minute noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: airflowVersionLabel}, nil).Times(2) composeMock := new(mocks.DockerComposeAPI) @@ -440,7 +440,7 @@ func (s *Suite) TestDockerComposeStart() { userProvidedTimeOut := 8 * time.Minute noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: airflowVersionLabel}, nil).Times(2) composeMock := new(mocks.DockerComposeAPI) @@ -465,7 +465,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("success with invalid airflow version label", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: "2.3.4.dev+astro1"}, nil).Times(4) imageHandler.On("TagLocalImage", mock.Anything).Return(nil).Once() @@ -517,7 +517,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("image build failure", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(errMockDocker).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(errMockDocker).Once() composeMock := new(mocks.DockerComposeAPI) composeMock.On("Ps", mock.Anything, mockDockerCompose.projectName, api.PsOptions{All: true}).Return([]api.ContainerSummary{}, nil).Once() @@ -539,7 +539,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("list label failure", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{}, errMockDocker).Once() composeMock := new(mocks.DockerComposeAPI) @@ -562,7 +562,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("compose up failure", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{}, nil).Once() composeMock := new(mocks.DockerComposeAPI) @@ -586,7 +586,7 @@ func (s *Suite) TestDockerComposeStart() { s.Run("webserver health check failure", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("ListLabels").Return(map[string]string{airflowVersionLabelName: airflowVersionLabel}, nil).Twice() composeMock := new(mocks.DockerComposeAPI) @@ -978,8 +978,8 @@ func (s *Suite) TestDockerComposePytest() { mockDockerCompose := DockerCompose{projectName: "test"} s.Run("success", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("0", nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("0", nil).Once() mockDockerCompose.imageHandler = imageHandler @@ -993,7 +993,7 @@ func (s *Suite) TestDockerComposePytest() { s.Run("success custom image", func() { imageHandler := new(mocks.ImageHandler) imageHandler.On("TagLocalImage", mock.Anything).Return(nil) - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("0", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("0", nil).Once() mockDockerCompose.imageHandler = imageHandler @@ -1006,8 +1006,8 @@ func (s *Suite) TestDockerComposePytest() { s.Run("unexpected exit code", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("1", nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("1", nil).Once() mockResponse := "1" mockDockerCompose.imageHandler = imageHandler @@ -1020,7 +1020,7 @@ func (s *Suite) TestDockerComposePytest() { s.Run("image build failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(errMockDocker).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1050,12 +1050,12 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("success no deployment id", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Times(3) + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Times(3) imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze2).Return(nil).Once() - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("0", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("0", nil).Once() mockDockerCompose.imageHandler = imageHandler @@ -1071,12 +1071,12 @@ func (s *Suite) TestDockerComposeUpgradeTest() { mockPlatformCoreClient.On("ListDeploymentsWithResponse", mock.Anything, mock.Anything, mock.Anything).Return(&mockListDeploymentsResponse, nil).Twice() mockPlatformCoreClient.On("GetDeploymentWithResponse", mock.Anything, mock.Anything, mock.Anything).Return(&mockGetDeploymentsResponse, nil).Once() imageHandler.On("Pull", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Times(2) + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Times(2) imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze2).Return(nil).Once() - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("0", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("0", nil).Once() mockDockerCompose.imageHandler = imageHandler @@ -1088,7 +1088,7 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("image build failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(errMockDocker).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1099,7 +1099,7 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("GetLabel failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", errMockDocker) mockDockerCompose.imageHandler = imageHandler @@ -1111,7 +1111,7 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("GetLabel failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", errMockDocker) mockDockerCompose.imageHandler = imageHandler @@ -1123,9 +1123,9 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("ConflictTest failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", errMockDocker).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1136,9 +1136,9 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("Create old pip freeze failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1150,11 +1150,11 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("build new image failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Once() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(errMockDocker).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1165,12 +1165,12 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("build new image for pytest failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Times(2) + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Times(2) imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze2).Return(nil).Once() - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(errMockDocker).Once() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1181,12 +1181,12 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("pytest failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Times(3) + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Times(3) imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze2).Return(nil).Once() - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("1", errMockDocker).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("1", errMockDocker).Once() mockDockerCompose.imageHandler = imageHandler @@ -1223,9 +1223,9 @@ func (s *Suite) TestDockerComposeUpgradeTest() { s.Run("build new image failure", func() { imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return(nil).Twice() + imageHandler.On("Build", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return(nil).Twice() imageHandler.On("GetLabel", mock.Anything, mock.Anything).Return("old-version", nil) - imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("", nil).Once() + imageHandler.On("ConflictTest", mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("", nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze).Return(nil).Once() imageHandler.On("CreatePipFreeze", mock.Anything, pipFreeze2).Return(errMockDocker).Once() @@ -1255,7 +1255,7 @@ func (s *Suite) TestDockerComposeParse() { DefaultTestPath = "test_dag_integrity_file.py" imageHandler := new(mocks.ImageHandler) - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("0", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("0", nil).Once() composeMock := new(mocks.DockerComposeAPI) mockDockerCompose.composeService = composeMock @@ -1271,7 +1271,7 @@ func (s *Suite) TestDockerComposeParse() { DefaultTestPath = "test_dag_integrity_file.py" imageHandler := new(mocks.ImageHandler) - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("1", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, []string{}, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("1", nil).Once() composeMock := new(mocks.DockerComposeAPI) mockDockerCompose.composeService = composeMock @@ -1287,7 +1287,7 @@ func (s *Suite) TestDockerComposeParse() { DefaultTestPath = "test_dag_integrity_file.py" imageHandler := new(mocks.ImageHandler) - imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: false}).Return("2", nil).Once() + imageHandler.On("Pytest", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: false}).Return("2", nil).Once() composeMock := new(mocks.DockerComposeAPI) mockDockerCompose.composeService = composeMock @@ -1620,7 +1620,7 @@ func (s *Suite) TestDockerComposeRunDAG() { s.Run("success without container", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("Run", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil).Once() composeMock := new(mocks.DockerComposeAPI) @@ -1639,7 +1639,7 @@ func (s *Suite) TestDockerComposeRunDAG() { s.Run("error without container", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(nil).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(nil).Once() imageHandler.On("Run", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errMockDocker).Once() composeMock := new(mocks.DockerComposeAPI) @@ -1658,7 +1658,7 @@ func (s *Suite) TestDockerComposeRunDAG() { s.Run("build error without container", func() { noCache := false imageHandler := new(mocks.ImageHandler) - imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, Output: true, NoCache: noCache}).Return(errMockDocker).Once() + imageHandler.On("Build", "", "", airflowTypes.ImageBuildConfig{Path: mockDockerCompose.airflowHome, NoCache: noCache}).Return(errMockDocker).Once() composeMock := new(mocks.DockerComposeAPI) composeMock.On("Ps", mock.Anything, mockDockerCompose.projectName, api.PsOptions{All: true}).Return([]api.ContainerSummary{}, nil).Once() diff --git a/airflow/types/types.go b/airflow/types/types.go index 15e0b4828..25a70c5a1 100644 --- a/airflow/types/types.go +++ b/airflow/types/types.go @@ -5,6 +5,5 @@ type ImageBuildConfig struct { Path string TargetPlatforms []string NoCache bool - Output bool Labels []string } diff --git a/cloud/deploy/deploy.go b/cloud/deploy/deploy.go index 449e37f92..34a691da8 100644 --- a/cloud/deploy/deploy.go +++ b/cloud/deploy/deploy.go @@ -621,7 +621,7 @@ func buildImageWithoutDags(path, buildSecretString string, imageHandler airflow. dagsIgnoreSet = true } - err = imageHandler.Build("", buildSecretString, types.ImageBuildConfig{Path: path, Output: true, TargetPlatforms: deployImagePlatformSupport}) + err = imageHandler.Build("", buildSecretString, types.ImageBuildConfig{Path: path, TargetPlatforms: deployImagePlatformSupport}) if err != nil { return err } @@ -650,7 +650,7 @@ func buildImage(path, currentVersion, deployImage, imageName, organizationID, bu return "", err } } else { - err := imageHandler.Build("", buildSecretString, types.ImageBuildConfig{Path: path, Output: true, TargetPlatforms: deployImagePlatformSupport}) + err := imageHandler.Build("", buildSecretString, types.ImageBuildConfig{Path: path, TargetPlatforms: deployImagePlatformSupport}) if err != nil { return "", err } diff --git a/cmd/airflow_hooks.go b/cmd/airflow_hooks.go index 743d108f2..d2172c164 100644 --- a/cmd/airflow_hooks.go +++ b/cmd/airflow_hooks.go @@ -6,6 +6,7 @@ import ( "path/filepath" "github.com/astronomer/astro-cli/airflow/runtimes" + softwareCmd "github.com/astronomer/astro-cli/cmd/software" "github.com/astronomer/astro-cli/cmd/utils" "github.com/astronomer/astro-cli/config" "github.com/spf13/cobra" @@ -28,6 +29,10 @@ func ConfigureContainerRuntime(_ *cobra.Command, _ []string) error { if err != nil { return err } + + if err := softwareCmd.SetUpLogs(os.Stdout, verboseLevel); err != nil { + return err + } return nil } diff --git a/pkg/spinner/spinner.go b/pkg/spinner/spinner.go new file mode 100644 index 000000000..cfd6bd84c --- /dev/null +++ b/pkg/spinner/spinner.go @@ -0,0 +1,34 @@ +package spinner + +import ( + "time" + + "github.com/astronomer/astro-cli/pkg/ansi" + + "github.com/briandowns/spinner" +) + +var spinnerCharSet = spinner.CharSets[14] + +const ( + spinnerRefresh = 100 * time.Millisecond +) + +func NewSpinner(suffix string) *spinner.Spinner { + s := spinner.New(spinnerCharSet, spinnerRefresh) + s.Suffix = " " + suffix + return s +} + +func StopWithCheckmark(s *spinner.Spinner, suffix string) *spinner.Spinner { + s.FinalMSG = " " + suffix + s.FinalMSG = ansi.Green("\u2714") + " " + suffix + "\n" + s.Stop() + return s +} + +func StopWithEmptyString(s *spinner.Spinner) *spinner.Spinner { + s.FinalMSG = "" + s.Stop() + return s +} diff --git a/software/deploy/deploy.go b/software/deploy/deploy.go index 501ed98e8..01e185d87 100644 --- a/software/deploy/deploy.go +++ b/software/deploy/deploy.go @@ -187,7 +187,6 @@ func buildPushDockerImage(houstonClient houston.ClientInterface, c *config.Conte Path: config.WorkingPath, NoCache: ignoreCacheDeploy, TargetPlatforms: deployImagePlatformSupport, - Output: true, Labels: deployLabels, }