Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ jobs:

- name: Unit Tests
run: make unit-test
env:
TEST_FLAGS: -short
10 changes: 8 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters:
- contextcheck
- dupword
- durationcheck
- err113
# - err113
- errchkjson
- errname
- errorlint
Expand All @@ -38,6 +38,7 @@ linters:
- unparam
- usestdlibvars
- usetesting
- varnamelen
- wastedassign
- whitespace
- wrapcheck
Expand All @@ -54,7 +55,8 @@ linters:
- wg sync.WaitGroup
- h Host
- h os.Host
- h *api.Host
- h mkeconfig.Host
- h *mkeconfig.Host
- ok bool
- s string
exclusions:
Expand All @@ -70,6 +72,10 @@ linters:
- test/*
- logo.go
- logo_windows.go
# package names that match stdlib (user, constant, log, version) are legacy; exclude only this rule
rules:
- linters: [revive]
text: "avoid package names that conflict with Go standard library"
issues:
max-issues-per-linter: 0
max-same-issues: 0
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ lint:

# Testing related targets

# TEST_FLAGS can be set in CI to e.g. -short to skip tests that need network/OCI
TEST_FLAGS?=
.PHONY: unit-test
unit-test:
$(GO) test -v --tags 'testing' ./pkg/...
$(GO) test -v --tags 'testing' $(TEST_FLAGS) ./pkg/...

.PHONY: functional-test
functional-test:
Expand Down
7 changes: 6 additions & 1 deletion cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ func closeAnalytics(ctx *cli.Context) error {

func upgradeCheckResult(ctx *cli.Context) error {
if ctx.Command.Name != "download-launchpad" {
latest := <-upgradeChan
var latest *version.LaunchpadRelease
select {
case latest = <-upgradeChan:
case <-ctx.Done():
// Context cancelled; skip upgrade message.
}
if latest != nil {
println(fmt.Sprintf("\nA new version (%s) of `launchpad` is available. Please visit %s or run `launchpad download-launchpad` to upgrade the tool.", latest.TagName, latest.URL))
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/download_launchpad.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func NewDownloadLaunchpadCommand() *cli.Command {
if err != nil {
return fmt.Errorf("failed to create download request: %w", err)
}
resp, err := http.DefaultClient.Do(req)
// asset.URL is from GitHub API release response (trusted source)
resp, err := http.DefaultClient.Do(req) // #nosec G704
if err != nil {
return fmt.Errorf("failed to perform download request: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func NewResetCommand() *cli.Command {
Aliases: []string{"f"},
},
}...),
Before: actions(initLogger, initAnalytics, checkLicense, initExec, requireForce, startUpgradeCheck),
After: actions(closeAnalytics, upgradeCheckResult),
Before: actions(initLogger, initAnalytics, checkLicense, initExec, requireForce),
After: actions(closeAnalytics),
Action: func(ctx *cli.Context) error {
start := time.Now()
analytics.TrackEvent("Cluster Reset Started", nil)
Expand Down
86 changes: 43 additions & 43 deletions examples/terraform/aws-simple/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions examples/terraform/aws-simple/launchpad.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ variable "launchpad" {
type = object({
drain = bool

mcr_version = string
mcr_channel = string
mke_version = string
msr_version = string // unused if you have no MSR hosts

Expand Down Expand Up @@ -137,8 +137,8 @@ locals {
// ------- Ye old launchpad yaml (just for debugging)

locals {
launchpad_yaml_15 = <<-EOT
apiVersion: launchpad.mirantis.com/mke/v1.5
launchpad_yaml = <<-EOT
apiVersion: launchpad.mirantis.com/mke/v1.6
kind: mke%{if local.has_msr}+msr%{endif}
metadata:
name: ${var.name}
Expand All @@ -165,11 +165,9 @@ spec:
insecure: ${h.winrm_insecure}
%{~endfor}
mcr:
version: ${var.launchpad.mcr_version}
channel: ${var.launchpad.mcr_channel}
repoURL: https://repos.mirantis.com
installURLLinux: https://get.mirantis.com/
installURLWindows: https://get.mirantis.com/install.ps1
channel: stable-25.0
prune: true
mke:
version: ${var.launchpad.mke_version}
Expand Down Expand Up @@ -199,7 +197,7 @@ EOT
output "launchpad_yaml" {
description = "launchpad config file yaml (for debugging)"
sensitive = true
value = local.launchpad_yaml_15
value = local.launchpad_yaml
}

output "mke_connect" {
Expand Down
32 changes: 20 additions & 12 deletions examples/terraform/aws-simple/terraform.tfvars.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ aws = {
launchpad = {
drain = false

mcr_version = "25.0.13"
mcr_channel = "stable-25.0.14"
mke_version = "3.8.8"
msr_version = "2.9.28"

mke_connect = {
username = "admin"
password = "" // an MKE passwords must be provided
password = "" // an MKE password must be provided
insecure = true
}

Expand All @@ -32,7 +32,7 @@ subnets = {
"main" = {
"cidr" = "172.31.0.0/17",
"private" = false,
"nodegroups" = ["MngrA", "WrkA", "MsrA"]
"nodegroups" = ["MngrA", "Wrkubuntu", "Wrkrhel", "Wrksles"]
}
}

Expand All @@ -44,24 +44,32 @@ nodegroups = {
"type" = "m6a.2xlarge",
"volume_size" = "100",
"role" = "manager",
"user_data" = "sudo ufw allow 7946/tcp ; sudo ufw allow 10250/tcp "
"user_data" = "sudo ufw allow 2377,7946,10250/tcp; sudo ufw allow 7946,4789/udp"
},
"WrkA" = {
"platform" = "ubuntu_22.04",
"Wrkrhel" = {
"platform" = "rhel_9",
"count" = 1,
"type" = "c6a.xlarge",
"volume_size" = "100",
"role" = "worker",
"user_data" = "sudo ufw allow 7946/tcp ; sudo ufw allow 10250/tcp "
}
"MsrA" = {
"user_data" = "sudo firewall-cmd --permanent --add-port=2377/tcp --add-port=7946/tcp --add-port=7946/udp --add-port=4789/udp --add-port=10250/tcp; sudo firewall-cmd --reload"
},
"Wrkubuntu" = {
"platform" = "ubuntu_22.04",
"count" = 1,
"type" = "c6a.xlarge",
"volume_size" = "100",
"role" = "msr",
"user_data" = "sudo ufw allow 7946/tcp ; sudo ufw allow 10250/tcp "
}
"role" = "worker",
"user_data" = "sudo ufw allow 2377,7946,10250/tcp; sudo ufw allow 7946,4789/udp"
},
"Wrksles" = {
"platform" = "sles_15",
"count" = 1,
"type" = "c6a.xlarge",
"volume_size" = "100",
"role" = "worker",
"user_data" = "sudo firewall-cmd --permanent --add-port=2377/tcp --add-port=7946/tcp --add-port=7946/udp --add-port=4789/udp --add-port=10250/tcp; sudo firewall-cmd --reload"
},
}

// set a windows password, if you have windows nodes
Expand Down
20 changes: 20 additions & 0 deletions jn-todo.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
* JNesbitt informal todo list

** code-quality

*** TODO Move product/mke/api/host.go:Host.MCRConfigure to /pkg/configurer interfaces

The MCRConfigure() method likely exists on the host as a convenience, but as we have common
configurer functionality and the other MCR methods are on the configurer it doesn't belong
on the host.

Another option would be to move functionality to the /pkg/mcr package.

On top of this, the configurer.MCRConfigPath should perhaps be an accessor pair of content,
instead of a filepath. Maybe the configurer should have methods to write/read the MCR configuration.

** linting

*** general interface{} -> any replace

There are a lot of `interface{}` types declared in the code base that should be changed to `any`
2 changes: 1 addition & 1 deletion pkg/analytics/analytics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"testing"

"github.com/Mirantis/launchpad/pkg/config/user"
"github.com/stretchr/testify/require"
"github.com/segmentio/analytics-go/v3"
"github.com/stretchr/testify/require"
)

type mockClient struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/migration/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func Migrate(plain map[string]interface{}) error { //nolint:maintidx
}

func removeIndex(s []interface{}, index int) []interface{} {
ret := make([]interface{}, 0) //nolint:prealloc // we don't know how big it will need to be
ret := make([]interface{}, 0, len(s))
ret = append(ret, s[:index]...)
return append(ret, s[index+1:]...)
}
Expand Down
Loading
Loading