Skip to content

Commit

Permalink
Squashed 'hack/libbuild/' changes from 8aab0b38..e3dd5e8c
Browse files Browse the repository at this point in the history
e3dd5e8c Add github.com/gorilla/websocket to forced dep list
daac748d Update libbuild.py
0ee25811 Update libbuild.py
8956f007 Fix call() call
020cf332 Use prometheus-operator v0.25.0
7af2c9a8 Update onessl version
6b6483c9 Add github.com/russross/blackfriday to required dep list
2a16d045 Add gopkg.in/yaml.v2 to required dep list
4e14a259 Add osm and onessl to dep list
bfe10914 Add k8s.io/cli-runtime to dep list
b7d30096 Update packgae paths during revendoring
b74b838c Update reimport map
90f1c861 Use k-1.12.0 branch for upgrading
cba2cd9c Use k-1.12 and conversion branch
f068193a Fix forked package paths
f48adcfb Upgrade to Kubernetes 1.12 (#28)
8b16b6e9 Add github.com/davecgh/go-spew to forced dep list
c930ea1e Update dep list (#30)
c3af0274 Add google.golang.org/genproto to required deps list
e417dadc Set k8s.io/kube-openapi version
9be79605 Add some deps as required deps (#29)
1de36b18 Use docker build --pull xref: appscode/discuss#90
43d3c958 Use forked client-go
d2f59a3f Add k8s.io/metrics to dep list
91a37ca4 Update commit message
c23c8744 Use go-1.11
66580929 Fix depfixer
8f5aa600 Add revendor() helper (#27)
dcff0532 Update gke version (#26)

git-subtree-dir: hack/libbuild
git-subtree-split: e3dd5e8ccb1396889f7226c29205ce4276f12428
  • Loading branch information
tamalsaha committed Dec 4, 2018
1 parent 795f7ea commit d77afdf
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 32 deletions.
2 changes: 1 addition & 1 deletion common/lib.sh
Expand Up @@ -110,7 +110,7 @@ EOL
}

build() {
local cmd="docker build -t $DOCKER_REGISTRY/$IMG:$TAG ."
local cmd="docker build --pull -t $DOCKER_REGISTRY/$IMG:$TAG ."
echo $cmd; $cmd
}

Expand Down
2 changes: 1 addition & 1 deletion concourse/cluster.sh
Expand Up @@ -236,7 +236,7 @@ if [ "${ClusterProvider}" = "gke" ]; then
CredProvider=GoogleCloud
ZONE=us-central1-f
NODE=n1-standard-2
K8S_VERSION=${K8S_VERSION:-"1.10.4-gke.2"}
K8S_VERSION=${K8S_VERSION:-"1.10.6-gke.2"}

pharmer_common
elif [ "${ClusterProvider}" = "aws" ]; then
Expand Down
2 changes: 1 addition & 1 deletion concourse/init.sh
Expand Up @@ -4,7 +4,7 @@ BASE_DIR=$(pwd)
GOPATH=$(go env GOPATH)
REPO_ROOT=${REPO_ROOT:-"$GOPATH/src/github.com/$ORG_NAME/$REPO_NAME"}
PHARMER_VERSION="0.1.0-rc.5"
ONESSL_VERSION="0.7.0"
ONESSL_VERSION="0.8.0"
ClusterProvider=$ClusterProvider

# copy $REPO_ROOT to $GOPATH
Expand Down
266 changes: 263 additions & 3 deletions libbuild.py
Expand Up @@ -10,14 +10,16 @@
import json
import os
import os.path
import random
import re
import socket
import string
import subprocess
import sys
from collections import OrderedDict
import yaml
from collections import Counter, OrderedDict
from os.path import expandvars


REPO_ROOT = ''
BIN_MATRIX = None
BUCKET_MATRIX = None
Expand Down Expand Up @@ -182,7 +184,7 @@ def go_build(name, goos, goarch, main, compress=False, upx=False):
if goos == 'alpine':
repo_dir = REPO_ROOT[len(GOPATH):]
uid = check_output('id -u').strip()
cmd = "docker run --rm -u {uid} -v /tmp:/.cache -v {repo_root}:/go{repo_dir} -w /go{repo_dir} -e {cgo_env} golang:1.9-alpine {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {tags} {main}".format(
cmd = "docker run --rm -u {uid} -v /tmp:/.cache -v {repo_root}:/go{repo_dir} -w /go{repo_dir} -e {cgo_env} golang:1.11-alpine {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {tags} {main}".format(
repo_root=REPO_ROOT,
repo_dir=repo_dir,
uid=uid,
Expand Down Expand Up @@ -338,3 +340,261 @@ def _ungroup_go_imports(fname):
f.seek(0)
f.writelines(out)
f.truncate()

def git_branch_exists(branch):
return call('git show-ref --quiet refs/heads/{0}'.format(branch), cwd=REPO_ROOT) == 0


def git_checkout(branch):
call('git fetch --all --prune', cwd=REPO_ROOT)
call('git fetch --tags', cwd=REPO_ROOT)
if git_branch_exists(branch):
call('git checkout {0}'.format(branch), cwd=REPO_ROOT)
else:
call('git checkout -b {0}'.format(branch), cwd=REPO_ROOT)


def git_requires_commit():
changed_files = check_output('git diff --name-only', cwd=REPO_ROOT).strip().split('\n')
return Counter(changed_files) != Counter(['glide.lock'])


def glide_mod(glide_config):
for x in REQUIRED_DEPS:
for idx, dep in enumerate(glide_config['import']):
found = False
if dep['package'] == x['package']:
glide_config['import'][idx] = x
found = True
break
if not found:
glide_config['import'].append(x)
for x in DEP_LIST:
for idx, dep in enumerate(glide_config['import']):
if dep['package'] == x['package']:
glide_config['import'][idx] = x
break


def glide_write(f, glide_config):
f.seek(0)
pkg = glide_config.pop('package')
out = 'package: ' + pkg + '\n' + yaml.dump(glide_config, default_flow_style=False)
f.write(out)
f.truncate()
glide_config['package'] = pkg


REQUIRED_DEPS = [
{
"package": "github.com/cpuguy83/go-md2man",
"version": "v1.0.8"
},
{
"package": "github.com/russross/blackfriday",
"version": "v1.5.2"
},
{
"package": "github.com/json-iterator/go",
"version": "1.1.5"
},
{
"package": "github.com/spf13/cobra",
"version": "v0.0.3"
},
{
"package": "github.com/spf13/pflag",
"version": "v1.0.3"
},
{
"package": "golang.org/x/text",
"version": "b19bf474d317b857955b12035d2c5acb57ce8b01"
},
{
"package": "golang.org/x/net",
"version": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"package": "golang.org/x/sys",
"version": "95c6576299259db960f6c5b9b69ea52422860fce"
},
{
"package": "golang.org/x/crypto",
"version": "de0752318171da717af4ce24d0a2e8626afaeb11"
},
{
"package": "github.com/golang/protobuf",
"version": "v1.1.0"
},
{
"package": "github.com/davecgh/go-spew",
"version": "v1.1.1"
},
{
"package": "k8s.io/kube-openapi",
"version": "0cf8f7e6ed1d2e3d47d02e3b6e559369af24d803"
},
{
"package": "gopkg.in/yaml.v2",
"version": "v2.2.1"
},
{
"package": "github.com/gorilla/websocket",
"version": "v1.4.0"
}
]
DEP_LIST = [
{
"package": "github.com/cpuguy83/go-md2man",
"version": "v1.0.8"
},
{
"package": "github.com/json-iterator/go",
"version": "1.1.5"
},
{
"package": "github.com/coreos/prometheus-operator",
"version": "v0.25.0"
},
{
"package": "k8s.io/api",
"version": "kubernetes-1.12.0"
},
{
"package": "k8s.io/apiextensions-apiserver",
"version": "kubernetes-1.12.0"
},
{
"package": "k8s.io/apimachinery",
"repo": "https://github.com/kmodules/apimachinery.git",
"vcs": "git",
"version": "ac-1.12.0"
},
{
"package": "k8s.io/apiserver",
"repo": "https://github.com/kmodules/apiserver.git",
"vcs": "git",
"version": "ac-1.12.0"
},
{
"package": "k8s.io/client-go",
"version": "v9.0.0"
},
{
"package": "k8s.io/cli-runtime",
"version": "kubernetes-1.12.0"
},
{
"package": "k8s.io/kubernetes",
"version": "v1.12.0"
},
{
"package": "k8s.io/kube-aggregator",
"version": "kubernetes-1.12.0"
},
{
"package": "k8s.io/metrics",
"version": "kubernetes-1.12.0"
},
{
"package": "github.com/appscode/kutil",
"version": "release-9.0"
},
{
"package": "github.com/appscode/kubernetes-webhook-util",
"version": "release-9.0"
},
{
"package": "kmodules.xyz/custom-resources",
"repo": "https://github.com/kmodules/custom-resources.git",
"vcs": "git",
"version": "release-9.0"
},
{
"package": "kmodules.xyz/monitoring-agent-api",
"repo": "https://github.com/kmodules/monitoring-agent-api.git",
"vcs": "git",
"version": "release-9.0"
},
{
"package": "kmodules.xyz/objectstore-api",
"repo": "https://github.com/kmodules/objectstore-api.git",
"vcs": "git",
"version": "release-9.0"
},
{
"package": "kmodules.xyz/offshoot-api",
"repo": "https://github.com/kmodules/offshoot-api.git",
"vcs": "git",
"version": "release-9.0"
},
{
"package": "kmodules.xyz/openshift",
"repo": "https://github.com/kmodules/openshift.git",
"vcs": "git",
"version": "release-9.0"
},
{
"package": "github.com/graymeta/stow",
"repo": "https://github.com/appscode/stow.git",
"vcs": "git",
"version": "master"
},
{
"package": "github.com/Azure/azure-sdk-for-go",
"version": "v19.0.0"
},
{
"package": "github.com/Azure/go-autorest",
"version": "v10.14.0"
},
{
"package": "github.com/aws/aws-sdk-go",
"version": "v1.14.12"
},
{
"package": "google.golang.org/api/storage/v1",
"version": "3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9"
},
{
"package": "cloud.google.com/go",
"version": "v0.2.0"
},
{
"package": "github.com/spf13/afero",
"version": "v1.1.2"
},
{
"package": "github.com/appscode/osm",
"version": "0.9.0"
},
{
"package": "github.com/kubepack/onessl",
"version": "0.9.0"
}
]


def revendor():
seed = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6))
revendor_branch = 'k-1.12.0'
print(REPO_ROOT)

call('git reset HEAD --hard', cwd=REPO_ROOT)
call('git clean -xfd', cwd=REPO_ROOT)
git_checkout('master')
call('git pull --rebase origin master', cwd=REPO_ROOT)
git_checkout(revendor_branch)
# https://stackoverflow.com/a/6759339/244009
call("find " + REPO_ROOT + "/apis -type f -exec sed -i -e 's/k8s.io\\/apimachinery\\/pkg\\/api\\/testing\\/roundtrip/k8s.io\\/apimachinery\\/pkg\\/api\\/apitesting\\/roundtrip/g' {} \;")
with open(REPO_ROOT + '/glide.yaml', 'r+') as glide_file:
glide_config = yaml.load(glide_file)
glide_mod(glide_config)
glide_write(glide_file, glide_config)
call('glide slow', cwd=REPO_ROOT)
if git_requires_commit():
call('git add --all', cwd=REPO_ROOT)
call('git commit -s -a -m "Update Kubernetes client libraries to 1.12.0"', cwd=REPO_ROOT)
call('git push origin {0}'.format(revendor_branch), cwd=REPO_ROOT)
else:
call('git reset HEAD --hard', cwd=REPO_ROOT)
27 changes: 1 addition & 26 deletions reimport.py
Expand Up @@ -37,32 +37,7 @@ def reimport(*paths):
END_IMPORT_REGEX = ur'\)\s*'

PKG_MAP = {
'k8s.io/kubernetes/pkg/api': ['k8s.io/client-go/pkg/api/v1', 'apiv1'],
'k8s.io/kubernetes/pkg/api/errors': ['k8s.io/apimachinery/pkg/api/errors', 'kerr'],
'k8s.io/kubernetes/pkg/api/unversioned': ['k8s.io/apimachinery/pkg/apis/meta/v1', 'metav1'],
'k8s.io/kubernetes/pkg/apimachinery/announced': ['k8s.io/apimachinery/pkg/apimachinery/announced'],
'k8s.io/kubernetes/pkg/apimachinery/registered': ['k8s.io/client-go/pkg/api', 'kapi'],
'k8s.io/kubernetes/pkg/apis/apps': ['k8s.io/client-go/pkg/apis/apps/v1beta1', 'apps'],
'k8s.io/kubernetes/pkg/apis/batch': ['k8s.io/client-go/pkg/apis/batch/v1', 'batch'],
'k8s.io/kubernetes/pkg/apis/extensions': ['k8s.io/client-go/pkg/apis/extensions/v1beta1', 'extensions'],
'k8s.io/kubernetes/pkg/apis/storage': ['k8s.io/client-go/pkg/apis/storage/v1', 'storage'],
'k8s.io/kubernetes/pkg/client/cache': ['k8s.io/client-go/tools/cache'],
'k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset': ['k8s.io/client-go/kubernetes', 'clientset'],
'k8s.io/kubernetes/pkg/client/record': ['k8s.io/client-go/tools/record'],
'k8s.io/kubernetes/pkg/client/restclient': ['k8s.io/client-go/rest'],
'k8s.io/kubernetes/pkg/client/testing/core': ['k8s.io/client-go/testing'],
'k8s.io/kubernetes/pkg/client/unversioned/clientcmd': ['k8s.io/client-go/tools/clientcmd'],
'k8s.io/kubernetes/pkg/fields': ['k8s.io/apimachinery/pkg/fields'],
'k8s.io/kubernetes/pkg/labels': ['k8s.io/apimachinery/pkg/labels'],
'k8s.io/kubernetes/pkg/runtime': ['k8s.io/apimachinery/pkg/runtime'],
'k8s.io/kubernetes/pkg/selection': ['k8s.io/apimachinery/pkg/selection'],
'k8s.io/kubernetes/pkg/types': ['k8s.io/apimachinery/pkg/types'],
'k8s.io/kubernetes/pkg/util/intstr':['k8s.io/apimachinery/pkg/util/intstr'],
'k8s.io/kubernetes/pkg/util/runtime': ['k8s.io/apimachinery/pkg/util/runtime'],
'k8s.io/kubernetes/pkg/util/sets':['k8s.io/apimachinery/pkg/util/sets'],
'k8s.io/kubernetes/pkg/util/strategicpatch': ['k8s.io/apimachinery/pkg/util/strategicpatch'],
'k8s.io/kubernetes/pkg/util/wait': ['k8s.io/apimachinery/pkg/util/wait'],
'k8s.io/kubernetes/pkg/watch': ['k8s.io/apimachinery/pkg/watch'],
'k8s.io/apimachinery/pkg/api/testing/roundtrip': ['k8s.io/apimachinery/pkg/api/apitesting/roundtrip']
}

def _detect_pkg_alias(line):
Expand Down

0 comments on commit d77afdf

Please sign in to comment.