Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
use hub and tag from istio/pkg DockerBuildInfo (#475)
Browse files Browse the repository at this point in the history
* update go mod file

* update hub and tag to use istio.io/pkg DockerBuildInfo

* add ldflags tests for hub and tag

* set if condition to check unknow string instead of empty string

* update go.mod go.sum

* fix lint error

* run make gen to update go.sum

* add licenses update
  • Loading branch information
carolynhu authored and istio-testing committed Oct 30, 2019
1 parent 4cbf620 commit 82ada6c
Show file tree
Hide file tree
Showing 14 changed files with 767 additions and 44 deletions.
22 changes: 22 additions & 0 deletions cmd/mesh/manifest-generate_test.go
Expand Up @@ -21,6 +21,8 @@ import (
"strings"
"testing"

"istio.io/pkg/version"

"istio.io/operator/pkg/object"
"istio.io/operator/pkg/util"
)
Expand Down Expand Up @@ -150,6 +152,26 @@ func TestManifestGenerateOrdered(t *testing.T) {
})
}

// TestLDFlags checks whether building mesh command with
// -ldflags "-X istio.io/pkg/version.buildHub=myhub -X istio.io/pkg/version.buildVersion=mytag"
// results in these values showing up in a generated manifest.
func TestLDFlags(t *testing.T) {
tmpHub, tmpTag := version.DockerInfo.Hub, version.DockerInfo.Tag
defer func() {
version.DockerInfo.Hub, version.DockerInfo.Tag = tmpHub, tmpTag
}()
version.DockerInfo.Hub = "testHub"
version.DockerInfo.Tag = "testTag"
l := newLogger(true, os.Stdout, os.Stderr)
_, icps, err := genICPS("", "default", "", true, l)
if err != nil {
t.Fatal(err)
}
if icps.Hub != version.DockerInfo.Hub || icps.Tag != version.DockerInfo.Tag {
t.Fatalf("DockerInfoHub, DockerInfoTag got: %s,%s, want: %s, %s", icps.Hub, icps.Tag, version.DockerInfo.Hub, version.DockerInfo.Tag)
}
}

func runTestGroup(t *testing.T, tests testGroup) {
testDataDir = filepath.Join(repoRootDir, "cmd/mesh/testdata/manifest-generate")
for _, tt := range tests {
Expand Down
8 changes: 6 additions & 2 deletions cmd/mesh/profile-dump.go
Expand Up @@ -18,6 +18,7 @@ import (
"bytes"
"fmt"
"io/ioutil"

"text/template"

"github.com/ghodss/yaml"
Expand All @@ -32,6 +33,7 @@ import (
"istio.io/operator/pkg/util"
"istio.io/operator/pkg/validate"
binversion "istio.io/operator/version"
"istio.io/pkg/version"
)

type profileDumpArgs struct {
Expand Down Expand Up @@ -140,8 +142,10 @@ func genICPS(inFilename, profile, setOverlayYAML string, force bool, l *logger)

// Due to the fact that base profile is compiled in before a tag can be created, we must allow an additional
// override from variables that are set during release build time.
if HubValueFromBuild != "" && TagValueFromBuild != "" {
buildHubTagOverlayYAML, err := generateHubTagOverlay(HubValueFromBuild, TagValueFromBuild)
hub := version.DockerInfo.Hub
tag := version.DockerInfo.Tag
if hub != "unknown" && tag != "unknown" {
buildHubTagOverlayYAML, err := generateHubTagOverlay(hub, tag)
if err != nil {
return "", nil, err
}
Expand Down
9 changes: 0 additions & 9 deletions cmd/mesh/shared.go
Expand Up @@ -30,15 +30,6 @@ const (
logFilePath = "./.mesh-cli.log"
)

var (
// HubValueFromBuild can be set to override the hub value in the base profile. It's applied after reading base
// profile from compiled in or file-based profiles, but before the user overlay or --set flag.
HubValueFromBuild = ""
// TagValueFromBuild can be set to override the tag value in the base profile. It's applied after reading base
// profile from compiled in or file-based profiles, but before the user overlay or --set flag.
TagValueFromBuild = ""
)

func initLogsOrExit(args *rootArgs) {
if logToFile {
// Only the logs for the last command are of interest.
Expand Down
14 changes: 5 additions & 9 deletions go.mod
Expand Up @@ -6,6 +6,8 @@ replace k8s.io/klog => github.com/istio/klog v0.0.0-20190424230111-fb7481ea8bcf

replace github.com/golang/glog => github.com/istio/glog v0.0.0-20190424172949-d7cfb6fa2ccd

replace github.com/spf13/viper => github.com/istio/viper v1.3.3-0.20190515210538-2789fed3109c

require (
contrib.go.opencensus.io/exporter/ocagent v0.4.12 // indirect
github.com/Azure/go-autorest v12.0.0+incompatible // indirect
Expand All @@ -14,7 +16,6 @@ require (
github.com/aokoli/goutils v1.0.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/docker/distribution v2.7.1+incompatible
github.com/dsnet/compress v0.0.1 // indirect
github.com/evanphx/json-patch v4.5.0+incompatible
Expand All @@ -26,14 +27,10 @@ require (
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.1 // indirect
github.com/google/go-cmp v0.3.0
github.com/google/uuid v1.1.1 // indirect
github.com/google/go-cmp v0.3.1
github.com/gophercloud/gophercloud v0.0.0-20190424031112-b9b92a825806 // indirect
github.com/gorilla/mux v1.7.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.9.0 // indirect
github.com/hashicorp/go-version v1.2.0
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.7 // indirect
Expand All @@ -54,12 +51,11 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/api v0.8.0 // indirect
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
google.golang.org/grpc v1.24.0 // indirect
gopkg.in/yaml.v2 v2.2.2
istio.io/pkg v0.0.0-20190515193414-9332430ad747
gopkg.in/yaml.v2 v2.2.4
istio.io/pkg v0.0.0-20191029184635-5c2f5ef63692
k8s.io/api v0.0.0
k8s.io/apiextensions-apiserver v0.0.0
k8s.io/apimachinery v0.0.0
Expand Down

0 comments on commit 82ada6c

Please sign in to comment.