Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code by gofumpt #982

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ jobs:
path: |
./build/

fmt:
name: Check if code is formatted
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: aquaproj/[email protected]
with:
aqua_version: v2.43.0
- name: Install gofumpt
run: gofumpt -version
- name: Check if code is formatted
run: |
git ls-files | grep -E "\.go$" | xargs gofumpt -l -w
if ! git diff --quiet; then
echo "::error:: Code isn't formatted. Please format code using gofumpt"
exit 1
fi

tidy:
name: Tidy Go Modules
runs-on: ubuntu-latest
Expand Down
14 changes: 14 additions & 0 deletions aqua.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/aquaproj/aqua/main/json-schema/aqua-yaml.json
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v4.302.1 # renovate: depName=aquaproj/aqua-registry
packages:
- name: mvdan/[email protected]
14 changes: 6 additions & 8 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func processCustomCommands(
if _, exist := existingTopLevelCommands[commandConfig.Name]; exist && topLevel {
command = existingTopLevelCommands[commandConfig.Name]
} else {
var customCommand = &cobra.Command{
customCommand := &cobra.Command{
Use: commandConfig.Name,
Short: commandConfig.Description,
Long: commandConfig.Description,
Expand Down Expand Up @@ -132,7 +132,7 @@ func processCommandAliases(
aliasCmd := strings.TrimSpace(v)
aliasFor := fmt.Sprintf("alias for '%s'", aliasCmd)

var aliasCommand = &cobra.Command{
aliasCommand := &cobra.Command{
Use: alias,
Short: aliasFor,
Long: aliasFor,
Expand Down Expand Up @@ -170,7 +170,7 @@ func preCustomCommand(
) {
var sb strings.Builder

//checking for zero arguments in config
// checking for zero arguments in config
if len(commandConfig.Arguments) == 0 {
if len(commandConfig.Steps) > 0 {
// do nothing here; let the code proceed
Expand All @@ -193,7 +193,7 @@ func preCustomCommand(
}
}

//Check on many arguments required and have no default value
// Check on many arguments required and have no default value
requiredNoDefaultCount := 0
for _, arg := range commandConfig.Arguments {
if arg.Required && arg.Default == "" {
Expand Down Expand Up @@ -310,7 +310,7 @@ func executeCustomCommand(
}

// Prepare template data
var data = map[string]any{
data := map[string]any{
"Arguments": argumentsData,
"Flags": flagsData,
}
Expand Down Expand Up @@ -536,7 +536,6 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
cacheCfg.LastChecked = time.Now().Unix()
if saveErr := cfg.SaveCache(cacheCfg); saveErr != nil {
u.LogWarning(atmosConfig, fmt.Sprintf("Unable to save cache: %s", saveErr))

}
}

Expand All @@ -554,7 +553,6 @@ func handleHelpRequest(cmd *cobra.Command, args []string) {
}

func showUsageAndExit(cmd *cobra.Command, args []string) {

var suggestions []string
unknownCommand := fmt.Sprintf("Error: Unknown command: %q\n\n", cmd.CommandPath())

Expand Down Expand Up @@ -593,7 +591,7 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin
checkAtmosConfig()

var argsAfterDoubleDash []string
var finalArgs = args
finalArgs := args

doubleDashIndex := lo.IndexOf(args, "--")
if doubleDashIndex > 0 {
Expand Down
3 changes: 0 additions & 3 deletions cmd/colored/colored.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type Config struct {

// Init patches Cobra's usage template with configuration provided.
func Init(cfg *Config) {

if cfg.RootCmd == nil {
panic("coloredcobra: Root command pointer is missing.")
}
Expand Down Expand Up @@ -147,7 +146,6 @@ func Init(cfg *Config) {
if cf != nil || cfd != nil || cfdt != nil {

cobra.AddTemplateFunc("FlagStyle", func(s string) string {

// Flags info section is multi-line.
// Let's split these lines and iterate them.
lines := strings.Split(s, "\n")
Expand Down Expand Up @@ -193,7 +191,6 @@ func Init(cfg *Config) {
s = strings.Join(lines, "\n")

return s

})

// Patch usage template
Expand Down
1 change: 0 additions & 1 deletion cmd/describe_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var describeConfigCmd = &cobra.Command{
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {

err := e.ExecuteDescribeConfigCmd(cmd, args)
if err != nil {
u.LogErrorAndExit(schema.AtmosConfiguration{}, err)
Expand Down
1 change: 0 additions & 1 deletion cmd/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var describeStacksCmd = &cobra.Command{
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {

// Check Atmos configuration
checkAtmosConfig()

Expand Down
6 changes: 4 additions & 2 deletions cmd/helmfile_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
)

// Command: atmos helmfile apply
var helmfileApplyShort = "Apply changes to align the actual state of Helm releases with the desired state."
var helmfileApplyLong = `This command reconciles the actual state of Helm releases in the cluster with the desired state
var (
helmfileApplyShort = "Apply changes to align the actual state of Helm releases with the desired state."
helmfileApplyLong = `This command reconciles the actual state of Helm releases in the cluster with the desired state
defined in your configurations by applying the necessary changes.

Example usage:
atmos helmfile apply echo-server -s tenant1-ue2-dev
atmos helmfile apply echo-server -s tenant1-ue2-dev --redirect-stderr /dev/stdout`
)

// helmfileApplyCmd represents the base command for all helmfile sub-commands
var helmfileApplyCmd = &cobra.Command{
Expand Down
6 changes: 4 additions & 2 deletions cmd/helmfile_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package cmd
import "github.com/spf13/cobra"

// Command: atmos helmfile destroy
var helmfileDestroyShort = "Destroy the Helm releases for the specified stack."
var helmfileDestroyLong = `This command removes the specified Helm releases from the cluster, ensuring a clean state for
var (
helmfileDestroyShort = "Destroy the Helm releases for the specified stack."
helmfileDestroyLong = `This command removes the specified Helm releases from the cluster, ensuring a clean state for
the given stack.

Example usage:
atmos helmfile destroy echo-server --stack=tenant1-ue2-dev
atmos helmfile destroy echo-server --stack=tenant1-ue2-dev --redirect-stderr /dev/stdout`
)

// helmfileDestroyCmd represents the base command for all helmfile sub-commands
var helmfileDestroyCmd = &cobra.Command{
Expand Down
6 changes: 4 additions & 2 deletions cmd/helmfile_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
)

// Command: atmos helmfile diff
var helmfileDiffShort = "Show differences between the desired and actual state of Helm releases."
var helmfileDiffLong = `This command calculates and displays the differences between the desired state of Helm releases
var (
helmfileDiffShort = "Show differences between the desired and actual state of Helm releases."
helmfileDiffLong = `This command calculates and displays the differences between the desired state of Helm releases
defined in your configurations and the actual state deployed in the cluster.

Example usage:
atmos helmfile diff echo-server -s tenant1-ue2-dev
atmos helmfile diff echo-server -s tenant1-ue2-dev --redirect-stderr /dev/null`
)

// helmfileDiffCmd represents the base command for all helmfile sub-commands
var helmfileDiffCmd = &cobra.Command{
Expand Down
6 changes: 4 additions & 2 deletions cmd/helmfile_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package cmd
import "github.com/spf13/cobra"

// Command: atmos helmfile sync
var helmfileSyncShort = "Synchronize the state of Helm releases with the desired state without making changes."
var helmfileSyncLong = `This command ensures that the actual state of Helm releases in the cluster matches the desired
var (
helmfileSyncShort = "Synchronize the state of Helm releases with the desired state without making changes."
helmfileSyncLong = `This command ensures that the actual state of Helm releases in the cluster matches the desired
state defined in your configurations without performing destructive actions.

Example usage:
atmos helmfile sync echo-server --stack tenant1-ue2-dev
atmos helmfile sync echo-server --stack tenant1-ue2-dev --redirect-stderr ./errors.txt`
)

// helmfileSyncCmd represents the base command for all helmfile sub-commands
var helmfileSyncCmd = &cobra.Command{
Expand Down
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func initCobraConfig() {
return nil
})
RootCmd.SetHelpFunc(func(command *cobra.Command, args []string) {

if !(Contains(os.Args, "help") || Contains(os.Args, "--help") || Contains(os.Args, "-h")) {
arguments := os.Args[len(strings.Split(command.CommandPath(), " ")):]
if len(command.Flags().Args()) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/validate_editorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var editorConfigCmd *cobra.Command = &cobra.Command{
func initializeConfig(cmd *cobra.Command) {
replaceAtmosConfigInConfig(cmd, atmosConfig)

var configPaths = []string{}
configPaths := []string{}
if configFilePath == "" {
configPaths = append(configPaths, defaultConfigFileNames[:]...)
} else {
Expand Down
3 changes: 1 addition & 2 deletions internal/exec/atlantis_generate_repo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func ExecuteAtlantisGenerateRepoConfig(
stacks []string,
components []string,
) error {

stacksMap, _, err := FindStacksMap(atmosConfig, false)
if err != nil {
return err
Expand Down Expand Up @@ -507,7 +506,7 @@ func ExecuteAtlantisGenerateRepoConfig(
return err
}

err = u.WriteToFileAsYAML(fileAbsolutePath, atlantisYaml, 0644)
err = u.WriteToFileAsYAML(fileAbsolutePath, atlantisYaml, 0o644)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion internal/exec/atlantis_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func BuildAtlantisProjectNameFromComponentConfig(
atmosConfig schema.AtmosConfiguration,
configAndStacksInfo schema.ConfigAndStacksInfo,
) (string, error) {

var atlantisProjectTemplate schema.AtlantisProjectConfig
var atlantisProjectName string

Expand Down
7 changes: 0 additions & 7 deletions internal/exec/config_sources_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func processSectionValueInStacks(
subsection string,
value string,
) schema.ConfigSourcesStackDependencies {

result := schema.ConfigSourcesStackDependencies{}

// Process the value for the component in the stack
Expand Down Expand Up @@ -231,7 +230,6 @@ func processComponentSectionValueInStack(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down Expand Up @@ -327,7 +325,6 @@ func processComponentTypeSectionValueInStack(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down Expand Up @@ -402,7 +399,6 @@ func processGlobalSectionValueInStack(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down Expand Up @@ -468,7 +464,6 @@ func processComponentSectionValueInStackImports(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down Expand Up @@ -578,7 +573,6 @@ func processComponentTypeSectionValueInStackImports(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down Expand Up @@ -667,7 +661,6 @@ func processGlobalSectionValueInStackImports(
subsection string,
value string,
) *schema.ConfigSourcesStackDependencies {

rawStackConfig, ok := rawStackConfigs[stackFile]
if !ok {
return result
Expand Down
Loading
Loading