From 12fcc9f1e62ce417fff0dcd3f0db41edf6540c4b Mon Sep 17 00:00:00 2001 From: Jeremy Beard Date: Thu, 12 Dec 2024 13:11:08 +1100 Subject: [PATCH] Use new instance of logrus logger --- airflow/container.go | 4 +-- airflow/docker.go | 20 +++++++-------- airflow/docker_image.go | 42 +++++++++++++++---------------- airflow/docker_registry.go | 4 +-- airflow/docker_test.go | 14 +++++------ cloud/auth/auth.go | 4 +-- cloud/deploy/bundle.go | 18 ++++++------- cmd/cloud/setup.go | 8 +++--- cmd/registry/dag.go | 12 ++++----- cmd/registry/dag_test.go | 6 ++--- cmd/registry/provider.go | 20 +++++++-------- cmd/registry/provider_test.go | 6 ++--- cmd/root.go | 2 +- cmd/software/root.go | 7 +++--- cmd/software/root_test.go | 6 ++--- cmd/software/teams.go | 4 +-- cmd/software/workspace.go | 4 +-- cmd/software/workspace_user.go | 4 +-- houston/utils.go | 4 +-- houston/websocket.go | 7 +++--- pkg/fileutil/files.go | 6 ++--- pkg/httputil/http.go | 20 +++++++-------- pkg/logger/logger.go | 5 ++++ settings/settings.go | 18 ++++++------- software/auth/auth.go | 11 ++++---- software/deployment/deployment.go | 14 +++++------ software/teams/teams.go | 4 +-- 27 files changed, 140 insertions(+), 134 deletions(-) create mode 100644 pkg/logger/logger.go diff --git a/airflow/container.go b/airflow/container.go index 2f671d24d..476efe9aa 100644 --- a/airflow/container.go +++ b/airflow/container.go @@ -14,11 +14,11 @@ import ( astroplatformcore "github.com/astronomer/astro-cli/astro-client-platform-core" "github.com/astronomer/astro-cli/config" "github.com/astronomer/astro-cli/pkg/fileutil" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/util" "github.com/docker/compose/v2/pkg/api" "github.com/docker/docker/client" "github.com/pkg/errors" - log "github.com/sirupsen/logrus" ) type ContainerHandler interface { @@ -144,7 +144,7 @@ func generateConfig(projectName, airflowHome, envFile, buildImage, settingsFile settingsFileExist, err := util.Exists("./" + settingsFile) if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } cfg := ComposeConfig{ diff --git a/airflow/docker.go b/airflow/docker.go index 647deae12..0f5debb9a 100644 --- a/airflow/docker.go +++ b/airflow/docker.go @@ -13,6 +13,7 @@ import ( "time" "github.com/astronomer/astro-cli/airflow/runtimes" + "github.com/astronomer/astro-cli/pkg/logger" semver "github.com/Masterminds/semver/v3" airflowTypes "github.com/astronomer/astro-cli/airflow/types" @@ -38,7 +39,6 @@ import ( "github.com/docker/docker/api/types/versions" "github.com/pkg/browser" "github.com/pkg/errors" - "github.com/sirupsen/logrus" ) const ( @@ -169,12 +169,12 @@ func DockerComposeInit(airflowHome, envFile, dockerfile, imageName string) (*Doc dockerCli, err := command.NewDockerCli() if err != nil { - logrus.Fatalf("error creating compose client %s", err) + logger.Logger.Fatalf("error creating compose client %s", err) } err = dockerCli.Initialize(flags.NewClientOptions()) if err != nil { - logrus.Fatalf("error init compose client %s", err) + logger.Logger.Fatalf("error init compose client %s", err) } composeService := compose.NewComposeService(dockerCli.Client(), &configfile.ConfigFile{}) @@ -348,7 +348,7 @@ func (d *DockerCompose) Stop(waitForExit bool) error { for { select { case <-timeout: - logrus.Debug("timed out waiting for postgres container to be in exited state") + logger.Logger.Debug("timed out waiting for postgres container to be in exited state") return nil case <-ticker.C: psInfo, _ := d.composeService.Ps(context.Background(), d.projectName, api.PsOptions{ @@ -359,10 +359,10 @@ func (d *DockerCompose) Stop(waitForExit bool) error { // so docker compose will ensure that postgres container going in shutting down phase only after all other containers have exited if strings.Contains(psInfo[i].Name, PostgresDockerContainerName) { if psInfo[i].State == dockerExitState { - logrus.Debug("postgres container reached exited state") + logger.Logger.Debug("postgres container reached exited state") return nil } - logrus.Debugf("postgres container is still in %s state, waiting for it to be in exited state", psInfo[i].State) + logger.Logger.Debugf("postgres container is still in %s state, waiting for it to be in exited state", psInfo[i].State) } } } @@ -764,7 +764,7 @@ func upgradeDockerfile(oldDockerfilePath, newDockerfilePath, newTag, newImage st if strings.HasPrefix(strings.TrimSpace(line), "FROM quay.io/astronomer/ap-airflow:") { isRuntime, err := isRuntimeVersion(newTag) if err != nil { - logrus.Debug(err) + logger.Logger.Debug(err) } if isRuntime { // Replace the tag on the matching line @@ -997,17 +997,17 @@ func writeToCompareFile(title string, pkgList []string, writer *bufio.Writer) { if len(pkgList) > 0 { _, err := writer.WriteString(title) if err != nil { - logrus.Debug(err) + logger.Logger.Debug(err) } for _, pkg := range pkgList { _, err = writer.WriteString(pkg + "\n") if err != nil { - logrus.Debug(err) + logger.Logger.Debug(err) } } _, err = writer.WriteString("\n") if err != nil { - logrus.Debug(err) + logger.Logger.Debug(err) } } } diff --git a/airflow/docker_image.go b/airflow/docker_image.go index cfddaab12..027393892 100644 --- a/airflow/docker_image.go +++ b/airflow/docker_image.go @@ -16,6 +16,7 @@ import ( "github.com/astronomer/astro-cli/airflow/runtimes" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/util" cliCommand "github.com/docker/cli/cli/command" cliConfig "github.com/docker/cli/cli/config" @@ -23,7 +24,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" - log "github.com/sirupsen/logrus" airflowTypes "github.com/astronomer/astro-cli/airflow/types" "github.com/astronomer/astro-cli/config" @@ -145,7 +145,7 @@ func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory } err = cmdExec(containerRuntime, nil, nil, "rm", "astro-pytest") if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } // Change to location of Dockerfile err = os.Chdir(buildConfig.Path) @@ -211,7 +211,7 @@ func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory // start pytest container err = cmdExec(containerRuntime, stdout, stderr, []string{"start", "astro-pytest", "-a"}...) if err != nil { - log.Debugf("Error starting pytest container: %s", err.Error()) + logger.Logger.Debugf("Error starting pytest container: %s", err.Error()) } // get exit code @@ -223,27 +223,27 @@ func (d *DockerImage) Pytest(pytestFile, airflowHome, envFile, testHomeDirectory var outb bytes.Buffer docErr = cmdExec(containerRuntime, &outb, stderr, args...) if docErr != nil { - log.Debug(docErr) + logger.Logger.Debug(docErr) } if htmlReport { // Copy the dag-test-report.html file from the container to the destination folder docErr = cmdExec(containerRuntime, nil, stderr, "cp", "astro-pytest:/usr/local/airflow/dag-test-report.html", "./"+testHomeDirectory) if docErr != nil { - log.Debugf("Error copying dag-test-report.html file from the pytest container: %s", docErr.Error()) + logger.Logger.Debugf("Error copying dag-test-report.html file from the pytest container: %s", docErr.Error()) } } // Persist the include folder from the Docker container to local include folder docErr = cmdExec(containerRuntime, nil, stderr, "cp", "astro-pytest:/usr/local/airflow/include/", ".") if docErr != nil { - log.Debugf("Error copying include folder from the pytest container: %s", docErr.Error()) + logger.Logger.Debugf("Error copying include folder from the pytest container: %s", docErr.Error()) } // delete container docErr = cmdExec(containerRuntime, nil, stderr, "rm", "astro-pytest") if docErr != nil { - log.Debugf("Error removing the astro-pytest container: %s", docErr.Error()) + logger.Logger.Debugf("Error removing the astro-pytest container: %s", docErr.Error()) } return outb.String(), err @@ -257,7 +257,7 @@ func (d *DockerImage) ConflictTest(workingDirectory, testHomeDirectory string, b // delete container err = cmdExec(containerRuntime, nil, nil, "rm", "astro-temp-container") if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } // Change to location of Dockerfile err = os.Chdir(buildConfig.Path) @@ -375,7 +375,7 @@ func (d *DockerImage) Push(remoteImage, username, token string) error { authConfig, err := configFile.GetAuthConfig(registry) if err != nil { - log.Debugf("Error reading credentials: %v", err) + logger.Logger.Debugf("Error reading credentials: %v", err) return fmt.Errorf("error reading credentials: %w", err) } @@ -384,7 +384,7 @@ func (d *DockerImage) Push(remoteImage, username, token string) error { creds := configFile.GetCredentialsStore(registryDomain) authConfig, err = creds.Get(registryDomain) if err != nil { - log.Debugf("Error reading credentials for domain: %s from %s credentials store: %v", containerRuntime, registryDomain, err) + logger.Logger.Debugf("Error reading credentials for domain: %s from %s credentials store: %v", containerRuntime, registryDomain, err) } } else { if username != "" { @@ -394,7 +394,7 @@ func (d *DockerImage) Push(remoteImage, username, token string) error { authConfig.ServerAddress = registry } - log.Debugf("Exec Push %s creds %v \n", containerRuntime, authConfig) + logger.Logger.Debugf("Exec Push %s creds %v \n", containerRuntime, authConfig) err = d.pushWithClient(&authConfig, remoteImage) if err != nil { @@ -441,19 +441,19 @@ func (d *DockerImage) pushWithClient(authConfig *cliTypes.AuthConfig, remoteImag cli, err := getDockerClient() if err != nil { - log.Debugf("Error setting up new Client ops %v", err) + logger.Logger.Debugf("Error setting up new Client ops %v", err) return err } cli.NegotiateAPIVersion(ctx) buf, err := json.Marshal(authConfig) if err != nil { - log.Debugf("Error negotiating api version: %v", err) + logger.Logger.Debugf("Error negotiating api version: %v", err) return err } encodedAuth := base64.URLEncoding.EncodeToString(buf) responseBody, err := cli.ImagePush(ctx, remoteImage, types.ImagePushOptions{RegistryAuth: encodedAuth}) if err != nil { - log.Debugf("Error pushing image to docker: %v", err) + logger.Logger.Debugf("Error pushing image to docker: %v", err) // if NewClientWithOpt does not work use bash to run docker commands return err } @@ -607,7 +607,7 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile, // delete container err = cmdExec(containerRuntime, nil, nil, "rm", astroRunContainer) if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } var args []string if containerName != "" { @@ -620,7 +620,7 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile, // check if settings file exists settingsFileExist, err := util.Exists("./" + settingsFile) if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } // docker exec if containerName == "" { @@ -643,7 +643,7 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile, // if env file exists append it to args fileExist, err := util.Exists(config.WorkingPath + "/" + envFile) if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } if fileExist { args = append(args, []string{"--env-file", envFile}...) @@ -675,13 +675,13 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile, fmt.Println("\nStarting a DAG run for " + dagID + "...") fmt.Println("\nLoading DAGs...") - log.Debug("args passed to docker command:") - log.Debug(args) + logger.Logger.Debug("args passed to docker command:") + logger.Logger.Debug(args) cmdErr := cmdExec(containerRuntime, stdout, stderr, args...) // add back later fmt.Println("\nSee the output of this command for errors. To view task logs, use the '--task-logs' flag.") if cmdErr != nil { - log.Debug(cmdErr) + logger.Logger.Debug(cmdErr) fmt.Println("\nSee the output of this command for errors.") fmt.Println("If you are having an issue with loading your settings file make sure both the 'variables' and 'connections' fields exist and that there are no yaml syntax errors.") fmt.Println("If you are getting a missing `airflow_settings.yaml` or `astro-run-dag` error try restarting airflow with `astro dev restart`.") @@ -690,7 +690,7 @@ func (d *DockerImage) Run(dagID, envFile, settingsFile, containerName, dagFile, // delete container err = cmdExec(containerRuntime, nil, nil, "rm", astroRunContainer) if err != nil { - log.Debug(err) + logger.Logger.Debug(err) } } return cmdErr diff --git a/airflow/docker_registry.go b/airflow/docker_registry.go index 82fadcc63..b61d84a5f 100644 --- a/airflow/docker_registry.go +++ b/airflow/docker_registry.go @@ -5,12 +5,12 @@ import ( "fmt" "os" + "github.com/astronomer/astro-cli/pkg/logger" cliConfig "github.com/docker/cli/cli/config" cliTypes "github.com/docker/cli/cli/config/types" "github.com/docker/docker/api/types" "github.com/docker/docker/client" "github.com/docker/docker/registry" - log "github.com/sirupsen/logrus" ) type DockerRegistry struct { @@ -53,7 +53,7 @@ func (d *DockerRegistry) Login(username, token string) error { authConfig.Password = auth.Password } - log.Debugf("docker creds %v \n", authConfig) + logger.Logger.Debugf("docker creds %v \n", authConfig) _, err := d.cli.RegistryLogin(ctx, authConfig) if err != nil { return fmt.Errorf("registry login error: %w", err) diff --git a/airflow/docker_test.go b/airflow/docker_test.go index 42a5a02c0..bfaf44c15 100644 --- a/airflow/docker_test.go +++ b/airflow/docker_test.go @@ -15,9 +15,9 @@ import ( astrocore "github.com/astronomer/astro-cli/astro-client-core" astroplatformcore "github.com/astronomer/astro-cli/astro-client-platform-core" astroplatformcore_mocks "github.com/astronomer/astro-cli/astro-client-platform-core/mocks" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/config" - "github.com/sirupsen/logrus" "github.com/astronomer/astro-cli/pkg/fileutil" testUtil "github.com/astronomer/astro-cli/pkg/testing" @@ -712,9 +712,9 @@ func (s *Suite) TestDockerComposeStop() { mockDockerCompose.composeService = composeMock mockDockerCompose.imageHandler = imageHandler - logrus.SetLevel(5) // debug level + logger.Logger.SetLevel(5) // debug level var out bytes.Buffer - logrus.SetOutput(&out) + logger.Logger.SetOutput(&out) err := mockDockerCompose.Stop(true) s.NoError(err) @@ -736,9 +736,9 @@ func (s *Suite) TestDockerComposeStop() { mockDockerCompose.composeService = composeMock mockDockerCompose.imageHandler = imageHandler - logrus.SetLevel(5) // debug level + logger.Logger.SetLevel(5) // debug level var out bytes.Buffer - logrus.SetOutput(&out) + logger.Logger.SetOutput(&out) err := mockDockerCompose.Stop(true) s.NoError(err) @@ -764,9 +764,9 @@ func (s *Suite) TestDockerComposeStop() { mockDockerCompose.composeService = composeMock mockDockerCompose.imageHandler = imageHandler - logrus.SetLevel(5) // debug level + logger.Logger.SetLevel(5) // debug level var out bytes.Buffer - logrus.SetOutput(&out) + logger.Logger.SetOutput(&out) err := mockDockerCompose.Stop(true) s.NoError(err) diff --git a/cloud/auth/auth.go b/cloud/auth/auth.go index a252a8536..11261a5b5 100644 --- a/cloud/auth/auth.go +++ b/cloud/auth/auth.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "log" "math/rand" "net/http" "net/url" @@ -25,6 +24,7 @@ import ( "github.com/astronomer/astro-cli/pkg/ansi" "github.com/astronomer/astro-cli/pkg/domainutil" "github.com/astronomer/astro-cli/pkg/httputil" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/util" ) @@ -155,7 +155,7 @@ func authorizeCallbackHandler() (string, error) { }) go func() { if err := s.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { - log.Fatal(err) + logger.Logger.Fatal(err) } }() diff --git a/cloud/deploy/bundle.go b/cloud/deploy/bundle.go index a3066b742..aa678c121 100644 --- a/cloud/deploy/bundle.go +++ b/cloud/deploy/bundle.go @@ -14,7 +14,7 @@ import ( "github.com/astronomer/astro-cli/config" "github.com/astronomer/astro-cli/pkg/fileutil" "github.com/astronomer/astro-cli/pkg/git" - "github.com/sirupsen/logrus" + "github.com/astronomer/astro-cli/pkg/logger" ) type DeployBundleInput struct { @@ -226,20 +226,20 @@ func retrieveLocalGitMetadata(bundlePath string) (deployGit *astrocore.DeployGit // get the remote repository details, assume the remote is named "origin" repoURL, err := git.GetRemoteRepository(bundlePath, "origin") if err != nil { - logrus.Debugf("Failed to retrieve remote repository details, skipping Git metadata retrieval: %s", err) + logger.Logger.Debugf("Failed to retrieve remote repository details, skipping Git metadata retrieval: %s", err) return nil, "" } switch repoURL.Host { case "github.com": deployGit.Provider = astrocore.DeployGitProviderGITHUB default: - logrus.Debugf("Unsupported Git provider, skipping Git metadata retrieval: %s", repoURL.Host) + logger.Logger.Debugf("Unsupported Git provider, skipping Git metadata retrieval: %s", repoURL.Host) return nil, "" } urlPath := strings.TrimPrefix(repoURL.Path, "/") firstSlashIndex := strings.Index(urlPath, "/") if firstSlashIndex == -1 { - logrus.Debugf("Failed to parse remote repository path, skipping Git metadata retrieval: %s", repoURL.Path) + logger.Logger.Debugf("Failed to parse remote repository path, skipping Git metadata retrieval: %s", repoURL.Path) return nil, "" } deployGit.Account = urlPath[:firstSlashIndex] @@ -248,7 +248,7 @@ func retrieveLocalGitMetadata(bundlePath string) (deployGit *astrocore.DeployGit // get the path of the bundle within the repository path, err := git.GetLocalRepositoryPathPrefix(bundlePath, bundlePath) if err != nil { - logrus.Debugf("Failed to retrieve local repository path prefix, skipping Git metadata retrieval: %s", err) + logger.Logger.Debugf("Failed to retrieve local repository path prefix, skipping Git metadata retrieval: %s", err) return nil, "" } if path != "" { @@ -258,7 +258,7 @@ func retrieveLocalGitMetadata(bundlePath string) (deployGit *astrocore.DeployGit // get the branch of the local commit branch, err := git.GetBranch(bundlePath) if err != nil { - logrus.Debugf("Failed to retrieve branch name, skipping Git metadata retrieval: %s", err) + logger.Logger.Debugf("Failed to retrieve branch name, skipping Git metadata retrieval: %s", err) return nil, "" } deployGit.Branch = branch @@ -266,7 +266,7 @@ func retrieveLocalGitMetadata(bundlePath string) (deployGit *astrocore.DeployGit // get the local commit sha, message, authorName, _, err := git.GetHeadCommit(bundlePath) if err != nil { - logrus.Debugf("Failed to retrieve commit, skipping Git metadata retrieval: %s", err) + logger.Logger.Debugf("Failed to retrieve commit, skipping Git metadata retrieval: %s", err) return nil, "" } deployGit.CommitSha = sha @@ -279,11 +279,11 @@ func retrieveLocalGitMetadata(bundlePath string) (deployGit *astrocore.DeployGit case "github.com": deployGit.CommitUrl = fmt.Sprintf("https://%s/%s/%s/commit/%s", repoURL.Host, deployGit.Account, deployGit.Repo, sha) default: - logrus.Debugf("Unsupported Git provider, skipping Git metadata retrieval: %s", repoURL.Host) + logger.Logger.Debugf("Unsupported Git provider, skipping Git metadata retrieval: %s", repoURL.Host) return nil, "" } - logrus.Debugf("Retrieved Git metadata: %+v", deployGit) + logger.Logger.Debugf("Retrieved Git metadata: %+v", deployGit) return deployGit, message } diff --git a/cmd/cloud/setup.go b/cmd/cloud/setup.go index 857c83adf..c633a792a 100644 --- a/cmd/cloud/setup.go +++ b/cmd/cloud/setup.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "log" "net/http" "net/url" "os" @@ -19,6 +18,7 @@ import ( "github.com/astronomer/astro-cli/cloud/organization" "github.com/astronomer/astro-cli/context" "github.com/astronomer/astro-cli/pkg/httputil" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/util" "github.com/golang-jwt/jwt/v4" @@ -208,14 +208,14 @@ func refresh(refreshToken string, authConfig auth.Config) (TokenResponse, error) r, err := http.NewRequestWithContext(http_context.Background(), http.MethodPost, addr, strings.NewReader(data.Encode())) // URL-encoded payload if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) return TokenResponse{}, fmt.Errorf("cannot get a new access token from the refresh token: %w", err) } r.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, err := client.Do(r) if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) return TokenResponse{}, fmt.Errorf("cannot get a new access token from the refresh token: %w", err) } defer res.Body.Close() @@ -298,7 +298,7 @@ func checkAPIKeys(platformCoreClient astroplatformcore.CoreClient, isDeploymentF // execute request res, err := client.Do(doOptions) if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) return false, fmt.Errorf("cannot getaccess token with API keys: %w", err) } defer res.Body.Close() diff --git a/cmd/registry/dag.go b/cmd/registry/dag.go index 44ab77d7e..d9c87744d 100644 --- a/cmd/registry/dag.go +++ b/cmd/registry/dag.go @@ -6,11 +6,11 @@ import ( "io" "net/url" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/astronomer/astro-cli/pkg/httputil" "github.com/astronomer/astro-cli/pkg/input" + "github.com/astronomer/astro-cli/pkg/logger" ) const ( @@ -70,13 +70,13 @@ func downloadDag(dagID, dagVersion string, addProviders bool, out io.Writer) { githubRawSourceURL, exists := dagJSON["githubRawSourceUrl"].(string) if !exists { - log.Fatalf("Couldn't find key githubRawSourceUrl in Response! %v", dagJSON) + logger.Logger.Fatalf("Couldn't find key githubRawSourceUrl in Response! %v", dagJSON) } filePath, exists := dagJSON["filePath"].(string) if !exists { jsonString, _ := json.Marshal(dagJSON) - log.Fatalf("Couldn't find key 'filePath' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'filePath' in Response! %s", jsonString) } httputil.DownloadResponseToFile(githubRawSourceURL, filePath) _, _ = fmt.Fprintf(out, "Successfully added DAG %s:%s to %s ", dagID, dagVersion, filePath) @@ -85,16 +85,16 @@ func downloadDag(dagID, dagVersion string, addProviders bool, out io.Writer) { providers, providersExists := dagJSON["providers"].([]interface{}) if !providersExists { jsonString, _ := json.Marshal(dagJSON) - log.Fatalf("Couldn't find key 'providers' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'providers' in Response! %s", jsonString) } for _, provider := range providers { providerJSON := provider.(map[string]interface{}) providerID, nameExists := providerJSON["name"].(string) // displayName?? if !nameExists { jsonString, _ := json.Marshal(providerJSON) - log.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) } - log.Infof("Adding provider required for DAG: %s", providerID) + logger.Logger.Infof("Adding provider required for DAG: %s", providerID) addProviderByName(providerID, out) } } diff --git a/cmd/registry/dag_test.go b/cmd/registry/dag_test.go index f35e4861d..21573f880 100644 --- a/cmd/registry/dag_test.go +++ b/cmd/registry/dag_test.go @@ -5,17 +5,17 @@ import ( "os" "github.com/astronomer/astro-cli/pkg/fileutil" + "github.com/astronomer/astro-cli/pkg/logger" testUtil "github.com/astronomer/astro-cli/pkg/testing" - log "github.com/sirupsen/logrus" ) func execDagCmd(args ...string) (string, error) { buf := new(bytes.Buffer) cmd := newRegistryDagCmd(os.Stdout) cmd.SetOut(buf) - log.SetOutput(buf) + logger.Logger.SetOutput(buf) defer func() { - log.SetOutput(os.Stderr) + logger.Logger.SetOutput(os.Stderr) }() cmd.SetArgs(args) testUtil.SetupOSArgsForGinkgo() diff --git a/cmd/registry/provider.go b/cmd/registry/provider.go index 8d473d82b..72297e770 100644 --- a/cmd/registry/provider.go +++ b/cmd/registry/provider.go @@ -8,11 +8,11 @@ import ( "os" "strings" - log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/astronomer/astro-cli/pkg/httputil" "github.com/astronomer/astro-cli/pkg/input" + "github.com/astronomer/astro-cli/pkg/logger" ) const writeAndReadPermissions = 0o655 @@ -74,7 +74,7 @@ func addProviderByName(providerName string, out io.Writer) { providers, exists := providersJSON["providers"].([]interface{}) if !exists { jsonString, _ := json.Marshal(providersJSON) - log.Fatalf("Couldn't find key 'providers' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'providers' in Response! %s", jsonString) } for _, provider := range providers { @@ -83,12 +83,12 @@ func addProviderByName(providerName string, out io.Writer) { providerID, childExists := childProvidersJSON["name"].(string) // displayName?? if !childExists { jsonString, _ := json.Marshal(childProvidersJSON) - log.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) } thisProviderVersion, childExists := childProvidersJSON["version"].(string) // displayName?? if !childExists { jsonString, _ := json.Marshal(childProvidersJSON) - log.Fatalf("Couldn't find key 'version' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'version' in Response! %s", jsonString) } addProviderByIDAndVersion(providerID, thisProviderVersion, out) } @@ -101,13 +101,13 @@ func addProviderByIDAndVersion(providerID, providerVersion string, out io.Writer name, exists := providersJSON["name"].(string) if !exists { jsonString, _ := json.Marshal(providersJSON) - log.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'name' in Response! %s", jsonString) } version, exists := providersJSON["version"].(string) if !exists { jsonString, _ := json.Marshal(providersJSON) - log.Fatalf("Couldn't find key 'version' in Response! %s", jsonString) + logger.Logger.Fatalf("Couldn't find key 'version' in Response! %s", jsonString) } addProviderToRequirementsTxt(name, version, out) } @@ -116,23 +116,23 @@ func addProviderToRequirementsTxt(name, version string, out io.Writer) { const filename = "requirements.txt" f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, writeAndReadPermissions) if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) } b, err := os.ReadFile(filename) if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) } exists := strings.Contains(string(b), name) if exists { fmt.Printf("%s already exists in %s", name, filename) } else { - log.Debugf("Couldn't find %s already in %s", name, string(b)) + logger.Logger.Debugf("Couldn't find %s already in %s", name, string(b)) providerString := fmt.Sprintf("%s==%s", name, version) _, err = f.WriteString(providerString + "\n") if err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) } _, _ = fmt.Fprintf(out, "\nWrote %s to %s", providerString, filename) } diff --git a/cmd/registry/provider_test.go b/cmd/registry/provider_test.go index bf4983e79..9fe319bb1 100644 --- a/cmd/registry/provider_test.go +++ b/cmd/registry/provider_test.go @@ -5,17 +5,17 @@ import ( "os" "github.com/astronomer/astro-cli/pkg/fileutil" + "github.com/astronomer/astro-cli/pkg/logger" testUtil "github.com/astronomer/astro-cli/pkg/testing" - log "github.com/sirupsen/logrus" ) func execProviderCmd(args ...string) (string, error) { buf := new(bytes.Buffer) cmd := newRegistryProviderCmd(os.Stdout) cmd.SetOut(buf) - log.SetOutput(buf) + logger.Logger.SetOutput(buf) defer func() { - log.SetOutput(os.Stderr) + logger.Logger.SetOutput(os.Stderr) }() cmd.SetArgs(args) testUtil.SetupOSArgsForGinkgo() diff --git a/cmd/root.go b/cmd/root.go index 0d49b9213..8108bb730 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,6 +9,7 @@ import ( "time" "github.com/astronomer/astro-cli/cmd/registry" + "github.com/sirupsen/logrus" airflowclient "github.com/astronomer/astro-cli/airflow-client" astrocore "github.com/astronomer/astro-cli/astro-client-core" @@ -24,7 +25,6 @@ import ( "github.com/astronomer/astro-cli/version" "github.com/google/go-github/v48/github" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/cmd/software/root.go b/cmd/software/root.go index 82e785f9d..60c15859b 100644 --- a/cmd/software/root.go +++ b/cmd/software/root.go @@ -5,6 +5,7 @@ import ( "io" "github.com/astronomer/astro-cli/houston" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/config" "github.com/sirupsen/logrus" @@ -52,18 +53,18 @@ func SetUpLogs(out io.Writer, level string) error { if level == "warning" { level = config.CFG.Verbosity.GetString() } - logrus.SetOutput(out) + logger.Logger.SetOutput(out) lvl, err := logrus.ParseLevel(level) if err != nil { return err } - logrus.SetLevel(lvl) + logger.Logger.SetLevel(lvl) return nil } func PrintDebugLogs() { for _, log := range InitDebugLogs { - logrus.Debug(log) + logger.Logger.Debug(log) } // Free-up memory used by init logs InitDebugLogs = nil diff --git a/cmd/software/root_test.go b/cmd/software/root_test.go index 0608ea2a6..aba5d6b68 100644 --- a/cmd/software/root_test.go +++ b/cmd/software/root_test.go @@ -8,8 +8,8 @@ import ( "github.com/astronomer/astro-cli/config" "github.com/astronomer/astro-cli/houston" houston_mocks "github.com/astronomer/astro-cli/houston/mocks" + "github.com/astronomer/astro-cli/pkg/logger" testUtil "github.com/astronomer/astro-cli/pkg/testing" - "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" ) @@ -86,7 +86,7 @@ func (s *AddCmdSuite) TestSetupLogs() { buf := new(bytes.Buffer) err := SetUpLogs(buf, "info") s.NoError(err) - s.Equal("info", logrus.GetLevel().String()) + s.Equal("info", logger.Logger.GetLevel().String()) testUtil.InitTestConfig(testUtil.SoftwarePlatform) err = config.CFG.Verbosity.SetHomeString("error") @@ -94,7 +94,7 @@ func (s *AddCmdSuite) TestSetupLogs() { err = SetUpLogs(buf, "warning") s.NoError(err) - s.Equal("error", logrus.GetLevel().String()) + s.Equal("error", logger.Logger.GetLevel().String()) err = SetUpLogs(buf, "invalid-level") s.EqualError(err, "not a valid logrus Level: \"invalid-level\"") diff --git a/cmd/software/teams.go b/cmd/software/teams.go index d6cd70fee..c38769484 100644 --- a/cmd/software/teams.go +++ b/cmd/software/teams.go @@ -4,8 +4,8 @@ import ( "io" "github.com/astronomer/astro-cli/config" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/software/teams" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -86,7 +86,7 @@ func listTeam(_ *cobra.Command, out io.Writer, paginated bool, pageSize int) err } if !(pageSize > 0 && pageSize <= teams.ListTeamLimit) { - logrus.Warnf("Page size cannot be more than %d, reducing the page size to %d", teams.ListTeamLimit, teams.ListTeamLimit) + logger.Logger.Warnf("Page size cannot be more than %d, reducing the page size to %d", teams.ListTeamLimit, teams.ListTeamLimit) pageSize = teams.ListTeamLimit } diff --git a/cmd/software/workspace.go b/cmd/software/workspace.go index eca09581d..2895ae70a 100644 --- a/cmd/software/workspace.go +++ b/cmd/software/workspace.go @@ -6,8 +6,8 @@ import ( "github.com/astronomer/astro-cli/config" "github.com/astronomer/astro-cli/houston" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/software/workspace" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -197,7 +197,7 @@ func workspaceSwitch(cmd *cobra.Command, out io.Writer, args []string) error { } if !(workspacePageSize > 0 && workspacePageSize <= defaultPageSize) { - logrus.Warnf("Page size cannot be more than %d, reducing the page size to %d", defaultPageSize, defaultPageSize) + logger.Logger.Warnf("Page size cannot be more than %d, reducing the page size to %d", defaultPageSize, defaultPageSize) workspacePageSize = defaultPageSize } } diff --git a/cmd/software/workspace_user.go b/cmd/software/workspace_user.go index 03b2f5d2b..9572c1598 100644 --- a/cmd/software/workspace_user.go +++ b/cmd/software/workspace_user.go @@ -6,8 +6,8 @@ import ( "github.com/astronomer/astro-cli/config" "github.com/astronomer/astro-cli/houston" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/software/workspace" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -160,7 +160,7 @@ func workspaceUserList(_ *cobra.Command, out io.Writer) error { } if !(pageSize > 0 && pageSize <= defaultWorkspaceUserPageSize) { - logrus.Warnf("Page size cannot be more than %d, reducing the page size to %d", defaultWorkspaceUserPageSize, defaultWorkspaceUserPageSize) + logger.Logger.Warnf("Page size cannot be more than %d, reducing the page size to %d", defaultWorkspaceUserPageSize, defaultWorkspaceUserPageSize) pageSize = defaultWorkspaceUserPageSize } diff --git a/houston/utils.go b/houston/utils.go index 3221e64a5..ad798c2bb 100644 --- a/houston/utils.go +++ b/houston/utils.go @@ -3,7 +3,7 @@ package houston import ( "sort" - "github.com/sirupsen/logrus" + "github.com/astronomer/astro-cli/pkg/logger" "golang.org/x/mod/semver" ) @@ -41,6 +41,6 @@ func (s queryList) GreatestLowerBound(v string) string { return s[idx].query } } - logrus.Debugf("GraphQL query not defined for the given Platform version: %s, falling back to latest query", v) + logger.Logger.Debugf("GraphQL query not defined for the given Platform version: %s, falling back to latest query", v) return s[len(s)-1].query } diff --git a/houston/websocket.go b/houston/websocket.go index c679d12c6..3db5c6b8e 100644 --- a/houston/websocket.go +++ b/houston/websocket.go @@ -9,6 +9,7 @@ import ( "os/signal" "time" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/gorilla/websocket" ) @@ -77,7 +78,7 @@ func Subscribe(jwtToken, url, queryMessage string) error { h := http.Header{"Sec-WebSocket-Protocol": []string{"graphql-ws"}} ws, resp, err := websocket.DefaultDialer.Dial(url, h) if err != nil { - log.Fatal("dial:", err) + logger.Logger.Fatal("dial:", err) } defer func() { ws.Close() @@ -112,12 +113,12 @@ func Subscribe(jwtToken, url, queryMessage string) error { fmt.Println("Your token has expired. Please log in again.") return default: - log.Fatal(err) + logger.Logger.Fatal(err) } } var resp WSResponse if err = json.Unmarshal(message, &resp); err != nil { - log.Fatal(err) + logger.Logger.Fatal(err) } fmt.Print(resp.Payload.Data.Log.Log) } diff --git a/pkg/fileutil/files.go b/pkg/fileutil/files.go index 2075f1e11..3560c50af 100644 --- a/pkg/fileutil/files.go +++ b/pkg/fileutil/files.go @@ -16,9 +16,9 @@ import ( "strings" "time" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/util" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "github.com/spf13/afero" ) @@ -156,13 +156,13 @@ func Tar(source, target string, prependBaseDir bool, excludePathPrefixes []strin // ignore excluded paths for _, excludePathPrefix := range excludePathPrefixes { if strings.HasPrefix(headerName, excludePathPrefix) { - logrus.Debugf("Excluding tarball path: %s", headerName) + logger.Logger.Debugf("Excluding tarball path: %s", headerName) return nil } } header.Name = headerName - logrus.Debugf("Adding to tarball: %s", header.Name) + logger.Logger.Debugf("Adding to tarball: %s", header.Name) if err := tarball.WriteHeader(header); err != nil { return err diff --git a/pkg/httputil/http.go b/pkg/httputil/http.go index d7d78e9f1..f8a271c63 100644 --- a/pkg/httputil/http.go +++ b/pkg/httputil/http.go @@ -8,7 +8,7 @@ import ( "io" "net/http" - "github.com/sirupsen/logrus" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/fileutil" @@ -117,7 +117,7 @@ func (e *Error) Error() string { func DownloadResponseToFile(sourceURL, path string) { file, err := fileutil.CreateFile(path) if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } client := http.Client{ @@ -128,38 +128,38 @@ func DownloadResponseToFile(sourceURL, path string) { } resp, err := client.Get(sourceURL) //nolint if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } defer resp.Body.Close() err = fileutil.WriteToFile(path, resp.Body) if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } defer file.Close() - logrus.Infof("Downloaded %s from %s", path, sourceURL) + logger.Logger.Infof("Downloaded %s from %s", path, sourceURL) } func RequestAndGetJSONBody(route string) map[string]interface{} { res, err := http.Get(route) //nolint if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } defer res.Body.Close() body, err := io.ReadAll(res.Body) if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } if res.StatusCode > LastSuccessfulHTTPResponseCode { - logrus.Fatalf("Response failed with status code: %d and\nbody: %s\n", res.StatusCode, body) + logger.Logger.Fatalf("Response failed with status code: %d and\nbody: %s\n", res.StatusCode, body) } var bodyJSON map[string]interface{} err = json.Unmarshal(body, &bodyJSON) if err != nil { - logrus.Fatal(err) + logger.Logger.Fatal(err) } - logrus.Debugf("%s - GET %s %s", res.Status, route, string(body)) + logger.Logger.Debugf("%s - GET %s %s", res.Status, route, string(body)) return bodyJSON } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go new file mode 100644 index 000000000..19742a5fa --- /dev/null +++ b/pkg/logger/logger.go @@ -0,0 +1,5 @@ +package logger + +import "github.com/sirupsen/logrus" + +var Logger = logrus.New() diff --git a/settings/settings.go b/settings/settings.go index 88668c1dc..d59edec41 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -14,8 +14,8 @@ import ( astrocore "github.com/astronomer/astro-cli/astro-client-core" "github.com/astronomer/astro-cli/docker" "github.com/astronomer/astro-cli/pkg/fileutil" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "github.com/spf13/viper" ) @@ -124,7 +124,7 @@ func AddVariables(id string, version uint64) { airflowCommand += fmt.Sprintf("'%s'", variable.VariableValue) out := execAirflowCommand(id, airflowCommand) - logrus.Debugf("Adding variable logs:\n%s", out) + logger.Logger.Debugf("Adding variable logs:\n%s", out) fmt.Printf("Added Variable: %s\n", variable.VariableName) } } @@ -226,7 +226,7 @@ func AddConnections(id string, version uint64, envConns map[string]astrocore.Env } out := execAirflowCommand(id, airflowCommand) - logrus.Debugf("Adding Connection logs:\n\n%s", out) + logger.Logger.Debugf("Adding Connection logs:\n\n%s", out) fmt.Printf("Added Connection: %s\n", conn.ConnID) } } @@ -295,7 +295,7 @@ func AddPools(id string, version uint64) { } fmt.Println(airflowCommand) out := execAirflowCommand(id, airflowCommand) - logrus.Debugf("Adding pool logs:\n%s", out) + logger.Logger.Debugf("Adding pool logs:\n%s", out) fmt.Printf("Added Pool: %s\n", pool.PoolName) } else { fmt.Printf("Skipping %s: Pool Slot must be set.\n", pool.PoolName) @@ -348,7 +348,7 @@ func EnvExport(id, envFile string, version uint64, connections, variables bool) func EnvExportVariables(id, envFile string) error { // setup airflow command to export variables out := execAirflowCommand(id, airflowVarExport) - logrus.Debugf("Env Export Variables logs:\n\n%s", out) + logger.Logger.Debugf("Env Export Variables logs:\n\n%s", out) if strings.Contains(out, "successfully") { // get variables from file created by airflow command @@ -384,7 +384,7 @@ func EnvExportVariables(id, envFile string) error { func EnvExportConnections(id, envFile string) error { // Airflow command to export connections to env uris out := execAirflowCommand(id, airflowConnExport) - logrus.Debugf("Env Export Connections logs:\n%s", out) + logger.Logger.Debugf("Env Export Connections logs:\n%s", out) if strings.Contains(out, "successfully") { // get connections from file craeted by airflow command @@ -461,7 +461,7 @@ func Export(id, settingsFile string, version uint64, connections, variables, poo func ExportConnections(id string) error { // Setup airflow command to export connections out := execAirflowCommand(id, airflowConnectionList) - logrus.Debugf("Export Connections logs:\n%s", out) + logger.Logger.Debugf("Export Connections logs:\n%s", out) // remove all color from output of the airflow command plainOut := re.ReplaceAllString(out, "") // remove extra warning text @@ -518,7 +518,7 @@ func ExportConnections(id string) error { func ExportVariables(id string) error { // setup files out := execAirflowCommand(id, airflowVarExport) - logrus.Debugf("Export Variables logs:\n%s", out) + logger.Logger.Debugf("Export Variables logs:\n%s", out) if strings.Contains(out, "successfully") { // get variables created by the airflow command @@ -561,7 +561,7 @@ func ExportPools(id string) error { // Setup airflow command to export pools airflowCommand := ariflowPoolsList out := execAirflowCommand(id, airflowCommand) - logrus.Debugf("Export Pools logs:\n%s", out) + logger.Logger.Debugf("Export Pools logs:\n%s", out) // remove all color from output of the airflow command plainOut := re.ReplaceAllString(out, "") diff --git a/software/auth/auth.go b/software/auth/auth.go index 50e18fe38..07ab12e96 100644 --- a/software/auth/auth.go +++ b/software/auth/auth.go @@ -11,9 +11,8 @@ import ( "github.com/astronomer/astro-cli/context" "github.com/astronomer/astro-cli/houston" "github.com/astronomer/astro-cli/pkg/input" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/software/workspace" - - log "github.com/sirupsen/logrus" ) const ( @@ -56,19 +55,19 @@ func basicAuth(username, password string, ctx *config.Context, client houston.Cl var switchToLastUsedWorkspace = func(client houston.ClientInterface, c *config.Context) bool { if c.LastUsedWorkspace == "" { - log.Debug("last used workspace was empty") + logger.Logger.Debug("last used workspace was empty") return false } // validate workspace workspace, err := client.ValidateWorkspaceID(c.LastUsedWorkspace) if err != nil || workspace != nil && workspace.ID != c.LastUsedWorkspace { - log.Debugf("last used workspace id is not valid: %s", err.Error()) + logger.Logger.Debugf("last used workspace id is not valid: %s", err.Error()) return false } if err := c.SetContextKey("workspace", workspace.ID); err != nil { - log.Debugf("unable to set workspace context: %s", err.Error()) + logger.Logger.Debugf("unable to set workspace context: %s", err.Error()) return false } @@ -237,7 +236,7 @@ func Login(domain string, oAuthOnly bool, username, password, houstonVersion str err = registryAuth(client, out) if err != nil { - log.Debugf("There was an error logging into registry: %s", err.Error()) + logger.Logger.Debugf("There was an error logging into registry: %s", err.Error()) } return nil diff --git a/software/deployment/deployment.go b/software/deployment/deployment.go index 61029837f..fbf6e31d7 100644 --- a/software/deployment/deployment.go +++ b/software/deployment/deployment.go @@ -11,6 +11,7 @@ import ( "strings" "github.com/astronomer/astro-cli/pkg/ansi" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/houston" "github.com/astronomer/astro-cli/pkg/input" @@ -19,7 +20,6 @@ import ( semver "github.com/Masterminds/semver/v3" "github.com/fatih/camelcase" - "github.com/sirupsen/logrus" giturls "github.com/whilp/git-urls" ) @@ -85,7 +85,7 @@ func newTableOut() *printutil.Table { } func checkManualReleaseNames(client houston.ClientInterface) bool { - logrus.Debug("Checking checkManualReleaseNames through appConfig from houston-api") + logger.Logger.Debug("Checking checkManualReleaseNames through appConfig from houston-api") config, err := houston.Call(client.GetAppConfig)(nil) if err != nil { @@ -97,7 +97,7 @@ func checkManualReleaseNames(client houston.ClientInterface) bool { // CheckNFSMountDagDeployment returns true when we can set custom NFS location for dags func CheckNFSMountDagDeployment(client houston.ClientInterface) bool { - logrus.Debug("Checking checkNFSMountDagDeployment through appConfig from houston-api") + logger.Logger.Debug("Checking checkNFSMountDagDeployment through appConfig from houston-api") config, err := houston.Call(client.GetAppConfig)(nil) if err != nil { @@ -108,7 +108,7 @@ func CheckNFSMountDagDeployment(client houston.ClientInterface) bool { } func CheckHardDeleteDeployment(client houston.ClientInterface) bool { - logrus.Debug("Checking for hard delete deployment flag") + logger.Logger.Debug("Checking for hard delete deployment flag") config, err := houston.Call(client.GetAppConfig)(nil) if err != nil { return false @@ -117,7 +117,7 @@ func CheckHardDeleteDeployment(client houston.ClientInterface) bool { } func CheckPreCreateNamespaceDeployment(client houston.ClientInterface) bool { - logrus.Debug("Checking for pre created deployment flag") + logger.Logger.Debug("Checking for pre created deployment flag") config, err := houston.Call(client.GetAppConfig)(nil) if err != nil { return false @@ -134,7 +134,7 @@ func CheckNamespaceFreeFormEntryDeployment(client houston.ClientInterface) bool } func CheckTriggererEnabled(client houston.ClientInterface) bool { - logrus.Debug("Checking for triggerer flag") + logger.Logger.Debug("Checking for triggerer flag") config, err := houston.Call(client.GetAppConfig)(nil) if err != nil { return false @@ -252,7 +252,7 @@ func getDeploymentSelectionNamespaces(client houston.ClientInterface, out io.Wri Header: []string{"AVAILABLE KUBERNETES NAMESPACES"}, } - logrus.Debug("checking namespaces available for platform") + logger.Logger.Debug("checking namespaces available for platform") tab.GetUserInput = true names, err := houston.Call(client.GetAvailableNamespaces)(nil) diff --git a/software/teams/teams.go b/software/teams/teams.go index 69838f751..d24245fa2 100644 --- a/software/teams/teams.go +++ b/software/teams/teams.go @@ -6,11 +6,11 @@ import ( "io" "github.com/astronomer/astro-cli/houston" + "github.com/astronomer/astro-cli/pkg/logger" "github.com/astronomer/astro-cli/pkg/printutil" "github.com/astronomer/astro-cli/software/deployment" "github.com/astronomer/astro-cli/software/utils" "github.com/astronomer/astro-cli/software/workspace" - "github.com/sirupsen/logrus" ) const ListTeamLimit = 20 @@ -70,7 +70,7 @@ func Get(teamID string, getUserInfo, getRoleInfo, allFilters bool, client housto } if getUserInfo || allFilters { - logrus.Debug("retrieving users part of team") + logger.Logger.Debug("retrieving users part of team") fmt.Fprintln(out, "\nUsers part of Team:") users, err := houston.Call(client.GetTeamUsers)(teamID) if err != nil {