From 276a565fa9478dccb9d5e3420dd4840efb81492b Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Wed, 11 Dec 2024 21:51:14 +0600 Subject: [PATCH 01/19] DEV-2815 --- atmos.yaml | 6 +++ cmd/cmd_utils.go | 60 ++++++++++++++++++++---- cmd/helmfile.go | 15 +----- cmd/root.go | 30 ++++++------ cmd/terraform.go | 15 ++---- go.mod | 1 + go.sum | 2 + pkg/config/cache.go | 108 +++++++++++++++++++++++++++++++++++++++++++ pkg/config/config.go | 7 +++ pkg/config/utils.go | 12 +++++ pkg/schema/schema.go | 11 +++++ 11 files changed, 219 insertions(+), 48 deletions(-) create mode 100644 pkg/config/cache.go diff --git a/atmos.yaml b/atmos.yaml index adfd5176b..de362387b 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -315,3 +315,9 @@ settings: # If the source and destination lists have the same length, all items in the destination lists are # deep-merged with all items in the source list. list_merge_strategy: replace + +version: + check: + enabled: true + timeout: 1000 # ms + frequency: daily diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 3d55bf630..a962f4d17 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -7,6 +7,7 @@ import ( "os" "path" "strings" + "time" "github.com/fatih/color" "github.com/spf13/cobra" @@ -428,20 +429,61 @@ func printMessageForMissingAtmosConfig(cliConfig schema.CliConfiguration) { u.PrintMessage("https://atmos.tools/quick-start\n") } -// customHelpMessageToUpgradeToAtmosLatestRelease adds Atmos version info at the end of each help commnad -func customHelpMessageToUpgradeToAtmosLatestRelease(cmd *cobra.Command, args []string) { - originalHelpFunc(cmd, args) - // Check for the latest Atmos release on GitHub +// CheckForAtmosUpdateAndPrintMessage checks if a version update is needed and prints a message if a newer version is found. +// It loads the cache, decides if it's time to check for updates, compares the current version to the latest available release, +// and if newer, prints the update message. It also updates the cache's timestamp after printing. +func CheckForAtmosUpdateAndPrintMessage(cliConfig schema.CliConfiguration) { + // If version checking is disabled in the configuration, do nothing + if !cliConfig.Version.Check.Enabled { + return + } + + // Load the cache + cacheCfg, err := cfg.LoadCache() + if err != nil { + u.LogWarning(cliConfig, fmt.Sprintf("Could not load cache: %s", err)) + return + } + + // Determine if it's time to check for updates based on frequency and last_checked + if !cfg.ShouldCheckForUpdates(cacheCfg.LastChecked, cliConfig.Version.Check.Frequency) { + // Not due for another check yet, so return without printing anything + return + } + + // Get the latest Atmos release from GitHub latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") - if err == nil && latestReleaseTag != "" { - latestRelease := strings.TrimPrefix(latestReleaseTag, "v") - currentRelease := strings.TrimPrefix(version.Version, "v") - if latestRelease != currentRelease { - u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease) + if err != nil { + u.LogTrace(cliConfig, fmt.Sprintf("Failed to retrieve latest Atmos release info: %s", err)) + return + } + + if latestReleaseTag == "" { + // No releases found or empty string, return silently + return + } + + // Trim "v" prefix to compare versions + latestVersion := strings.TrimPrefix(latestReleaseTag, "v") + currentVersion := strings.TrimPrefix(version.Version, "v") + + // If the versions differ, print the update message + if latestVersion != currentVersion { + u.PrintMessageToUpgradeToAtmosLatestRelease(latestVersion) + + // Update the cache to mark the current timestamp + cacheCfg.LastChecked = time.Now().Unix() + if saveErr := cfg.SaveCache(cacheCfg); saveErr != nil { + u.LogWarning(cliConfig, fmt.Sprintf("Unable to save cache: %s", saveErr)) } } } +func customHelpMessageToUpgradeToAtmosLatestRelease(cmd *cobra.Command, args []string) { + originalHelpFunc(cmd, args) + CheckForAtmosUpdateAndPrintMessage(cliConfig) +} + // Check Atmos is version command func isVersionCommand() bool { return len(os.Args) > 1 && os.Args[1] == "version" diff --git a/cmd/helmfile.go b/cmd/helmfile.go index ae7280fe7..d2236e835 100644 --- a/cmd/helmfile.go +++ b/cmd/helmfile.go @@ -1,15 +1,12 @@ package cmd import ( - "strings" - "github.com/samber/lo" "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" - "github.com/cloudposse/atmos/pkg/version" ) // helmfileCmd represents the base command for all helmfile sub-commands @@ -34,18 +31,10 @@ var helmfileCmd = &cobra.Command{ if err != nil { u.LogErrorAndExit(schema.CliConfiguration{}, err) } - - // Check for the latest Atmos release on GitHub and print update message - latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") - if err == nil && latestReleaseTag != "" { - latestRelease := strings.TrimPrefix(latestReleaseTag, "v") - currentRelease := strings.TrimPrefix(version.Version, "v") - if latestRelease != currentRelease { - u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease) - } - } // Exit on help if info.NeedHelp { + // Check for the latest Atmos release on GitHub and print update message + CheckForAtmosUpdateAndPrintMessage(cliConfig) return } // Check Atmos configuration diff --git a/cmd/root.go b/cmd/root.go index 0027776c1..c7b043a3f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -18,6 +18,8 @@ import ( u "github.com/cloudposse/atmos/pkg/utils" ) +var cliConfig schema.CliConfiguration + // originalHelpFunc holds Cobra's original help function to avoid recursion. var originalHelpFunc func(*cobra.Command, []string) @@ -72,14 +74,6 @@ func Execute() error { Flags: cc.Bold, }) - // Save the original help function to prevent infinite recursion when overriding it. - // This allows us to call the original help functionality within our custom help function. - originalHelpFunc = RootCmd.HelpFunc() - - // Override the help function with a custom one that adds an upgrade message after displaying help. - // This custom help function will call the original help function and then display the bordered message. - RootCmd.SetHelpFunc(customHelpMessageToUpgradeToAtmosLatestRelease) - // Check if the `help` flag is passed and print a styled Atmos logo to the terminal before printing the help err := RootCmd.ParseFlags(os.Args) if err != nil && errors.Is(err, pflag.ErrHelp) { @@ -89,21 +83,29 @@ func Execute() error { u.LogErrorAndExit(schema.CliConfiguration{}, err) } } - // InitCliConfig finds and merges CLI configurations in the following order: // system dir, home dir, current dir, ENV vars, command-line arguments // Here we need the custom commands from the config - cliConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false) - if err != nil && !errors.Is(err, cfg.NotFound) { + var initErr error + cliConfig, initErr = cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false) + if initErr != nil && !errors.Is(initErr, cfg.NotFound) { if isVersionCommand() { - u.LogTrace(schema.CliConfiguration{}, fmt.Sprintf("warning: CLI configuration 'atmos.yaml' file not found. Error: %s", err)) + u.LogTrace(schema.CliConfiguration{}, fmt.Sprintf("warning: CLI configuration 'atmos.yaml' file not found. Error: %s", initErr)) } else { - u.LogErrorAndExit(schema.CliConfiguration{}, err) + u.LogErrorAndExit(schema.CliConfiguration{}, initErr) } } + // Save the original help function to prevent infinite recursion when overriding it. + // This allows us to call the original help functionality within our custom help function. + originalHelpFunc = RootCmd.HelpFunc() + + // Override the help function with a custom one that adds an upgrade message after displaying help. + // This custom help function will call the original help function and then display the bordered message. + RootCmd.SetHelpFunc(customHelpMessageToUpgradeToAtmosLatestRelease) + // If CLI configuration was found, process its custom commands and command aliases - if err == nil { + if initErr == nil { err = processCustomCommands(cliConfig, cliConfig.Commands, RootCmd, true) if err != nil { u.LogErrorAndExit(schema.CliConfiguration{}, err) diff --git a/cmd/terraform.go b/cmd/terraform.go index 3b5ec3783..586e79d22 100644 --- a/cmd/terraform.go +++ b/cmd/terraform.go @@ -1,15 +1,12 @@ package cmd import ( - "strings" - "github.com/samber/lo" "github.com/spf13/cobra" e "github.com/cloudposse/atmos/internal/exec" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" - "github.com/cloudposse/atmos/pkg/version" ) // terraformCmd represents the base command for all terraform sub-commands @@ -35,17 +32,11 @@ var terraformCmd = &cobra.Command{ if err != nil { u.LogErrorAndExit(schema.CliConfiguration{}, err) } - // Check for the latest Atmos release on GitHub and print update message - latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") - if err == nil && latestReleaseTag != "" { - latestRelease := strings.TrimPrefix(latestReleaseTag, "v") - currentRelease := strings.TrimPrefix(version.Version, "v") - if latestRelease != currentRelease { - u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease) - } - } + // Exit on help if info.NeedHelp { + // Check for the latest Atmos release on GitHub and print update message + CheckForAtmosUpdateAndPrintMessage(cliConfig) return } // Check Atmos configuration diff --git a/go.mod b/go.mod index ef51bcbdf..1c01ef148 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/elewis787/boa v0.1.2 github.com/fatih/color v1.18.0 github.com/go-git/go-git/v5 v5.12.0 + github.com/gofrs/flock v0.12.1 github.com/google/go-containerregistry v0.20.2 github.com/google/go-github/v59 v59.0.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index f557e9bc6..90b091ecb 100644 --- a/go.sum +++ b/go.sum @@ -584,6 +584,8 @@ github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22 github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/pkg/config/cache.go b/pkg/config/cache.go new file mode 100644 index 000000000..0c0ffc02f --- /dev/null +++ b/pkg/config/cache.go @@ -0,0 +1,108 @@ +package config + +import ( + "os" + "path/filepath" + "time" + + "github.com/gofrs/flock" + "github.com/pkg/errors" + "github.com/spf13/viper" +) + +type CacheConfig struct { + LastChecked int64 `mapstructure:"last_checked"` +} + +func GetCacheFilePath() (string, error) { + xdgCacheHome := os.Getenv("XDG_CACHE_HOME") + var cacheDir string + if xdgCacheHome == "" { + cacheDir = filepath.Join(".", ".atmos") + } else { + cacheDir = filepath.Join(xdgCacheHome, "atmos") + } + + if err := os.MkdirAll(cacheDir, 0755); err != nil { + return "", errors.Wrap(err, "error creating cache directory") + } + + return filepath.Join(cacheDir, "cache.yaml"), nil +} + +func withCacheFileLock(cacheFile string, fn func() error) error { + lock := flock.New(cacheFile) + err := lock.Lock() + if err != nil { + return errors.Wrap(err, "error acquiring file lock") + } + defer lock.Unlock() + return fn() +} + +func LoadCache() (CacheConfig, error) { + cacheFile, err := GetCacheFilePath() + if err != nil { + return CacheConfig{}, err + } + + var cfg CacheConfig + if _, err := os.Stat(cacheFile); os.IsNotExist(err) { + // No file yet, return default + return cfg, nil + } + + v := viper.New() + v.SetConfigFile(cacheFile) + if err := v.ReadInConfig(); err != nil { + return cfg, errors.Wrap(err, "failed to read cache file") + } + if err := v.Unmarshal(&cfg); err != nil { + return cfg, errors.Wrap(err, "failed to unmarshal cache file") + } + return cfg, nil +} + +func SaveCache2(cfg CacheConfig) error { + cacheFile, err := GetCacheFilePath() + if err != nil { + return err + } + + return withCacheFileLock(cacheFile, func() error { + v := viper.New() + v.Set("last_checked", cfg.LastChecked) + if err := v.WriteConfigAs(cacheFile); err != nil { + return errors.Wrap(err, "failed to write cache file") + } + return nil + }) +} + +func SaveCache(cfg CacheConfig) error { + cacheFile, err := GetCacheFilePath() + if err != nil { + return err + } + + v := viper.New() + v.Set("last_checked", cfg.LastChecked) + if err := v.WriteConfigAs(cacheFile); err != nil { + return errors.Wrap(err, "failed to write cache file") + } + return nil +} + +func ShouldCheckForUpdates(lastChecked int64, frequency string) bool { + now := time.Now().Unix() + var interval int64 + switch frequency { + case "daily": + interval = 86400 + case "weekly": + interval = 604800 + default: + interval = 86400 // default daily + } + return now-lastChecked >= interval +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 8cbfb8c36..a0a1f0167 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -82,6 +82,13 @@ var ( }, }, Initialized: true, + Version: schema.Version{ + Check: schema.VersionCheck{ + Enabled: true, + Timeout: 1000, + Frequency: "daily", + }, + }, } ) diff --git a/pkg/config/utils.go b/pkg/config/utils.go index 929243c3f..bf4404e5a 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -371,6 +371,18 @@ func processEnvVars(cliConfig *schema.CliConfiguration) error { cliConfig.Settings.ListMergeStrategy = listMergeStrategy } + versionEnabled := os.Getenv("ATMOS_VERSION_CHECK_ENABLED") + if len(versionEnabled) > 0 { + u.LogTrace(*cliConfig, fmt.Sprintf("Found ENV var ATMOS_VERSION_CHECK_ENABLED=%s", versionEnabled)) + enabled, err := strconv.ParseBool(versionEnabled) + if err != nil { + u.LogWarning(*cliConfig, fmt.Sprintf("Invalid boolean value '%s' for ATMOS_VERSION_CHECK_ENABLED; using default.", versionEnabled)) + } else { + cliConfig.Version.Check.Enabled = enabled + } + cliConfig.Version.Check.Enabled = enabled + } + return nil } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index ff05ed6dc..e44396a38 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -26,6 +26,7 @@ type CliConfiguration struct { StackConfigFilesAbsolutePaths []string `yaml:"stackConfigFilesAbsolutePaths,omitempty" json:"stackConfigFilesAbsolutePaths,omitempty" mapstructure:"stackConfigFilesAbsolutePaths"` StackType string `yaml:"stackType,omitempty" json:"StackType,omitempty" mapstructure:"stackType"` Default bool `yaml:"default" json:"default" mapstructure:"default"` + Version Version `yaml:"version,omitempty" json:"version,omitempty" mapstructure:"version"` } type CliSettings struct { @@ -128,6 +129,16 @@ type Context struct { TerraformWorkspace string `yaml:"terraform_workspace" json:"terraform_workspace" mapstructure:"terraform_workspace"` } +type VersionCheck struct { + Enabled bool `yaml:"enabled,omitempty" mapstructure:"enabled"` + Timeout int `yaml:"timeout,omitempty" mapstructure:"timeout"` + Frequency string `yaml:"frequency,omitempty" mapstructure:"frequency"` +} + +type Version struct { + Check VersionCheck `yaml:"check,omitempty" mapstructure:"check"` +} + type ArgsAndFlagsInfo struct { AdditionalArgsAndFlags []string SubCommand string From efdf9212eb1f46cb5b75ac590a3395d9015fa469 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Fri, 13 Dec 2024 20:22:49 +0600 Subject: [PATCH 02/19] version --- cmd/cmd_utils.go | 11 ++++++----- cmd/version.go | 23 ++++++++++++++++------- pkg/config/utils.go | 1 - 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index a962f4d17..41a3246d8 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -470,12 +470,13 @@ func CheckForAtmosUpdateAndPrintMessage(cliConfig schema.CliConfiguration) { // If the versions differ, print the update message if latestVersion != currentVersion { u.PrintMessageToUpgradeToAtmosLatestRelease(latestVersion) + } + + // Update the cache to mark the current timestamp + cacheCfg.LastChecked = time.Now().Unix() + if saveErr := cfg.SaveCache(cacheCfg); saveErr != nil { + u.LogWarning(cliConfig, fmt.Sprintf("Unable to save cache: %s", saveErr)) - // Update the cache to mark the current timestamp - cacheCfg.LastChecked = time.Now().Unix() - if saveErr := cfg.SaveCache(cacheCfg); saveErr != nil { - u.LogWarning(cliConfig, fmt.Sprintf("Unable to save cache: %s", saveErr)) - } } } diff --git a/cmd/version.go b/cmd/version.go index 5146f4ff3..9b11e207a 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -13,6 +13,8 @@ import ( "github.com/cloudposse/atmos/pkg/version" ) +var checkFlag bool + var versionCmd = &cobra.Command{ Use: "version", Short: "Print the CLI version", @@ -29,18 +31,25 @@ var versionCmd = &cobra.Command{ u.PrintMessage(fmt.Sprintf("\U0001F47D Atmos %s on %s/%s", version.Version, runtime.GOOS, runtime.GOARCH)) fmt.Println() - // Check for the latest Atmos release on GitHub - latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") - if err == nil && latestReleaseTag != "" { - latestRelease := strings.TrimPrefix(latestReleaseTag, "v") - currentRelease := strings.TrimPrefix(version.Version, "v") - if latestRelease != currentRelease { - u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease) + if checkFlag { + // Check for the latest Atmos release on GitHub + latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") + if err == nil && latestReleaseTag != "" { + latestRelease := strings.TrimPrefix(latestReleaseTag, "v") + currentRelease := strings.TrimPrefix(version.Version, "v") + if latestRelease != currentRelease { + u.PrintMessageToUpgradeToAtmosLatestRelease(latestRelease) + } } + return } + + // Check for the cache and print update message + CheckForAtmosUpdateAndPrintMessage(cliConfig) }, } func init() { + versionCmd.Flags().BoolVarP(&checkFlag, "check", "c", false, "Run additional checks after displaying version info") RootCmd.AddCommand(versionCmd) } diff --git a/pkg/config/utils.go b/pkg/config/utils.go index bf4404e5a..060a1cf2a 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -380,7 +380,6 @@ func processEnvVars(cliConfig *schema.CliConfiguration) error { } else { cliConfig.Version.Check.Enabled = enabled } - cliConfig.Version.Check.Enabled = enabled } return nil From 88c6f9058000cc25444d99a2de59af1c31ad0a50 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Fri, 13 Dec 2024 21:40:28 +0600 Subject: [PATCH 03/19] docs update --- website/docs/cli/commands/help.mdx | 7 +++++++ website/docs/cli/commands/version.mdx | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index fcbc1c2e3..d9df1ec6e 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -12,6 +12,13 @@ import Terminal from '@site/src/components/Terminal' ## Usage The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. +Please note that an atmos upgrage version box is shown at the end of each help command. +The frequency with which the update box message is shown is configured in atmos.yaml. +There are two options daily and weekly. The default value is set to daily. +It is also possible to turn it off in atmos.yaml file by switching enable to false. +Or set an env variable ATMOS_VERSION_CHECK_ENABLED to false, +this overriders the config's settting. + ```shell atmos help diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index a8aabaf56..0c786c7d3 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -20,7 +20,19 @@ Execute the `atmos version` command like this: atmos version ``` -This will show the CLI version. +This will show the CLI version. +The frequency with which the update box message in version is shown is configured in atmos.yaml. +There are two options daily and weekly. The default value is set to daily. +It is also possible to turn it off in atmos.yaml file by switching enable to false. +Or set an env variable ATMOS_VERSION_CHECK_ENABLED to false, +this overriders the config's settting. + +```shell +atmos version --check +``` + +The version command supports --check flag. +It will show the update box message irrespectively of the config settings. :::tip To find the latest version of Atmos, go to the [releases](https://github.com/cloudposse/atmos/releases) page on GitHub. From 1afaece3551de59d8bdcc3cd1de07d5e304ad125 Mon Sep 17 00:00:00 2001 From: "Erik Osterman (CEO @ Cloud Posse)" Date: Fri, 13 Dec 2024 09:49:52 -0600 Subject: [PATCH 04/19] Update website/docs/cli/commands/help.mdx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- website/docs/cli/commands/help.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index d9df1ec6e..3ce881118 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -12,12 +12,12 @@ import Terminal from '@site/src/components/Terminal' ## Usage The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. -Please note that an atmos upgrage version box is shown at the end of each help command. -The frequency with which the update box message is shown is configured in atmos.yaml. -There are two options daily and weekly. The default value is set to daily. -It is also possible to turn it off in atmos.yaml file by switching enable to false. -Or set an env variable ATMOS_VERSION_CHECK_ENABLED to false, -this overriders the config's settting. +Please note that an Atmos upgrade version box is shown at the end of each help command. +The frequency of the update box message is configured in the atmos.yaml file. +There are two options: daily and weekly. The default value is set to daily. +You can disable this feature in the atmos.yaml file by setting `enable: false`, +or by setting the environment variable `ATMOS_VERSION_CHECK_ENABLED=false`, +which overrides the config's setting. ```shell From 43b503fbf3e856fef83d6ada8869822de78b87d3 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:03:05 +0600 Subject: [PATCH 05/19] Update website/docs/cli/commands/version.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/version.mdx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 0c786c7d3..ce33b085d 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -21,11 +21,10 @@ atmos version ``` This will show the CLI version. -The frequency with which the update box message in version is shown is configured in atmos.yaml. -There are two options daily and weekly. The default value is set to daily. -It is also possible to turn it off in atmos.yaml file by switching enable to false. -Or set an env variable ATMOS_VERSION_CHECK_ENABLED to false, -this overriders the config's settting. + +From time to time, Atmos will check for updates. The frequency is configured in the `atmos.yaml`. There are two options `daily` and `weekly`. The default is to check `daily`, and if any unsupported values are passed this default will be used. + +It is also possible to turn off version checks in `atmos.yaml` by switching `enable` to `false`, or by setting the `ATMOS_VERSION_CHECK_ENABLED` environment variable to `false`, which overriders the config's settings. ```shell atmos version --check From 1d64764c2e70754f5daeaa107e527b0a023a7d34 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:03:27 +0600 Subject: [PATCH 06/19] Update pkg/config/cache.go Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- pkg/config/cache.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/config/cache.go b/pkg/config/cache.go index 0c0ffc02f..944ce917c 100644 --- a/pkg/config/cache.go +++ b/pkg/config/cache.go @@ -97,12 +97,21 @@ func ShouldCheckForUpdates(lastChecked int64, frequency string) bool { now := time.Now().Unix() var interval int64 switch frequency { - case "daily": - interval = 86400 - case "weekly": - interval = 604800 - default: - interval = 86400 // default daily + case "minute": + interval = 60 // 1 minute + case "hourly": + interval = 3600 // 1 hour + case "daily": + interval = 86400 // 1 day + case "weekly": + interval = 604800 // 1 week + case "monthly": + interval = 2592000 // 30 days (approximate) + case "yearly": + interval = 31536000 // 365 days + default: + interval = 86400 // default to daily + } } return now-lastChecked >= interval } From bc0974c6dff239033454e1e3dc25dba7ff2be784 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:07:52 +0600 Subject: [PATCH 07/19] Update website/docs/cli/commands/version.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/version.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index ce33b085d..7b5bd2de6 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -31,7 +31,7 @@ atmos version --check ``` The version command supports --check flag. -It will show the update box message irrespectively of the config settings. +It will force atmos to check for a new version, irrespective of the configuration settings. :::tip To find the latest version of Atmos, go to the [releases](https://github.com/cloudposse/atmos/releases) page on GitHub. From aa0800449890aa44b0e573c78fb6117a1bd6b820 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:08:10 +0600 Subject: [PATCH 08/19] Update website/docs/cli/commands/version.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/version.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 7b5bd2de6..60d26c9bd 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -30,7 +30,7 @@ It is also possible to turn off version checks in `atmos.yaml` by switching `ena atmos version --check ``` -The version command supports --check flag. +The version command supports a `--check` flag. It will force atmos to check for a new version, irrespective of the configuration settings. :::tip From a332af10db3d846d80ad211f2a494d33a75a3106 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Fri, 13 Dec 2024 21:57:36 +0600 Subject: [PATCH 09/19] help wording fix as per coderabbit suggestion --- pkg/config/cache.go | 29 ++++++++++++++--------------- website/docs/cli/commands/help.mdx | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pkg/config/cache.go b/pkg/config/cache.go index 944ce917c..3bb3a08d1 100644 --- a/pkg/config/cache.go +++ b/pkg/config/cache.go @@ -97,21 +97,20 @@ func ShouldCheckForUpdates(lastChecked int64, frequency string) bool { now := time.Now().Unix() var interval int64 switch frequency { - case "minute": - interval = 60 // 1 minute - case "hourly": - interval = 3600 // 1 hour - case "daily": - interval = 86400 // 1 day - case "weekly": - interval = 604800 // 1 week - case "monthly": - interval = 2592000 // 30 days (approximate) - case "yearly": - interval = 31536000 // 365 days - default: - interval = 86400 // default to daily - } + case "minute": + interval = 60 // 1 minute + case "hourly": + interval = 3600 // 1 hour + case "daily": + interval = 86400 // 1 day + case "weekly": + interval = 604800 // 1 week + case "monthly": + interval = 2592000 // 30 days (approximate) + case "yearly": + interval = 31536000 // 365 days + default: + interval = 86400 // default to daily } return now-lastChecked >= interval } diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index 3ce881118..f08cd4608 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -15,8 +15,8 @@ The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. Please note that an Atmos upgrade version box is shown at the end of each help command. The frequency of the update box message is configured in the atmos.yaml file. There are two options: daily and weekly. The default value is set to daily. -You can disable this feature in the atmos.yaml file by setting `enable: false`, -or by setting the environment variable `ATMOS_VERSION_CHECK_ENABLED=false`, +You can disable this feature in the atmos.yaml file by setting enable: false, +or by setting the environment variable ATMOS_VERSION_CHECK_ENABLED=false, which overrides the config's setting. From 85804aa511c2d528323619f798331d8b2e1a77f0 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Fri, 13 Dec 2024 22:41:32 +0600 Subject: [PATCH 10/19] more update frequencies and respective update to the dox --- pkg/config/cache.go | 4 ++++ website/docs/cli/commands/help.mdx | 3 ++- website/docs/cli/commands/version.mdx | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/config/cache.go b/pkg/config/cache.go index 3bb3a08d1..6776a0a71 100644 --- a/pkg/config/cache.go +++ b/pkg/config/cache.go @@ -1,10 +1,13 @@ package config import ( + "fmt" "os" "path/filepath" "time" + "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" "github.com/gofrs/flock" "github.com/pkg/errors" "github.com/spf13/viper" @@ -110,6 +113,7 @@ func ShouldCheckForUpdates(lastChecked int64, frequency string) bool { case "yearly": interval = 31536000 // 365 days default: + u.LogWarning(schema.CliConfiguration{}, fmt.Sprintf("Unexpected frequency '%s' encountered. Defaulting to daily.", frequency)) interval = 86400 // default to daily } return now-lastChecked >= interval diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index f08cd4608..519ec29cb 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -14,7 +14,8 @@ import Terminal from '@site/src/components/Terminal' The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. Please note that an Atmos upgrade version box is shown at the end of each help command. The frequency of the update box message is configured in the atmos.yaml file. -There are two options: daily and weekly. The default value is set to daily. +There are six frequency options: minute, hourly, daily, weekly, monthly, and yearly. +The default value is set to daily. You can disable this feature in the atmos.yaml file by setting enable: false, or by setting the environment variable ATMOS_VERSION_CHECK_ENABLED=false, which overrides the config's setting. diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 60d26c9bd..77d207f92 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -22,7 +22,7 @@ atmos version This will show the CLI version. -From time to time, Atmos will check for updates. The frequency is configured in the `atmos.yaml`. There are two options `daily` and `weekly`. The default is to check `daily`, and if any unsupported values are passed this default will be used. +From time to time, Atmos will check for updates. The frequency is configured in the `atmos.yaml`. There are six frequency options: minute, hourly, daily, weekly, monthly, and yearly. The default is to check `daily`, and if any unsupported values are passed this default will be used. It is also possible to turn off version checks in `atmos.yaml` by switching `enable` to `false`, or by setting the `ATMOS_VERSION_CHECK_ENABLED` environment variable to `false`, which overriders the config's settings. From 9da1a165211ce20b2bffaaf3b8c5ab91c412e9f0 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Sat, 14 Dec 2024 19:09:04 +0600 Subject: [PATCH 11/19] help wording update --- website/docs/cli/commands/help.mdx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index 519ec29cb..e556805f0 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -12,13 +12,8 @@ import Terminal from '@site/src/components/Terminal' ## Usage The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. -Please note that an Atmos upgrade version box is shown at the end of each help command. -The frequency of the update box message is configured in the atmos.yaml file. -There are six frequency options: minute, hourly, daily, weekly, monthly, and yearly. -The default value is set to daily. -You can disable this feature in the atmos.yaml file by setting enable: false, -or by setting the environment variable ATMOS_VERSION_CHECK_ENABLED=false, -which overrides the config's setting. +From time to time, Atmos will check for a newer release and let you know if one is available. +Please see the documentation for Atmos version to configure this behavior. ```shell From 595b08ff20cf9e086bd95f6812bdb0a1d7ec9bc6 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Sun, 15 Dec 2024 18:16:01 +0600 Subject: [PATCH 12/19] reviewchanges --- atmos.yaml | 2 +- cmd/cmd_utils.go | 4 +- cmd/version.go | 8 +++ pkg/config/cache.go | 65 +++++++++++++++---- website/docs/cli/commands/help.mdx | 3 +- website/docs/cli/commands/version.mdx | 15 ++++- .../docs/cli/configuration/configuration.mdx | 1 + 7 files changed, 80 insertions(+), 18 deletions(-) diff --git a/atmos.yaml b/atmos.yaml index de362387b..f0855f1c4 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -320,4 +320,4 @@ version: check: enabled: true timeout: 1000 # ms - frequency: daily + frequency: 3m diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 41a3246d8..149969cf6 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -454,12 +454,12 @@ func CheckForAtmosUpdateAndPrintMessage(cliConfig schema.CliConfiguration) { // Get the latest Atmos release from GitHub latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") if err != nil { - u.LogTrace(cliConfig, fmt.Sprintf("Failed to retrieve latest Atmos release info: %s", err)) + u.LogWarning(cliConfig, fmt.Sprintf("Failed to retrieve latest Atmos release info: %s", err)) return } if latestReleaseTag == "" { - // No releases found or empty string, return silently + u.LogWarning(cliConfig, "No release information available") return } diff --git a/cmd/version.go b/cmd/version.go index 9b11e207a..c865d81d0 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -35,6 +35,14 @@ var versionCmd = &cobra.Command{ // Check for the latest Atmos release on GitHub latestReleaseTag, err := u.GetLatestGitHubRepoRelease("cloudposse", "atmos") if err == nil && latestReleaseTag != "" { + if err != nil { + u.LogWarning(schema.CliConfiguration{}, fmt.Sprintf("Failed to check for updates: %v", err)) + return + } + if latestReleaseTag == "" { + u.LogWarning(schema.CliConfiguration{}, "No release information available") + return + } latestRelease := strings.TrimPrefix(latestReleaseTag, "v") currentRelease := strings.TrimPrefix(version.Version, "v") if latestRelease != currentRelease { diff --git a/pkg/config/cache.go b/pkg/config/cache.go index 6776a0a71..db401a865 100644 --- a/pkg/config/cache.go +++ b/pkg/config/cache.go @@ -4,6 +4,8 @@ import ( "fmt" "os" "path/filepath" + "strconv" + "strings" "time" "github.com/cloudposse/atmos/pkg/schema" @@ -98,23 +100,64 @@ func SaveCache(cfg CacheConfig) error { func ShouldCheckForUpdates(lastChecked int64, frequency string) bool { now := time.Now().Unix() - var interval int64 - switch frequency { + + interval, err := parseFrequency(frequency) + if err != nil { + // Log warning and default to daily if we can’t parse + u.LogWarning(schema.CliConfiguration{}, fmt.Sprintf("Unsupported frequency '%s' encountered. Defaulting to daily.", frequency)) + interval = 86400 // daily + } + return now-lastChecked >= interval +} + +// parseFrequency attempts to parse the frequency string in three ways: +// 1. As an integer (seconds) +// 2. As a duration with a suffix (e.g., "1h", "5m", "30s") +// 3. As one of the predefined keywords (daily, hourly, etc.) +func parseFrequency(frequency string) (int64, error) { + freq := strings.TrimSpace(frequency) + + if intVal, err := strconv.ParseInt(freq, 10, 64); err == nil { + if intVal > 0 { + return intVal, nil + } + } + + // Parse duration with suffix + if len(freq) > 1 { + unit := freq[len(freq)-1] + valPart := freq[:len(freq)-1] + if valInt, err := strconv.ParseInt(valPart, 10, 64); err == nil && valInt > 0 { + switch unit { + case 's': + return valInt, nil + case 'm': + return valInt * 60, nil + case 'h': + return valInt * 3600, nil + case 'd': + return valInt * 86400, nil + default: + return 0, fmt.Errorf("unrecognized duration unit: %s", string(unit)) + } + } + } + + // Handle predefined keywords + switch freq { case "minute": - interval = 60 // 1 minute + return 60, nil case "hourly": - interval = 3600 // 1 hour + return 3600, nil case "daily": - interval = 86400 // 1 day + return 86400, nil case "weekly": - interval = 604800 // 1 week + return 604800, nil case "monthly": - interval = 2592000 // 30 days (approximate) + return 2592000, nil case "yearly": - interval = 31536000 // 365 days + return 31536000, nil default: - u.LogWarning(schema.CliConfiguration{}, fmt.Sprintf("Unexpected frequency '%s' encountered. Defaulting to daily.", frequency)) - interval = 86400 // default to daily + return 0, fmt.Errorf("unrecognized frequency: %s", freq) } - return now-lastChecked >= interval } diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index e556805f0..c11646207 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -12,8 +12,9 @@ import Terminal from '@site/src/components/Terminal' ## Usage The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. + From time to time, Atmos will check for a newer release and let you know if one is available. -Please see the documentation for Atmos version to configure this behavior. +Please see the [Atmos version documentation](/cli/commands) to configure this behavior. ```shell diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 77d207f92..ea0fba4aa 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -22,16 +22,25 @@ atmos version This will show the CLI version. -From time to time, Atmos will check for updates. The frequency is configured in the `atmos.yaml`. There are six frequency options: minute, hourly, daily, weekly, monthly, and yearly. The default is to check `daily`, and if any unsupported values are passed this default will be used. +From time to time, Atmos will check for updates. The frequency of these checks is configured in the atmos.yaml file. -It is also possible to turn off version checks in `atmos.yaml` by switching `enable` to `false`, or by setting the `ATMOS_VERSION_CHECK_ENABLED` environment variable to `false`, which overriders the config's settings. +Atmos supports three ways to specify the update check frequency: + +1. As an integer: Specify the number of seconds between checks (for example, 3600 for hourly checks). +2. As a duration with a suffix: Use a time suffix to indicate the interval (for example, 1m for one minute, 5h for five hours, or 2d for two days). +3. As one of the predefined keywords: Choose from the following options: minute, hourly, daily, weekly, monthly, and yearly. The default is daily. +The default is to check `daily`, and if any unsupported values are passed this default will be used. + +It is also possible to turn off version checks in `atmos.yaml` by switching `enable` to `false`, +or by setting the `ATMOS_VERSION_CHECK_ENABLED` environment variable to `false`, which overrides +the config's settings. ```shell atmos version --check ``` The version command supports a `--check` flag. -It will force atmos to check for a new version, irrespective of the configuration settings. +This will force Atmos to check for a new version, irrespective of the configuration settings. :::tip To find the latest version of Atmos, go to the [releases](https://github.com/cloudposse/atmos/releases) page on GitHub. diff --git a/website/docs/cli/configuration/configuration.mdx b/website/docs/cli/configuration/configuration.mdx index 4e95a6850..6ee833528 100644 --- a/website/docs/cli/configuration/configuration.mdx +++ b/website/docs/cli/configuration/configuration.mdx @@ -652,6 +652,7 @@ setting `ATMOS_STACKS_BASE_PATH` to a path in `/localhost` to your local develop | ATMOS_LOGS_FILE | logs.file | The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including `/dev/stdout`, `/dev/stderr` and `/dev/null`). If omitted, `/dev/stdout` will be used | | ATMOS_LOGS_LEVEL | logs.level | Logs level. Supported log levels are `Trace`, `Debug`, `Info`, `Warning`, `Off`. If the log level is set to `Off`, Atmos will not log any messages (note that this does not prevent other tools like Terraform from logging) | | ATMOS_SETTINGS_LIST_MERGE_STRATEGY | settings.list_merge_strategy | Specifies how lists are merged in Atmos stack manifests. The following strategies are supported: `replace`, `append`, `merge` | +| ATMOS_VERSION_CHECK_ENABLED | version.check.enabled | Disables version checks for updates to the newest release | ### Context From 8291c5bbde70c2d0d9a45f70cf87a93aab203917 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Sun, 15 Dec 2024 18:38:10 +0600 Subject: [PATCH 13/19] versiondoc --- website/docs/cli/commands/help.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index c11646207..91e7b1b6f 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -14,7 +14,7 @@ import Terminal from '@site/src/components/Terminal' The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. From time to time, Atmos will check for a newer release and let you know if one is available. -Please see the [Atmos version documentation](/cli/commands) to configure this behavior. +Please see the [Atmos version documentation](/cli/commands/version) to configure this behavior. ```shell From 25cf475d78121bae403c828e254a4fdd2b9d6e5f Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Sun, 15 Dec 2024 22:05:15 +0600 Subject: [PATCH 14/19] Update website/docs/cli/commands/help.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/help.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/help.mdx b/website/docs/cli/commands/help.mdx index 91e7b1b6f..1df2ef3a1 100644 --- a/website/docs/cli/commands/help.mdx +++ b/website/docs/cli/commands/help.mdx @@ -14,7 +14,7 @@ import Terminal from '@site/src/components/Terminal' The `atmos --help` and `atmos -h` commands show help for all Atmos CLI commands. From time to time, Atmos will check for a newer release and let you know if one is available. -Please see the [Atmos version documentation](/cli/commands/version) to configure this behavior. +Please see the [`atmos version`](/cli/commands/version) documentation to configure this behavior. ```shell From b2e2a5db73237c7a2f9e2e9783303a87757e04f2 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Sun, 15 Dec 2024 22:05:56 +0600 Subject: [PATCH 15/19] Update website/docs/cli/commands/version.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/version.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index ea0fba4aa..73fbaf1ef 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -27,7 +27,7 @@ From time to time, Atmos will check for updates. The frequency of these checks i Atmos supports three ways to specify the update check frequency: 1. As an integer: Specify the number of seconds between checks (for example, 3600 for hourly checks). -2. As a duration with a suffix: Use a time suffix to indicate the interval (for example, 1m for one minute, 5h for five hours, or 2d for two days). +2. As a duration with a suffix: Use a time suffix to indicate the interval (for example, `1m` for one minute, `5h` for five hours, or `2d` for two days). 3. As one of the predefined keywords: Choose from the following options: minute, hourly, daily, weekly, monthly, and yearly. The default is daily. The default is to check `daily`, and if any unsupported values are passed this default will be used. From da2d692b132a4eeda3d94538c1d89c8ab00f1d99 Mon Sep 17 00:00:00 2001 From: Listener430 <95291462+Listener430@users.noreply.github.com> Date: Sun, 15 Dec 2024 22:06:21 +0600 Subject: [PATCH 16/19] Update website/docs/cli/commands/version.mdx Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- website/docs/cli/commands/version.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 73fbaf1ef..06829b274 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -22,7 +22,7 @@ atmos version This will show the CLI version. -From time to time, Atmos will check for updates. The frequency of these checks is configured in the atmos.yaml file. +From time to time, Atmos will check for updates. The frequency of these checks is configured in the `atmos.yaml` file. Atmos supports three ways to specify the update check frequency: From 6947afdc235db7d5be2ca68cd9a733fbeb077798 Mon Sep 17 00:00:00 2001 From: aknysh Date: Sun, 15 Dec 2024 11:42:59 -0500 Subject: [PATCH 17/19] updates --- .gitignore | 2 ++ atmos.yaml | 2 +- examples/quick-start-advanced/Dockerfile | 2 +- website/docs/integrations/atlantis.mdx | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f231eff31..7eeb05d79 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ # Nix .envrc .direnv/ + +.atmos/cache.yaml diff --git a/atmos.yaml b/atmos.yaml index f0855f1c4..b7fbef6f7 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -320,4 +320,4 @@ version: check: enabled: true timeout: 1000 # ms - frequency: 3m + frequency: hourly diff --git a/examples/quick-start-advanced/Dockerfile b/examples/quick-start-advanced/Dockerfile index 8ad376f7e..895f09c56 100644 --- a/examples/quick-start-advanced/Dockerfile +++ b/examples/quick-start-advanced/Dockerfile @@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian # https://atmos.tools/ # https://github.com/cloudposse/atmos # https://github.com/cloudposse/atmos/releases -ARG ATMOS_VERSION=1.122.0 +ARG ATMOS_VERSION=1.127.0 # Terraform: https://github.com/hashicorp/terraform/releases ARG TF_VERSION=1.5.7 diff --git a/website/docs/integrations/atlantis.mdx b/website/docs/integrations/atlantis.mdx index 842404516..e3a544497 100644 --- a/website/docs/integrations/atlantis.mdx +++ b/website/docs/integrations/atlantis.mdx @@ -673,7 +673,7 @@ on: branches: [ main ] env: - ATMOS_VERSION: 1.122.0 + ATMOS_VERSION: 1.127.0 ATMOS_CLI_CONFIG_PATH: ./ jobs: From 45aa14b6e55e5dcdb4c1092bc07b5c2901fa2741 Mon Sep 17 00:00:00 2001 From: Andrey Kalmykov Date: Sun, 15 Dec 2024 23:06:33 +0600 Subject: [PATCH 18/19] atmos.yaml --- atmos.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atmos.yaml b/atmos.yaml index b7fbef6f7..e9793b62f 100644 --- a/atmos.yaml +++ b/atmos.yaml @@ -320,4 +320,4 @@ version: check: enabled: true timeout: 1000 # ms - frequency: hourly + frequency: 1h From 61402aeb2807944f707b103ac668f50a4e06ac4b Mon Sep 17 00:00:00 2001 From: aknysh Date: Sun, 15 Dec 2024 12:14:15 -0500 Subject: [PATCH 19/19] updates --- pkg/config/cache.go | 5 +++-- website/docs/cli/commands/version.mdx | 4 ++-- website/docs/cli/configuration/configuration.mdx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/config/cache.go b/pkg/config/cache.go index db401a865..6833e67b5 100644 --- a/pkg/config/cache.go +++ b/pkg/config/cache.go @@ -8,11 +8,12 @@ import ( "strings" "time" - "github.com/cloudposse/atmos/pkg/schema" - u "github.com/cloudposse/atmos/pkg/utils" "github.com/gofrs/flock" "github.com/pkg/errors" "github.com/spf13/viper" + + "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" ) type CacheConfig struct { diff --git a/website/docs/cli/commands/version.mdx b/website/docs/cli/commands/version.mdx index 06829b274..2deb20a4f 100644 --- a/website/docs/cli/commands/version.mdx +++ b/website/docs/cli/commands/version.mdx @@ -31,9 +31,9 @@ Atmos supports three ways to specify the update check frequency: 3. As one of the predefined keywords: Choose from the following options: minute, hourly, daily, weekly, monthly, and yearly. The default is daily. The default is to check `daily`, and if any unsupported values are passed this default will be used. -It is also possible to turn off version checks in `atmos.yaml` by switching `enable` to `false`, +It is also possible to turn off version checks in `atmos.yaml` by setting `version.check.enabled` to `false`, or by setting the `ATMOS_VERSION_CHECK_ENABLED` environment variable to `false`, which overrides -the config's settings. +the `version.check.enabled` settings in `atmos.yaml`. ```shell atmos version --check diff --git a/website/docs/cli/configuration/configuration.mdx b/website/docs/cli/configuration/configuration.mdx index 6ee833528..9268c0cb3 100644 --- a/website/docs/cli/configuration/configuration.mdx +++ b/website/docs/cli/configuration/configuration.mdx @@ -652,7 +652,7 @@ setting `ATMOS_STACKS_BASE_PATH` to a path in `/localhost` to your local develop | ATMOS_LOGS_FILE | logs.file | The file to write Atmos logs to. Logs can be written to any file or any standard file descriptor, including `/dev/stdout`, `/dev/stderr` and `/dev/null`). If omitted, `/dev/stdout` will be used | | ATMOS_LOGS_LEVEL | logs.level | Logs level. Supported log levels are `Trace`, `Debug`, `Info`, `Warning`, `Off`. If the log level is set to `Off`, Atmos will not log any messages (note that this does not prevent other tools like Terraform from logging) | | ATMOS_SETTINGS_LIST_MERGE_STRATEGY | settings.list_merge_strategy | Specifies how lists are merged in Atmos stack manifests. The following strategies are supported: `replace`, `append`, `merge` | -| ATMOS_VERSION_CHECK_ENABLED | version.check.enabled | Disables version checks for updates to the newest release | +| ATMOS_VERSION_CHECK_ENABLED | version.check.enabled | Enable/disable Atmos version checks for updates to the newest release | ### Context