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

feat: Application generation strategies and clusters generation #8263

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d0e2135
move projects
pasha-codefresh Dec 6, 2021
7a82176
Revert "move projects"
pasha-codefresh Dec 6, 2021
c7f55e5
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 10, 2021
27f1b48
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 13, 2021
7e90d1a
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 16, 2021
f3fd16b
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 17, 2021
7e14dce
project generation
pasha-codefresh Dec 20, 2021
0ac6c9d
support application generation
pasha-codefresh Dec 20, 2021
8a0495d
implement resource generation with sampling
pasha-codefresh Dec 20, 2021
2ce1866
ability to clean resources
pasha-codefresh Dec 21, 2021
88e4d4a
add progress bar support to repo generation
pasha-codefresh Dec 23, 2021
13e134b
add logs
pasha-codefresh Dec 23, 2021
613a8e2
move to gen resources folder
pasha-codefresh Dec 27, 2021
d293b57
fix cmd
pasha-codefresh Dec 27, 2021
5137ed8
add build cmd
pasha-codefresh Dec 27, 2021
4b42486
revert redundant changes
pasha-codefresh Dec 27, 2021
9e61a16
resource gen
pasha-codefresh Dec 27, 2021
61613c3
pick random repository name during app creation
pasha-codefresh Dec 27, 2021
451a92f
manage destination
pasha-codefresh Dec 28, 2021
71afa78
Merge branch 'argoproj:master' into master
pasha-codefresh Dec 28, 2021
882263e
gen resources
pasha-codefresh Jan 14, 2022
f53882e
Merge branch 'master' of https://github.com/argoproj/argo-cd
pasha-codefresh Jan 14, 2022
a972604
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 15, 2022
5e6a122
Merge branch 'argoproj:master' into master
pasha-codefresh Jan 19, 2022
77c9047
Merge branches 'application-generation-strategies' and 'master' of gi…
pasha-codefresh Jan 22, 2022
77f361c
cluster generation
pasha-codefresh Jan 22, 2022
d229254
cluster generation
pasha-codefresh Jan 22, 2022
59b72e9
refactoring
pasha-codefresh Jan 23, 2022
7c8f70a
add all entities to saml
pasha-codefresh Jan 23, 2022
af77515
improve cluster generation
pasha-codefresh Jan 23, 2022
a8ba33d
improve clean up process for clusters
pasha-codefresh Jan 23, 2022
8e8af42
improve generation logs
pasha-codefresh Jan 24, 2022
bacaa1d
cleaning resources logs
pasha-codefresh Jan 24, 2022
3f90b5e
change path
pasha-codefresh Jan 24, 2022
6c5e728
fix linter
pasha-codefresh Jan 24, 2022
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
76 changes: 0 additions & 76 deletions hack/gen-resources/cmd/commands/all.go

This file was deleted.

59 changes: 0 additions & 59 deletions hack/gen-resources/cmd/commands/application.go

This file was deleted.

132 changes: 132 additions & 0 deletions hack/gen-resources/cmd/commands/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package commands

import (
"context"
"log"

"github.com/spf13/cobra"

generator "github.com/argoproj/argo-cd/v2/hack/gen-resources/generators"
"github.com/argoproj/argo-cd/v2/util/db"
"github.com/argoproj/argo-cd/v2/util/settings"

cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/hack/gen-resources/util"
"github.com/argoproj/argo-cd/v2/util/cli"
)

const (
cliName = "argocd-generator"
)

func init() {
cobra.OnInitialize(initConfig)
}

func initConfig() {
cli.SetLogFormat(cmdutil.LogFormat)
cli.SetLogLevel(cmdutil.LogLevel)
}

// NewCommand returns a new instance of an argocd command
func NewCommand() *cobra.Command {

var generateOpts util.GenerateOpts

var command = &cobra.Command{
Use: cliName,
Short: "Generator for argocd resources",
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
},
DisableAutoGenTag: true,
}

command.AddCommand(NewGenerateCommand(&generateOpts))
command.AddCommand(NewCleanCommand(&generateOpts))

command.PersistentFlags().StringVar(&generateOpts.Namespace, "kube-namespace", "argocd", "Name of the namespace on which Argo agent should be installed [$KUBE_NAMESPACE]")
return command
}

func NewGenerateCommand(opts *util.GenerateOpts) *cobra.Command {
var file string
var command = &cobra.Command{
Use: "generate [-f file]",
Short: "Generate entities",
Long: "Generate entities",
Run: func(c *cobra.Command, args []string) {
log.Printf("Retrieve configuration from %s", file)
err := util.Parse(opts, file)
if err != nil {
log.Fatalf("Failed to retrieve configuration, %v", err.Error())
}
argoClientSet := util.ConnectToK8sArgoClientSet()
clientSet := util.ConnectToK8sClientSet()

settingsMgr := settings.NewSettingsManager(context.TODO(), clientSet, opts.Namespace)
argoDB := db.NewDB(opts.Namespace, settingsMgr, clientSet)

pg := generator.NewProjectGenerator(argoClientSet)
ag := generator.NewApplicationGenerator(argoClientSet, clientSet, argoDB)
rg := generator.NewRepoGenerator(util.ConnectToK8sClientSet())
cg := generator.NewClusterGenerator(argoDB, util.ConnectToK8sClientSet(), util.ConnectToK8sConfig())

err = pg.Generate(opts)
if err != nil {
log.Fatalf("Failed to generate projects, %v", err.Error())
}
err = rg.Generate(opts)
if err != nil {
log.Fatalf("Failed to generate repositories, %v", err.Error())
}
err = cg.Generate(opts)
if err != nil {
log.Fatalf("Failed to generate clusters, %v", err.Error())
}
err = ag.Generate(opts)
if err != nil {
log.Fatalf("Failed to generate applications, %v", err.Error())
}
},
}
command.Flags().StringVarP(&file, "file", "f", "", "")
return command
}

func NewCleanCommand(opts *util.GenerateOpts) *cobra.Command {
var command = &cobra.Command{
Use: "clean",
Short: "Clean entities",
Long: "Clean entities",
Run: func(c *cobra.Command, args []string) {
argoClientSet := util.ConnectToK8sArgoClientSet()
clientSet := util.ConnectToK8sClientSet()
settingsMgr := settings.NewSettingsManager(context.TODO(), clientSet, opts.Namespace)
argoDB := db.NewDB(opts.Namespace, settingsMgr, clientSet)

pg := generator.NewProjectGenerator(argoClientSet)
ag := generator.NewApplicationGenerator(argoClientSet, clientSet, argoDB)
cg := generator.NewClusterGenerator(argoDB, clientSet, util.ConnectToK8sConfig())
rg := generator.NewRepoGenerator(clientSet)

err := pg.Clean(opts)
if err != nil {
log.Fatalf("Failed to clean projects, %v", err.Error())
}
err = ag.Clean(opts)
if err != nil {
log.Fatalf("Failed to clean applications, %v", err.Error())
}
err = cg.Clean(opts)
if err != nil {
log.Fatalf("Failed to clean clusters, %v", err.Error())
}
err = rg.Clean(opts)
if err != nil {
log.Fatalf("Failed to clean repositores, %v", err.Error())
}
},
}
return command
}
60 changes: 0 additions & 60 deletions hack/gen-resources/cmd/commands/project.go

This file was deleted.

61 changes: 0 additions & 61 deletions hack/gen-resources/cmd/commands/repos.go

This file was deleted.

Loading