Skip to content

Commit

Permalink
Build with go 1.16, add arm64 binaries for linux and mac (#304)
Browse files Browse the repository at this point in the history
* Upgrade go to 1.16

* Replace ioutil with 1.16 packages

* Build darwin and linux arm64

* Not io.ReadFile but os.ReadFile

* Dummy readme change to trigger build

* More io=>os

* Readdir has changed

* Copypaste fail
  • Loading branch information
kke authored May 11, 2021
1 parent 5206e61 commit b2f6bf5
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15
FROM golang:1.16

RUN apt-get update && apt-get install -y golint

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ build: $(TARGET)

build-all: builder
GOOS=linux GOARCH=amd64 $(GO) go build $(BUILD_FLAGS) -o bin/launchpad-linux-x64 main.go
GOOS=linux GOARCH=arm64 $(GO) go build $(BUILD_FLAGS) -o bin/launchpad-linux-arm64 main.go
GOOS=windows GOARCH=amd64 $(GO) go build $(BUILD_FLAGS) -o bin/launchpad-win-x64.exe main.go
GOOS=darwin GOARCH=amd64 $(GO) go build $(BUILD_FLAGS) -o bin/launchpad-darwin-x64 main.go
GOOS=darwin GOARCH=arm64 $(GO) go build $(BUILD_FLAGS) -o bin/launchpad-darwin-arm64 main.go

release: build-all
./release.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> The Next Generation Mirantis Cluster Installer & Lifecycle Management Tool
The purpose of `launchpad` is to provide amazing new user experience for anyone interested in getting started with cluster products. It will simplify the complex installation processes and provides "from zero to hero" experience in less than 5mins for IT admin / DevOps people who are experienced with various command line tools and cloud technologies. In addition, it'll provide functionality to upgrade existing clusters to new versions with no downtime or service interruptions (high availability clusters). In the future, more functionality may be added.
The purpose of `launchpad` is to provide an amazing new user experience for anyone interested in getting started with cluster products. It will simplify the complex installation processes and provides "from zero to hero" experience in less than 5mins for IT admin / DevOps people who are experienced with various command line tools and cloud technologies. In addition, it'll provide functionality to upgrade existing clusters to new versions with no downtime or service interruptions (high availability clusters). In the future, more functionality may be added.

See the public Github repo for getting started instructions, documentation and more at https://github.com/mirantis/launchpad.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Mirantis/mcc

go 1.15
go 1.16

require (
github.com/AlecAivazis/survey/v2 v2.0.7
Expand Down
4 changes: 2 additions & 2 deletions pkg/analytics/analytics.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package analytics

import (
"io/ioutil"
"io"
logger "log"
"runtime"

Expand Down Expand Up @@ -51,7 +51,7 @@ func init() {

// NewSegmentClient returns a Segment client for uploading analytics data.
func NewSegmentClient(segmentToken string) (Analytics, error) {
segmentLogger := analytics.StdLogger(logger.New(ioutil.Discard, "segment ", logger.LstdFlags))
segmentLogger := analytics.StdLogger(logger.New(io.Discard, "segment ", logger.LstdFlags))
segmentConfig := analytics.Config{
Logger: segmentLogger,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -97,7 +97,7 @@ func resolveClusterFile(clusterFile string) ([]byte, error) {
stat, err := os.Stdin.Stat()
if err == nil {
if (stat.Mode() & os.ModeCharDevice) == 0 {
return ioutil.ReadAll(os.Stdin)
return io.ReadAll(os.Stdin)
}
}

Expand All @@ -110,7 +110,7 @@ func resolveClusterFile(clusterFile string) ([]byte, error) {
return nil, err
}

return ioutil.ReadAll(file)
return io.ReadAll(file)
}

func openClusterFile(clusterFile string) (*os.File, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/config/user/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package user

import (
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -62,7 +61,7 @@ func SaveConfig(config *Config) error {
if err != nil {
return err
}
err = ioutil.WriteFile(configFile, d, 0644)
err = os.WriteFile(configFile, d, 0644)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/mke/mke.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/json"
"encoding/pem"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -99,7 +99,7 @@ func GetClientBundle(mkeURL *url.URL, tlsConfig *tls.Config, username, password
log.Debugf("Failed to get bundle: %v", err)
return nil, err
}
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != http.StatusOK {
if err == nil {
Expand Down Expand Up @@ -127,7 +127,7 @@ func GetToken(client *http.Client, mkeURL *url.URL, username, password string) (
log.Debugf("Failed to POST %s: %v", mkeURL.String(), err)
return "", err
}
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode == 200 {
var authToken AuthToken
Expand Down
7 changes: 3 additions & 4 deletions pkg/product/mke/api/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"encoding/json"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -31,7 +30,7 @@ import (
)

func TestHostRequireManagerValidationPass(t *testing.T) {
kf, _ := ioutil.TempFile("", "testkey")
kf, _ := os.CreateTemp("", "testkey")
defer kf.Close()
data := `
apiVersion: "launchpad.mirantis.com/mke/v1.4"
Expand All @@ -55,7 +54,7 @@ spec:
}

func TestHostRequireManagerValidationFail(t *testing.T) {
kf, _ := ioutil.TempFile("", "testkey")
kf, _ := os.CreateTemp("", "testkey")
defer kf.Close()
data := `
apiVersion: "launchpad.mirantis.com/mke/v1.4"
Expand Down Expand Up @@ -406,7 +405,7 @@ spec:
}

func TestValidationWithMSRRole(t *testing.T) {
kf, _ := ioutil.TempFile("", "testkey")
kf, _ := os.CreateTemp("", "testkey")
defer kf.Close()
t.Run("the role is not ucp, worker or msr", func(t *testing.T) {
data := `
Expand Down
4 changes: 2 additions & 2 deletions pkg/product/mke/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mke

import (
"fmt"
"io/ioutil"
"io"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -134,7 +134,7 @@ func (p *MKE) Exec(targets []string, interactive, first, all, parallel bool, rol
if interactive {
return fmt.Errorf("--interactive given but there's piped data in stdin")
}
data, err := ioutil.ReadAll(os.Stdin)
data, err := io.ReadAll(os.Stdin)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/product/mke/phase/download_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package phase
import (
"archive/zip"
"fmt"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -88,7 +88,7 @@ func (p *DownloadBundle) writeBundle(bundleDir string, bundle *zip.Reader) error
}
defer src.Close()
var data []byte
data, err = ioutil.ReadAll(src)
data, err = io.ReadAll(src)
if err != nil {
return err
}
Expand All @@ -105,7 +105,7 @@ func (p *DownloadBundle) writeBundle(bundleDir string, bundle *zip.Reader) error
}
}

err = ioutil.WriteFile(filepath.Join(bundleDir, zf.Name), data, os.FileMode(mode))
err = os.WriteFile(filepath.Join(bundleDir, zf.Name), data, os.FileMode(mode))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/product/mke/phase/remove_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package phase
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -299,7 +299,7 @@ func (p *RemoveNodes) getReplicaIDFromHostname(config *api.ClusterConfig, h *api
}

var containersResponse []dockerContainer
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/product/mke/phase/upload_images.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package phase

import (
"io/ioutil"
"os"
"path"
"path/filepath"

Expand Down Expand Up @@ -32,25 +32,28 @@ func (p *LoadImages) HostFilterFunc(h *api.Host) bool {
}
log.Debugf("%s: listing images in imageDir '%s'", h, h.ImageDir)

files, err := ioutil.ReadDir(h.ImageDir)
files, err := os.ReadDir(h.ImageDir)
if err != nil {
log.Errorf("%s: failed to list images in imageDir '%s': %s", h, h.ImageDir, err.Error())
return false
}

for _, info := range files {
if info.IsDir() {
for _, entry := range files {
if entry.IsDir() {
continue
}

ext := filepath.Ext(info.Name())
ext := filepath.Ext(entry.Name())
if ext != ".tar" && ext != ".gz" {
continue
}

imagePath := filepath.Join(h.ImageDir, info.Name())
imagePath := filepath.Join(h.ImageDir, entry.Name())
h.Metadata.ImagesToUpload = append(h.Metadata.ImagesToUpload, imagePath)
h.Metadata.TotalImageBytes += uint64(info.Size())
info, err := entry.Info()
if err == nil {
h.Metadata.TotalImageBytes += uint64(info.Size())
}
}

return h.Metadata.TotalImageBytes > 0
Expand Down
3 changes: 1 addition & 2 deletions pkg/product/mke/phase/validate_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package phase
import (
"fmt"
"io"
"io/ioutil"
"os"
"strings"

Expand Down Expand Up @@ -60,7 +59,7 @@ func (p *ValidateHosts) formatErrors() error {
}

func (p *ValidateHosts) validateHostConnection() error {
f, err := ioutil.TempFile("", "uploadTest")
f, err := os.CreateTemp("", "uploadTest")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package util

import (
"fmt"
"io/ioutil"
"os"
"strings"
)

Expand All @@ -11,7 +11,7 @@ import (
// SetupLicenseFile reads the license file and returns a license string command
// flag to be used with MSR and MKE installers
func SetupLicenseFile(licenseFilePath string) (string, error) {
license, err := ioutil.ReadFile(licenseFilePath)
license, err := os.ReadFile(licenseFilePath)
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package util

import (
"fmt"
"io/ioutil"
"os"

"github.com/mitchellh/go-homedir"
Expand All @@ -26,7 +25,7 @@ var LoadExternalFile = func(path string) ([]byte, error) {
return []byte{}, err
}

filedata, err := ioutil.ReadFile(realpath)
filedata, err := os.ReadFile(realpath)
if err != nil {
return []byte{}, err
}
Expand Down
6 changes: 3 additions & 3 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package version
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"runtime"
"sort"
Expand Down Expand Up @@ -109,7 +109,7 @@ func latestTag(timeout time.Duration) string {
log.Debugf("%s returned http %d", baseMsg, resp.StatusCode)
return "" // ignore backend failures
}
body, readErr := ioutil.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
log.Debugf("%s failed to read body: %s", baseMsg, err.Error())
return "" // ignore reading errors
Expand Down Expand Up @@ -173,7 +173,7 @@ func GetLatest(timeout time.Duration) *LaunchpadRelease {
log.Debugf("%s returned http %d", baseMsg, resp.StatusCode)
return nil // ignore backend failures
}
body, readErr := ioutil.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
log.Debugf("%s failed to read body: %s", baseMsg, err.Error())
return nil // ignore reading errors
Expand Down

0 comments on commit b2f6bf5

Please sign in to comment.