From b90dee9384007eafccb34db6a11cbbc33408f353 Mon Sep 17 00:00:00 2001 From: Aliaksandr Panasiuk Date: Wed, 22 Jan 2025 17:47:29 +0100 Subject: [PATCH 1/4] #29 - add the generation of values for all cluster provider configurations in the project generate command, refactoring code --- cmd/cluster.go | 8 +--- cmd/cluster_capa.go | 2 +- cmd/cluster_capg.go | 2 +- cmd/cluster_capz.go | 2 +- cmd/commands.go | 3 ++ cmd/project.go | 53 ++++++++++++++++++++- cmd/project_dependencies.go | 50 ++++++++++++-------- cmd/project_generation.go | 93 +++++++++++++++++++++++++++++-------- docs/release-notes.md | 2 + github/github.go | 20 +++++--- notification/slack.go | 4 +- util/dictionary.go | 2 +- util/system.go | 13 ++++-- 13 files changed, 191 insertions(+), 63 deletions(-) diff --git a/cmd/cluster.go b/cmd/cluster.go index 962c956..e4cb7c3 100644 --- a/cmd/cluster.go +++ b/cmd/cluster.go @@ -4,7 +4,6 @@ import ( "fmt" "go.uber.org/zap" "os" - "regexp" "strings" yaml2 "github.com/ghodss/yaml" @@ -226,13 +225,8 @@ func (cc *ClusterCommands) getKubeContext() (string, string, error) { return "", "", err } - re, err := regexp.Compile(`(?i)\b` + cc.Conf.Name + `\b`) - if err != nil { - return "", "", err - } - for key := range kubeConfig.Contexts { - if re.MatchString(key) { + if cc.Conf.Name == key { contextNames = append(contextNames, key) } } diff --git a/cmd/cluster_capa.go b/cmd/cluster_capa.go index dba5395..c7ded5e 100644 --- a/cmd/cluster_capa.go +++ b/cmd/cluster_capa.go @@ -184,7 +184,7 @@ func (cc *ClusterCommands) createAWSSecrets() error { return err } - if len(secrets) > 0 { + if len(secrets) > 0 || !util.IsExists(cc.Conf.SopsAgeKeys, false) { return nil } diff --git a/cmd/cluster_capg.go b/cmd/cluster_capg.go index 6064e2d..caf86e8 100644 --- a/cmd/cluster_capg.go +++ b/cmd/cluster_capg.go @@ -106,7 +106,7 @@ func (cc *ClusterCommands) createGCPSecrets() error { return err } - if len(secrets) > 0 { + if len(secrets) > 0 || !util.IsExists(cc.Conf.SopsAgeKeys, false) { return nil } diff --git a/cmd/cluster_capz.go b/cmd/cluster_capz.go index de1bae8..b4265f9 100644 --- a/cmd/cluster_capz.go +++ b/cmd/cluster_capz.go @@ -159,7 +159,7 @@ func (cc *ClusterCommands) createAzureSecrets(ac *azure_provider.AzureConfigure) return err } - if len(secrets) > 0 { + if len(secrets) > 0 || !util.IsExists(cc.Conf.SopsAgeKeys, false) { return nil } diff --git a/cmd/commands.go b/cmd/commands.go index d78de00..3b4471f 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "sort" "github.com/urfave/cli/v2" @@ -519,6 +520,8 @@ func readInputSourceWithContext(gitSpec *git_handler.GitSpec, conf *config.Confi if ctx.Command.Name == "generate" && !util.IsExists(util.GetPwdPath(util.TenantProjectFile), true) { return nil + } else if ctx.Command.Name == "generate" && util.IsExists(util.GetPwdPath(util.TenantProjectFile), true) { + return fmt.Errorf("%s file exists, please eather delete it or run 'rmk config init' command to regenerate project", util.TenantProjectFile) } configPath := util.GetHomePath(util.RMKDir, util.RMKConfig, gitSpec.ID+".yaml") diff --git a/cmd/project.go b/cmd/project.go index 9dd8dc3..c763b18 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -18,10 +18,17 @@ import ( "rmk/config" "rmk/git_handler" + "rmk/github" "rmk/notification" "rmk/util" ) +const ( + clusterDepsRepo = "cluster-deps.bootstrap.infra" + clusterDepsRepoOwner = "edenlabllc" + clusterDepsRepoUrl = "git::https://github.com/" + clusterDepsRepoOwner + "/{{.Name}}.git?ref={{.Version}}" +) + type ProjectCommands struct { *parseContent projectFile *config.ProjectFile @@ -117,6 +124,21 @@ func (p *ProjectCommands) createProjectFile() error { p.projectFile.Spec.Scopes = p.Ctx.StringSlice("scopes") } + client, err := github.NewClient(clusterDepsRepoOwner, clusterDepsRepo, "", github.APIBaseUrl) + if err != nil { + return err + } + + if release, err := client.GetRelease(p.Ctx.Context, ""); err != nil { + zap.S().Warnf("skip add dependencies section into %s file, GitHub error: %v", util.TenantProjectFile, err) + } else { + p.projectFile.Dependencies = append(p.projectFile.Dependencies, config.Package{ + Name: clusterDepsRepo, + Version: release.GetTagName(), + Url: clusterDepsRepoUrl, + }) + } + encoder := yaml.NewEncoder(&buf) encoder.SetIndent(2) if err := encoder.Encode(&p.projectFile); err != nil { @@ -313,6 +335,33 @@ func (p *ProjectCommands) generateProjectFiles(gitSpec *git_handler.GitSpec) err for _, sc := range p.scopes { for _, env := range sc.environments { switch sc.name { + case "deps": + tAWSCluster, err := p.Conf.ParseTemplate(template.New("TenantAWSCluster"), &p.parseContent, tenantAWSClusterValuesExample) + if err != nil { + return err + } + + if err := p.writeProjectFiles(filepath.Join(env.valuesPath, "aws-cluster.yaml.gotmpl"), tAWSCluster); err != nil { + return err + } + + tAzureCluster, err := p.Conf.ParseTemplate(template.New("TenantAzureCluster"), &p.parseContent, tenantAzureClusterValuesExample) + if err != nil { + return err + } + + if err := p.writeProjectFiles(filepath.Join(env.valuesPath, "azure-cluster.yaml.gotmpl"), tAzureCluster); err != nil { + return err + } + + tGCPCluster, err := p.Conf.ParseTemplate(template.New("TenantGCPCluster"), &p.parseContent, tenantGCPClusterValuesExample) + if err != nil { + return err + } + + if err := p.writeProjectFiles(filepath.Join(env.valuesPath, "gcp-cluster.yaml.gotmpl"), tGCPCluster); err != nil { + return err + } case p.TenantName: tGlobals, err := p.Conf.ParseTemplate(template.New("TenantGlobals"), &p.parseContent, tenantGlobals) if err != nil { @@ -344,7 +393,9 @@ func (p *ProjectCommands) generateProjectFiles(gitSpec *git_handler.GitSpec) err if err := p.writeProjectFiles(filepath.Join(env.valuesPath, p.TenantName+"-app.yaml.gotmpl"), tenantValuesExample); err != nil { return err } - default: + } + + if sc.name != p.TenantName { if err := p.writeProjectFiles(env.globalsPath, globals); err != nil { return err } diff --git a/cmd/project_dependencies.go b/cmd/project_dependencies.go index 39b0b1c..cc49a2e 100644 --- a/cmd/project_dependencies.go +++ b/cmd/project_dependencies.go @@ -145,9 +145,8 @@ func resolveHooks(hooks map[string]*config.Package, tenant string, conf *config. } else if len(conf.Dependencies) > 0 { conf.HooksMapping = append(conf.HooksMapping, config.HookMapping{ - Tenant: tenant, - Exists: false, - Package: &config.Package{}, + Tenant: tenant, + Exists: false, }, ) } @@ -185,7 +184,7 @@ func uniqueHooksMapping(hooks []config.HookMapping) []config.HookMapping { for key, ver := range compareHooks { if len(compareHooks) > 1 { for _, v := range compareHooks { - if ver.GreaterThan(v) { + if ver.GreaterThan(v) || ver.Equal(v) { numberHook = key } } @@ -201,7 +200,19 @@ func uniqueHooksMapping(hooks []config.HookMapping) []config.HookMapping { } } - return uniqueHooksMapping + packageObject := false + for _, val := range uniqueHooksMapping { + if val.Package != nil { + packageObject = true + break + } + } + + if packageObject { + return uniqueHooksMapping + } + + return []config.HookMapping{} } func (is *InventoryState) saveState(inv config.Inventory) { @@ -277,16 +288,12 @@ func resolveDependencies(conf *config.Config, ctx *cli.Context, silent bool) err for _, val := range conf.Dependencies { projectFile := &config.ProjectFile{} - depsDir := util.FindDir(util.GetPwdPath(TenantPrDependenciesDir), val.Name) + nameDir := val.Name + "-" + strings.ReplaceAll(val.Version, "/", "_") + depsDir := util.FindDir(util.GetPwdPath(TenantPrDependenciesDir), nameDir, false, false) if err := projectFile.ReadProjectFile(util.GetPwdPath(TenantPrDependenciesDir, depsDir, util.TenantProjectFile)); err != nil { return err } - // Resolve and recursively download repositories containing helm plugins - if conf.HelmPlugins, invErr = invState.resolveHelmPlugins(projectFile.HelmPlugins, conf); invErr != nil { - return invErr - } - // Resolve repositories containing hooks if len(strings.Split(depsDir, ".")) > 0 { if err := resolveHooks(projectFile.Hooks, strings.Split(depsDir, ".")[0], conf); err != nil { @@ -294,6 +301,11 @@ func resolveDependencies(conf *config.Config, ctx *cli.Context, silent bool) err } } + // Resolve and recursively download repositories containing helm plugins + if conf.HelmPlugins, invErr = invState.resolveHelmPlugins(projectFile.HelmPlugins, conf); invErr != nil { + return invErr + } + // Resolve and recursively download repositories containing tools if conf.Tools, invErr = invState.resolveTools(projectFile.Tools, conf); invErr != nil { return invErr @@ -347,11 +359,11 @@ func resolveDependencies(conf *config.Config, ctx *cli.Context, silent bool) err return err } - if err := updateTools(conf, ctx, silent); err != nil { + if err := newConfigCommands(conf, ctx, util.GetPwdPath("")).configHelmPlugins(); err != nil { return err } - if err := newConfigCommands(conf, ctx, util.GetPwdPath("")).configHelmPlugins(); err != nil { + if err := updateTools(conf, ctx, silent); err != nil { return err } @@ -367,13 +379,11 @@ func removeOldDir(pwd string, pkg config.Package) error { return nil } - oldDir := util.FindDir(pwd, pkg.Name) - if len(strings.Split(oldDir, "-")) > 1 { - oldVer := strings.SplitN(oldDir, "-", 2)[1] - if oldVer != pkg.Version { - if err := os.RemoveAll(filepath.Join(pwd, pkg.Name+"-"+oldVer)); err != nil { - return err - } + oldDir := util.FindDir(pwd, pkg.Name, true, false) + oldVer := strings.TrimPrefix(oldDir, pkg.Name+"-") + if oldVer != strings.ReplaceAll(pkg.Version, "/", "_") { + if err := os.RemoveAll(filepath.Join(pwd, pkg.Name+"-"+oldVer)); err != nil { + return err } } diff --git a/cmd/project_generation.go b/cmd/project_generation.go index 3775438..7d8f40d 100644 --- a/cmd/project_generation.go +++ b/cmd/project_generation.go @@ -102,23 +102,9 @@ helmfiles: ` + escapeOpen + `{{ env "HELMFILE_` + escapeClose + `{{ .TenantNameE ` helmfileReleases = `releases: - # TODO: Releases from group 1 are needed to deploy K3D clusters. - # TODO: If you do not inherit upstream repositories, you can leave these releases as is, - # TODO: or make sure that upstream repositories do not have the same releases to avoid conflicts. - # Group 1 - - name: k3d-cluster - namespace: kube-system - chart: "{{"{{` + escape + `{{ .Release.Labels.repo }}` + escape + `}}"}}/k3d-cluster" - version: 0.1.0 - labels: - cluster: k3d - installed: ` + escapeOpen + `{{ eq (env "K3D_CLUSTER" | default "false") "true" }}` + escapeClose + ` - inherit: - - template: release - # TODO: It is recommended to adapt this example considering security, performance and configuration management # TODO: requirements specific to your application or infrastructure. - # Group 2 + # Group 1 - name: {{ .TenantName }}-app namespace: {{ .TenantName }} chart: "{{"{{` + escape + `{{ .Release.Labels.repo }}` + escape + `}}"}}/app" @@ -171,12 +157,21 @@ develop ------> staging ------> production > Note: The generated project structure using the RMK tools is mandatory and is required for the interaction of the RMK with the code base. > All generated files have example content and can be supplemented according to project requirements. -After generating the project structure, a set of files is generated for the main project scope etc/{{ .TenantName }} -to demonstrate an example of configuring the {{ .TenantName }}-app release. -This example shows how the following options are configured and interact with each other: - +After generating the project structure, files are created in the deps scope +` + escape + `etc/deps` + escape + ` and the main project scope ` + escape + `etc/{{ .TenantName }}` + escape + ` to provide +an example of configuring cluster provisioning and the ` + escape + `{{ .TenantName }}-app` + escape + ` release. +This example demonstrates how the following options are configured and interact with each other: + +- etc/deps/\/secrets/.sops.yaml +- etc/deps/\/secrets/.spec.yaml.gotmpl +- etc/deps/\/values/aws-cluster.yaml.gotmpl +- etc/deps/\/values/azure-cluster.yaml.gotmpl +- etc/deps/\/values/gcp-cluster.yaml.gotmpl +- etc/deps/\/globals.yaml.gotmpl +- etc/deps/\/releases.yaml +- etc/{{ .TenantName }}/\/secrets/.sops.yaml - etc/{{ .TenantName }}/\/secrets/.spec.yaml.gotmpl -- etc/{{ .TenantName }}/\/values/rmk-test-app.yaml.gotmpl +- etc/{{ .TenantName }}/\/values/{{ .TenantName }}-app.yaml.gotmpl - etc/{{ .TenantName }}/\/globals.yaml.gotmpl - etc/{{ .TenantName }}/\/releases.yaml - helmfile.yaml.gotmpl @@ -297,6 +292,64 @@ generation-rules: PASSWORD: ` + escapeOpen + `{{ randAlphaNum 16 }}` + escapeClose + ` ` + tenantAWSClusterValuesExample = `# This value file is an introductory example configuration for provisioning AWS EKS via RMK. +# The value file is intended to demonstrate the basic capabilities of RMK in provisioning Kubernetes clusters for specific provider +# and should not be used as is in a production environment. +# A complete example of a set of options for configuring the provision of an AWS EKS +# cluster at the link: https://github.com/edenlabllc/cluster-deps.bootstrap.infra/blob/develop/etc/deps/develop/values/aws-cluster.yaml.gotmpl + +# TODO: It is recommended to adapt this example considering security, performance and configuration management +# TODO: requirements specific to your infrastructure. +controlPlane: + spec: + iamAuthenticatorConfig: + # UserMappings is a list of user mappings + mapUsers: [] +` + escapeOpen + `{{/*# TODO: Add a list of users at the downstream tenant repository level*/}}` + escapeClose + ` +` + escapeOpen + `{{/* - groups:*/}}` + escapeClose + ` +` + escapeOpen + `{{/* - system:masters*/}}` + escapeClose + ` +` + escapeOpen + `{{/* # UserARN is the AWS ARN for the user to map*/}}` + escapeClose + ` +` + escapeOpen + `{{/* userarn: arn:aws:iam::{{ env "AWS_ACCOUNT_ID" }}:user/user1*/}}` + escapeClose + ` +` + escapeOpen + `{{/* # UserName is a kubernetes RBAC user subject*/}}` + escapeClose + ` +` + escapeOpen + `{{/* username: user1*/}}` + escapeClose + ` + +## The machine pools configurations +machinePools: + app: + enabled: true +` + + tenantAzureClusterValuesExample = `# This value file is an introductory example configuration for provisioning Azure AKS via RMK. +# The value file is intended to demonstrate the basic capabilities of RMK in provisioning Kubernetes clusters for specific provider +# and should not be used as is in a production environment. +# A complete example of a set of options for configuring the provision of an Azure AKS +# cluster at the link: https://github.com/edenlabllc/cluster-deps.bootstrap.infra/blob/develop/etc/deps/develop/values/azure-cluster.yaml.gotmpl + +# TODO: It is recommended to adapt this example considering security, performance and configuration management +# TODO: requirements specific to your infrastructure. +## The machine pools configurations +machinePools: + system: + enabled: true + + app: + enabled: true +` + + tenantGCPClusterValuesExample = `# This value file is an introductory example configuration for provisioning GCP GKE via RMK. +# The value file is intended to demonstrate the basic capabilities of RMK in provisioning Kubernetes clusters for specific provider +# and should not be used as is in a production environment. +# A complete example of a set of options for configuring the provision of an GCP GKE +# cluster at the link: https://github.com/edenlabllc/cluster-deps.bootstrap.infra/blob/develop/etc/deps/develop/values/gcp-cluster.yaml.gotmpl + +# TODO: It is recommended to adapt this example considering security, performance and configuration management +# TODO: requirements specific to your infrastructure. +## The machine pools configurations +machinePools: + app: + enabled: true +` + tenantValuesExample = `# This value file is an introductory example configuration for running Nginx in Kubernetes via RMK. # It combines several key components such as Deployment, Service, ConfigMap, Secrets and other options. # The value file is intended to demonstrate the basic capabilities of RMK in deploying releases diff --git a/docs/release-notes.md b/docs/release-notes.md index 4234091..21987c6 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -9,6 +9,8 @@ - #29 - Added GCP NAT router creation for the GCP provider. - #29 - Added commands for managing Cluster API clusters to the cluster category commands. - #29 - Added new configuration arguments for project generation. +- #29 - Added the generation of values for all cluster provider configurations in the project generate command. +- #29 - Fixed the inheritance behavior of dependent repositories. - #29 - Fixed the output of the config list command for adjacent tenant names. - #29 - Removed the artifact-mode flag and the functionality. - #29 - Reworked the behaviour of the config init command to align with each cluster provider. diff --git a/github/github.go b/github/github.go index 9bfb4ab..f3ccfa4 100644 --- a/github/github.go +++ b/github/github.go @@ -10,6 +10,8 @@ import ( "golang.org/x/oauth2" ) +const APIBaseUrl = "https://api.github.com/" + // GitHub contains the functions necessary for interacting with GitHub release // objects type GitHub interface { @@ -24,6 +26,8 @@ type Client struct { // NewClient creates and initializes a new GitHubClient func NewClient(owner, repo, token, urlStr string) (GitHub, error) { + var client *github.Client + if len(owner) == 0 { return nil, fmt.Errorf("missing GitHub repository owner") } @@ -37,10 +41,14 @@ func NewClient(owner, repo, token, urlStr string) (GitHub, error) { return nil, fmt.Errorf("failed to parse Github API URL: %v", err) } - ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) - tc := oauth2.NewClient(context.TODO(), ts) + if len(token) > 0 { + ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) + tc := oauth2.NewClient(context.TODO(), ts) + client = github.NewClient(tc) + } else { + client = github.NewClient(&http.Client{}) + } - client := github.NewClient(tc) client.BaseURL = baseURL return &Client{Owner: owner, Repo: repo, Client: client}, nil @@ -52,17 +60,17 @@ func (c *Client) GetRelease(ctx context.Context, tag string) (*github.Repository errHandler := func(release *github.RepositoryRelease, res *github.Response, err error) (*github.RepositoryRelease, error) { if err != nil { if res == nil { - return nil, fmt.Errorf("failed to get RMK release version: %s", tag) + return nil, fmt.Errorf("failed to get release version for repository: %s", c.Repo) } switch { case res.StatusCode == http.StatusUnauthorized: return nil, fmt.Errorf("wrong token is specified or there is no permission, invalid status: %s", res.Status) case res.StatusCode != http.StatusNotFound: - return nil, fmt.Errorf("get RMK update release, invalid status: %s", res.Status) + return nil, fmt.Errorf("repository %s not found, invalid status: %s", c.Repo, res.Status) } - return nil, fmt.Errorf("RMK release version %s not found", tag) + return nil, fmt.Errorf("release version %s not found for repository: %s", tag, c.Repo) } return release, nil diff --git a/notification/slack.go b/notification/slack.go index d1ea947..5a7d7a9 100644 --- a/notification/slack.go +++ b/notification/slack.go @@ -48,8 +48,8 @@ func (s *SlackConfig) slackPostMsg(status string) error { return nil } else { if len(s.SlackWebHook) == 0 || len(s.SlackChannel) == 0 { - zap.S().Fatalf("parameters --slack-webhook, --slack-channel not set for command " + - "'rmk config init', required if Slack notifications are enabled") + zap.S().Fatalf("parameters --slack-webhook, --slack-channel not set for 'rmk config init' command," + + "required if Slack notifications are enabled") } } diff --git a/util/dictionary.go b/util/dictionary.go index c923071..919a293 100644 --- a/util/dictionary.go +++ b/util/dictionary.go @@ -35,7 +35,7 @@ const ( ToolsVersionDir = "version" ConfigNotInitializedErrorText = "RMK config not initialized, " + - "please run command 'rmk config init' with specific parameters" + "please run 'rmk config init' command with specific parameters" // UnknownErrorText standard text for unknown errors UnknownErrorText = "unknown error when calling %s" //HelmPluginExist HelmSecretsIsNotEncrypted HelmSecretsAlreadyEncrypted - exception err text matching diff --git a/util/system.go b/util/system.go index ff5b914..1e1c7b6 100644 --- a/util/system.go +++ b/util/system.go @@ -179,15 +179,22 @@ func IsExists(path string, file bool) bool { } } -func FindDir(path, name string) string { +func FindDir(path, pattern string, byPrefix, bySuffix bool) string { fileInfo, err := os.ReadDir(path) if err != nil { zap.S().Fatal(err) } for _, dir := range fileInfo { - if dir.IsDir() && strings.Contains(dir.Name(), name) { - return dir.Name() + if dir.IsDir() { + switch { + case byPrefix && strings.HasPrefix(dir.Name(), pattern): + return dir.Name() + case bySuffix && strings.HasSuffix(dir.Name(), pattern): + return dir.Name() + case dir.Name() == pattern: + return dir.Name() + } } } From 838186d93e4ffff148218448932130939b5bdca1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Panasiuk Date: Thu, 23 Jan 2025 09:44:15 +0100 Subject: [PATCH 2/4] #29 - refactoring --- cmd/project.go | 6 +++--- cmd/project_generation.go | 25 +++++++++++++------------ github/github.go | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cmd/project.go b/cmd/project.go index c763b18..b01ca8c 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -26,7 +26,7 @@ import ( const ( clusterDepsRepo = "cluster-deps.bootstrap.infra" clusterDepsRepoOwner = "edenlabllc" - clusterDepsRepoUrl = "git::https://github.com/" + clusterDepsRepoOwner + "/{{.Name}}.git?ref={{.Version}}" + clusterDepsRepoURL = "git::https://github.com/" + clusterDepsRepoOwner + "/{{.Name}}.git?ref={{.Version}}" ) type ProjectCommands struct { @@ -124,7 +124,7 @@ func (p *ProjectCommands) createProjectFile() error { p.projectFile.Spec.Scopes = p.Ctx.StringSlice("scopes") } - client, err := github.NewClient(clusterDepsRepoOwner, clusterDepsRepo, "", github.APIBaseUrl) + client, err := github.NewClient(clusterDepsRepoOwner, clusterDepsRepo, "", github.APIBaseURL) if err != nil { return err } @@ -135,7 +135,7 @@ func (p *ProjectCommands) createProjectFile() error { p.projectFile.Dependencies = append(p.projectFile.Dependencies, config.Package{ Name: clusterDepsRepo, Version: release.GetTagName(), - Url: clusterDepsRepoUrl, + Url: clusterDepsRepoURL, }) } diff --git a/cmd/project_generation.go b/cmd/project_generation.go index 7d8f40d..ffd2266 100644 --- a/cmd/project_generation.go +++ b/cmd/project_generation.go @@ -125,20 +125,20 @@ helmfiles: ` + escapeOpen + `{{ env "HELMFILE_` + escapeClose + `{{ .TenantNameE ## Description -The repository designed for the rapid setup and deployment of the infrastructure required for the {{ .TenantName }} project. +The repository designed for the rapid setup and deployment of the infrastructure required for the ` + escape + `{{ .TenantName }}` + escape + ` project. This project includes scripts, configurations, and instructions to automate the deployment of necessary services and dependencies. ## Getting Started -To get started with {{ .RepoName }}, ensure you have all the necessary tools and dependencies installed. +To get started with ` + escape + `{{ .RepoName }}` + escape + `, ensure you have all the necessary tools and dependencies installed. Detailed information about requirements and installation instructions can be found in the [Requirements](#requirements) section. ### Requirements -- Git -- GitHub PAT to access the repositories listed in the ` + "`dependencies`" + ` section of ` + "`project.yaml`" + ` -- Note: K3D v5.x.x requires at least Docker v20.10.5 (runc >= v1.0.0-rc93) to work properly -- [RMK CLI](https://edenlabllc.github.io/rmk/latest) +- **Git** +- **GitHub PAT** to access the repositories listed in the ` + "`dependencies`" + ` section of ` + "`project.yaml`" + ` +- **K3D** v5.x.x requires at least Docker v20.10.5 (runc >= v1.0.0-rc93) to work properly +- **[RMK CLI](https://edenlabllc.github.io/rmk/latest)** ### GitLab flow strategy @@ -154,10 +154,10 @@ develop ------> staging ------> production ### Generating project structure -> Note: The generated project structure using the RMK tools is mandatory and is required for the interaction of the RMK with the code base. +> The generated project structure using the RMK tools is mandatory and is required for the interaction of the RMK with the code base. > All generated files have example content and can be supplemented according to project requirements. -After generating the project structure, files are created in the deps scope +After generating the project structure, files are created in the ` + escape + `deps` + escape + ` scope ` + escape + `etc/deps` + escape + ` and the main project scope ` + escape + `etc/{{ .TenantName }}` + escape + ` to provide an example of configuring cluster provisioning and the ` + escape + `{{ .TenantName }}-app` + escape + ` release. This example demonstrates how the following options are configured and interact with each other: @@ -179,13 +179,13 @@ This example demonstrates how the following options are configured and interact {{ if .Dependencies }} #### Inherited repositories {{ range .Dependencies }} -- **{{ . }}** +- {{ . }} {{ end }} {{- end }} {{- if .Scopes }} #### Available scopes of variables {{ range .Scopes }} -- **{{ . }}** +- {{ . }} {{ end }} {{- end }} ### Basic RMK commands for project management @@ -195,7 +195,8 @@ This example demonstrates how the following options are configured and interact ` + "```" + `shell rmk project generate \ --environment=develop.root-domain=localhost \ - --owners=user \ + --owners=gh-user \ + --scopes=deps --scopes={{ .TenantName }} ` + "```" + ` @@ -217,7 +218,7 @@ rmk cluster k3d create rmk release sync ` + "```" + ` -> Note: A complete list of RMK commands and capabilities can be found at the [link](https://edenlabllc.github.io/rmk/latest) +> A complete list of RMK commands and capabilities can be found at the [link](https://edenlabllc.github.io/rmk/latest) ` releasesFile = `# This file defines the release list, is located in the environment directory diff --git a/github/github.go b/github/github.go index f3ccfa4..277d640 100644 --- a/github/github.go +++ b/github/github.go @@ -10,7 +10,7 @@ import ( "golang.org/x/oauth2" ) -const APIBaseUrl = "https://api.github.com/" +const APIBaseURL = "https://api.github.com/" // GitHub contains the functions necessary for interacting with GitHub release // objects From a0dd922516f60609ce98f4438707d9118d1286d9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Panasiuk Date: Thu, 23 Jan 2025 09:45:43 +0100 Subject: [PATCH 3/4] #29 - refactoring --- cmd/project_generation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/project_generation.go b/cmd/project_generation.go index ffd2266..1712246 100644 --- a/cmd/project_generation.go +++ b/cmd/project_generation.go @@ -196,7 +196,7 @@ This example demonstrates how the following options are configured and interact rmk project generate \ --environment=develop.root-domain=localhost \ --owners=gh-user \ - --scopes=deps + --scopes=deps \ --scopes={{ .TenantName }} ` + "```" + ` From b53bd31524ecff894a8c58285cba7b3abdecc263 Mon Sep 17 00:00:00 2001 From: Aliaksandr Panasiuk Date: Thu, 23 Jan 2025 10:21:26 +0100 Subject: [PATCH 4/4] #29 - refactoring --- cmd/project_generation.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/project_generation.go b/cmd/project_generation.go index 1712246..81fb88c 100644 --- a/cmd/project_generation.go +++ b/cmd/project_generation.go @@ -190,7 +190,7 @@ This example demonstrates how the following options are configured and interact {{- end }} ### Basic RMK commands for project management -#### Project generate +#### Generate project structure ` + "```" + `shell rmk project generate \ @@ -200,7 +200,7 @@ rmk project generate \ --scopes={{ .TenantName }} ` + "```" + ` -#### Initialization configuration +#### Initialize configuration ` + "```" + `shell rmk config init @@ -212,13 +212,13 @@ rmk config init rmk cluster k3d create ` + "```" + ` -#### Release sync +#### Synchronize releases defined in Helmfile ` + "```" + `shell rmk release sync ` + "```" + ` -> A complete list of RMK commands and capabilities can be found at the [link](https://edenlabllc.github.io/rmk/latest) +A complete list of RMK commands and capabilities can be found at the [link](https://edenlabllc.github.io/rmk/latest) ` releasesFile = `# This file defines the release list, is located in the environment directory