Skip to content

Commit 9b64d4d

Browse files
Merge pull request #20385 from deads2k/oc-04-scheme
start tightening scheme usage in oc
2 parents 3d40ec5 + 9878647 commit 9b64d4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+789
-852
lines changed

cmd/oc/oc.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ import (
1010
"k8s.io/apiserver/pkg/util/logs"
1111
"k8s.io/kubernetes/pkg/kubectl/scheme"
1212

13+
"github.com/openshift/api"
14+
"github.com/openshift/api/authorization"
15+
"github.com/openshift/api/quota"
1316
"github.com/openshift/library-go/pkg/serviceability"
17+
"github.com/openshift/origin/pkg/api/install"
18+
"github.com/openshift/origin/pkg/api/legacy"
1419
"github.com/openshift/origin/pkg/oc/cli"
1520
"github.com/openshift/origin/pkg/version"
16-
17-
// install all APIs
18-
apiinstall "github.com/openshift/origin/pkg/api/install"
19-
_ "k8s.io/kubernetes/pkg/apis/autoscaling/install"
20-
_ "k8s.io/kubernetes/pkg/apis/batch/install"
21-
_ "k8s.io/kubernetes/pkg/apis/core/install"
22-
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
21+
"k8s.io/kubernetes/pkg/api/legacyscheme"
2322
)
2423

2524
func main() {
@@ -33,7 +32,17 @@ func main() {
3332
runtime.GOMAXPROCS(runtime.NumCPU())
3433
}
3534

36-
apiinstall.InstallAll(scheme.Scheme)
35+
// the kubectl scheme expects to have all the recognizable external types it needs to consume. Install those here.
36+
api.Install(scheme.Scheme)
37+
legacy.InstallExternalLegacyAll(scheme.Scheme)
38+
// TODO fix up the install for the "all types"
39+
authorization.Install(scheme.Scheme)
40+
quota.Install(scheme.Scheme)
41+
42+
// the legacyscheme is used in kubectl and expects to have the internal types registered. Explicitly wire our types here.
43+
// this does
44+
install.InstallInternalOpenShift(legacyscheme.Scheme)
45+
legacy.InstallInternalLegacyAll(scheme.Scheme)
3746

3847
basename := filepath.Base(os.Args[0])
3948
command := cli.CommandFor(basename)

cmd/openshift/openshift.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929
defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"), version.Get())()
3030
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()
3131

32-
legacy.InstallLegacyInternalAll(legacyscheme.Scheme)
32+
legacy.InstallInternalLegacyAll(legacyscheme.Scheme)
3333

3434
rand.Seed(time.Now().UTC().UnixNano())
3535
if len(os.Getenv("GOMAXPROCS")) == 0 {

examples/examples_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
)
3434

3535
func init() {
36-
legacy.InstallLegacyInternalAll(legacyscheme.Scheme)
36+
legacy.InstallInternalLegacyAll(legacyscheme.Scheme)
3737
}
3838

3939
func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error {

hack/lib/constants.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,9 @@ function os::build::check_binaries() {
341341
# enforce that certain binaries don't accidentally grow too large
342342
# IMPORTANT: contact Clayton or another master team member before altering this code
343343
if [[ -f "${OS_OUTPUT_BINPATH}/${platform}/oc" ]]; then
344-
if [[ "$(du -m "${OS_OUTPUT_BINPATH}/${platform}/oc" | cut -f 1)" -gt "115" ]]; then
345-
os::log::fatal "oc binary has grown substantially. You must have approval before bumping this limit."
344+
ocsize=$(du -m "${OS_OUTPUT_BINPATH}/${platform}/oc" | cut -f 1)
345+
if [[ "${ocsize}" -gt "116" ]]; then
346+
os::log::fatal "oc binary has grown substantially to ${ocsize}. You must have approval before bumping this limit."
346347
fi
347348
fi
348349
if [[ -f "${OS_OUTPUT_BINPATH}/${platform}/openshift-node-config" ]]; then

hack/lib/start.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -522,15 +522,11 @@ function os::start::internal::openshift_executable() {
522522

523523
openshift_executable="${sudo} docker run ${docker_options} ${volumes} ${envvars} openshift/origin:${version}"
524524
else
525-
local envvars=""
526-
if [[ -n "${ENV:-}" ]]; then
527-
envvars="env "
528-
for envvar in "${ENV[@]}"; do
529-
envvars+="${envvar} "
530-
done
531-
fi
532-
533-
openshift_executable="${sudo} ${envvars} $(which openshift)"
525+
if [[ -n "${sudo}" ]]; then
526+
openshift_executable="${sudo} -E $(which openshift)"
527+
else
528+
openshift_executable="$(which openshift)"
529+
fi
534530
fi
535531

536532
echo "${openshift_executable}"

0 commit comments

Comments
 (0)