Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .mockery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ require-template-schema-exists: true
template: testify
template-schema: "{{.Template}}.schema.json"
packages:
github.com/codesphere-cloud/oms/internal/bootstrap/gcp:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/env:
config:
all: true
Expand All @@ -22,6 +26,10 @@ packages:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/installer/node:
config:
all: true
interfaces:
github.com/codesphere-cloud/oms/internal/portal:
config:
all: true
Expand Down
36 changes: 18 additions & 18 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ License URL: https://github.com/googleapis/google-cloud-go/blob/iam/v1.5.3/iam/L

----------
Module: cloud.google.com/go/longrunning
Version: v0.7.0
Version: v0.8.0
License: Apache-2.0
License URL: https://github.com/googleapis/google-cloud-go/blob/longrunning/v0.7.0/longrunning/LICENSE
License URL: https://github.com/googleapis/google-cloud-go/blob/longrunning/v0.8.0/longrunning/LICENSE

----------
Module: cloud.google.com/go/resourcemanager
Expand Down Expand Up @@ -89,15 +89,15 @@ License URL: https://github.com/clipperhouse/stringish/blob/v0.1.1/LICENSE

----------
Module: github.com/clipperhouse/uax29/v2
Version: v2.3.0
Version: v2.4.0
License: MIT
License URL: https://github.com/clipperhouse/uax29/blob/v2.3.0/LICENSE
License URL: https://github.com/clipperhouse/uax29/blob/v2.4.0/LICENSE

----------
Module: github.com/codesphere-cloud/cs-go/pkg/io
Version: v0.16.1
Version: v0.16.2
License: Apache-2.0
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.1/LICENSE
License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.16.2/LICENSE

----------
Module: github.com/codesphere-cloud/oms/internal/tmpl
Expand Down Expand Up @@ -275,9 +275,9 @@ License URL: https://github.com/ulikunitz/xz/blob/v0.5.15/LICENSE

----------
Module: gitlab.com/gitlab-org/api/client-go
Version: v1.11.0
Version: v1.24.0
License: Apache-2.0
License URL: https://gitlab.com/gitlab-org/api/client-go/-/blob/v1.11.0/LICENSE
License URL: https://gitlab.com/gitlab-org/api/client-go/-/blob/v1.24.0/LICENSE

----------
Module: go.opentelemetry.io/auto/sdk
Expand Down Expand Up @@ -401,33 +401,33 @@ License URL: https://cs.opensource.google/go/x/time/+/v0.14.0:LICENSE

----------
Module: google.golang.org/api
Version: v0.263.0
Version: v0.264.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.263.0/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.264.0/LICENSE

----------
Module: google.golang.org/api/internal/third_party/uritemplates
Version: v0.263.0
Version: v0.264.0
License: BSD-3-Clause
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.263.0/internal/third_party/uritemplates/LICENSE
License URL: https://github.com/googleapis/google-api-go-client/blob/v0.264.0/internal/third_party/uritemplates/LICENSE

----------
Module: google.golang.org/genproto/googleapis
Version: v0.0.0-20251222181119-0a764e51fe1b
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/0a764e51fe1b/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/LICENSE

----------
Module: google.golang.org/genproto/googleapis/api
Version: v0.0.0-20251222181119-0a764e51fe1b
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/0a764e51fe1b/googleapis/api/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/googleapis/api/LICENSE

----------
Module: google.golang.org/genproto/googleapis/rpc
Version: v0.0.0-20260122232226-8e98ce8d340d
Version: v0.0.0-20260128011058-8636f8732409
License: Apache-2.0
License URL: https://github.com/googleapis/go-genproto/blob/8e98ce8d340d/googleapis/rpc/LICENSE
License URL: https://github.com/googleapis/go-genproto/blob/8636f8732409/googleapis/rpc/LICENSE

----------
Module: google.golang.org/grpc
Expand Down
51 changes: 29 additions & 22 deletions cli/cmd/bootstrap_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ import (

"github.com/codesphere-cloud/cs-go/pkg/io"
"github.com/codesphere-cloud/oms/internal/bootstrap"
"github.com/codesphere-cloud/oms/internal/bootstrap/gcp"
"github.com/codesphere-cloud/oms/internal/env"
"github.com/codesphere-cloud/oms/internal/installer"
"github.com/codesphere-cloud/oms/internal/installer/node"
"github.com/codesphere-cloud/oms/internal/util"
)

type BootstrapGcpCmd struct {
cmd *cobra.Command
Opts *GlobalOptions
Env env.Env
CodesphereEnv *bootstrap.CodesphereEnvironment

cmd *cobra.Command
Opts *GlobalOptions
Env env.Env
CodesphereEnv *gcp.CodesphereEnvironment
InputRegistryType string
SSHQuiet bool
}

func (c *BootstrapGcpCmd) RunE(_ *cobra.Command, args []string) error {

err := c.BootstrapGcp()
if err != nil {
return fmt.Errorf("failed to bootstrap: %w", err)
Expand All @@ -49,7 +51,7 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
},
Opts: opts,
Env: env.NewEnv(),
CodesphereEnv: &bootstrap.CodesphereEnvironment{},
CodesphereEnv: &gcp.CodesphereEnvironment{},
}

flags := bootstrapGcpCmd.cmd.Flags()
Expand All @@ -65,15 +67,16 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
flags.BoolVar(&bootstrapGcpCmd.CodesphereEnv.Preemptible, "preemptible", false, "Use preemptible VMs for Codesphere infrastructure (default: false)")
flags.IntVar(&bootstrapGcpCmd.CodesphereEnv.DatacenterID, "datacenter-id", 1, "Datacenter ID (default: 1)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.CustomPgIP, "custom-pg-ip", "", "Custom PostgreSQL IP (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallConfig, "install-config", "config.yaml", "Path to install config file (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.SecretsFile, "secrets-file", "prod.vault.yaml", "Path to secrets files (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallConfigPath, "install-config", "config.yaml", "Path to install config file (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.SecretsFilePath, "secrets-file", "prod.vault.yaml", "Path to secrets files (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.Region, "region", "europe-west4", "GCP Region (default: europe-west4)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.Zone, "zone", "europe-west4-a", "GCP Zone (default: europe-west4-a)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.DNSProjectID, "dns-project-id", "", "GCP Project ID for Cloud DNS (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.DNSZoneName, "dns-zone-name", "oms-testing", "Cloud DNS Zone Name (optional)")
flags.StringVar(&bootstrapGcpCmd.CodesphereEnv.InstallCodesphereVersion, "install-codesphere-version", "", "Codesphere version to install (default: none)")
flags.StringVar(&bootstrapGcpCmd.InputRegistryType, "registry-type", "local-container", "Container registry type to use (options: local-container, artifact-registry) (default: artifact-registry)")
flags.BoolVar(&bootstrapGcpCmd.CodesphereEnv.WriteConfig, "write-config", true, "Write generated install config to file (default: true)")
flags.BoolVar(&bootstrapGcpCmd.SSHQuiet, "ssh-quiet", true, "Suppress SSH command output (default: true)")

util.MarkFlagRequired(bootstrapGcpCmd.cmd, "project-name")
util.MarkFlagRequired(bootstrapGcpCmd.cmd, "billing-account")
Expand All @@ -84,33 +87,37 @@ func AddBootstrapGcpCmd(root *cobra.Command, opts *GlobalOptions) {
}

func (c *BootstrapGcpCmd) BootstrapGcp() error {
c.CodesphereEnv.RegistryType = bootstrap.RegistryType(c.InputRegistryType)

gcpClient := bootstrap.NewGCPClient(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"))
bootstrapper, err := bootstrap.NewGCPBootstrapper(c.Env, c.CodesphereEnv, gcpClient)
ctx := c.cmd.Context()
stlog := bootstrap.NewStepLogger(false)
icg := installer.NewInstallConfigManager()
gcpClient := gcp.NewGCPClient(ctx, stlog, os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"))
fw := util.NewFilesystemWriter()
nm := node.NewNode(fw, c.CodesphereEnv.SSHPrivateKeyPath, c.SSHQuiet)

bs, err := gcp.NewGCPBootstrapper(ctx, c.Env, stlog, c.CodesphereEnv, icg, gcpClient, nm, fw)
if err != nil {
return err
}

env, err := bootstrapper.Bootstrap()
envBytes, err2 := json.MarshalIndent(env, "", " ")
c.CodesphereEnv.RegistryType = gcp.RegistryType(c.InputRegistryType)

err = bs.Bootstrap()
envBytes, err2 := json.MarshalIndent(bs.Env, "", " ")
envString := string(envBytes)
if err2 != nil {
envString = ""
}
if err != nil {
if env.Jumpbox.ExternalIP != "" {
log.Printf("To debug on the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", env.Jumpbox.ExternalIP)
if bs.Env.Jumpbox != nil && bs.Env.Jumpbox.GetExternalIP() != "" {
log.Printf("To debug on the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", bs.Env.Jumpbox.GetExternalIP())
}
return fmt.Errorf("failed to bootstrap GCP: %w, env: %s", err, envString)
}
log.Println("GCP infrastructure bootstrapped:")

log.Println("\n🎉🎉🎉 GCP infrastructure bootstrapped successfully!")
log.Println(envString)

log.Printf("Start the Codesphere installation using OMS from the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", env.Jumpbox.ExternalIP)

log.Printf("When the installation is done, run the k0s configuration script generated at the k0s-1 host %s /root/configure-k0s.sh.", env.ControlPlaneNodes[0].InternalIP)
log.Printf("Start the Codesphere installation using OMS from the jumpbox host:\nssh-add $SSH_KEY_PATH; ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o SendEnv=OMS_PORTAL_API_KEY root@%s", bs.Env.Jumpbox.GetExternalIP())
log.Printf("When the installation is done, run the k0s configuration script generated at the k0s-1 host %s /root/configure-k0s.sh.", bs.Env.ControlPlaneNodes[0].GetInternalIP())

return err
}
1 change: 1 addition & 0 deletions docs/oms-cli_beta_bootstrap-gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ oms-cli beta bootstrap-gcp [flags]
--secrets-file string Path to secrets files (optional) (default "prod.vault.yaml")
--ssh-private-key-path string SSH Private Key Path (default: ~/.ssh/id_rsa) (default "~/.ssh/id_rsa")
--ssh-public-key-path string SSH Public Key Path (default: ~/.ssh/id_rsa.pub) (default "~/.ssh/id_rsa.pub")
--ssh-quiet Suppress SSH command output (default: true) (default true)
--write-config Write generated install config to file (default: true) (default true)
--zone string GCP Zone (default: europe-west4-a) (default "europe-west4-a")
```
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
cloud.google.com/go/iam v1.5.3
cloud.google.com/go/resourcemanager v1.10.7
cloud.google.com/go/serviceusage v1.9.7
github.com/codesphere-cloud/cs-go v0.16.1
github.com/codesphere-cloud/cs-go v0.16.2
github.com/creativeprojects/go-selfupdate v1.5.2
github.com/jedib0t/go-pretty/v6 v6.7.8
github.com/lithammer/shortuuid v3.0.0+incompatible
Expand All @@ -34,8 +34,8 @@ require (
cloud.google.com/go/auth v0.18.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/kms v1.23.2 // indirect
cloud.google.com/go/longrunning v0.7.0 // indirect
cloud.google.com/go/kms v1.25.0 // indirect
cloud.google.com/go/longrunning v0.8.0 // indirect
cloud.google.com/go/monitoring v1.24.3 // indirect
cloud.google.com/go/storage v1.58.0 // indirect
code.gitea.io/sdk/gitea v0.22.1 // indirect
Expand Down Expand Up @@ -177,7 +177,6 @@ require (
github.com/daixiang0/gci v0.13.7 // indirect
github.com/dave/dst v0.27.3 // indirect
github.com/davidmz/go-pageant v1.0.2 // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/dghubble/go-twitter v0.0.0-20221104224141-912508c3888b // indirect
github.com/dghubble/oauth1 v0.7.3 // indirect
github.com/dghubble/sling v1.4.2 // indirect
Expand Down Expand Up @@ -258,7 +257,6 @@ require (
github.com/golangci/asciicheck v0.5.0 // indirect
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
github.com/golangci/go-printf-func-name v0.1.1 // indirect
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/golangci/golangci-lint/v2 v2.8.0 // indirect
github.com/golangci/golines v0.14.0 // indirect
github.com/golangci/misspell v0.7.0 // indirect
Expand Down Expand Up @@ -471,7 +469,7 @@ require (
github.com/ykadowak/zerologlint v0.1.5 // indirect
gitlab.com/bosi/decorder v0.4.2 // indirect
gitlab.com/digitalxero/go-conventional-commit v1.0.7 // indirect
gitlab.com/gitlab-org/api/client-go v1.11.0 // indirect
gitlab.com/gitlab-org/api/client-go v1.24.0 // indirect
go-simpler.org/musttag v0.14.0 // indirect
go-simpler.org/sloglint v0.11.1 // indirect
go.augendre.info/arangolint v0.3.1 // indirect
Expand All @@ -496,9 +494,9 @@ require (
golang.org/x/exp/typeparams v0.0.0-20251219203646-944ab1f22d93 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260122232226-8e98ce8d340d // indirect
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/mail.v2 v2.3.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand All @@ -514,11 +512,13 @@ require (
require (
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/clipperhouse/uax29/v2 v2.4.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.2.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
Expand Down
Loading