Unverified Commit 03320c14 authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #73985 from BenTheElder/manual-vendor

mark vendor build targets manual
parents 4734e4bf 14ff4625
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"GodepVersion": "v80-k8s-r1", "GodepVersion": "v80-k8s-r1",
"Packages": [ "Packages": [
"github.com/bazelbuild/bazel-gazelle/cmd/gazelle", "github.com/bazelbuild/bazel-gazelle/cmd/gazelle",
"github.com/bazelbuild/buildtools/buildozer",
"github.com/cespare/prettybench", "github.com/cespare/prettybench",
"github.com/client9/misspell/cmd/misspell", "github.com/client9/misspell/cmd/misspell",
"github.com/cloudflare/cfssl/cmd/cfssl", "github.com/cloudflare/cfssl/cmd/cfssl",
...@@ -472,16 +473,51 @@ ...@@ -472,16 +473,51 @@
"Rev": "c728ce9f663e2bff26361ba5978ec5c9e6816a3c" "Rev": "c728ce9f663e2bff26361ba5978ec5c9e6816a3c"
}, },
{ {
"ImportPath": "github.com/bazelbuild/buildtools/api_proto",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/build", "ImportPath": "github.com/bazelbuild/buildtools/build",
"Comment": "0.6.0-60-g1a9c38e0df9397", "Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
}, },
{ {
"ImportPath": "github.com/bazelbuild/buildtools/build_proto",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/buildozer",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/edit",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/file",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/lang",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/bazelbuild/buildtools/tables", "ImportPath": "github.com/bazelbuild/buildtools/tables",
"Comment": "0.6.0-60-g1a9c38e0df9397", "Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f" "Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
}, },
{ {
"ImportPath": "github.com/bazelbuild/buildtools/wspace",
"Comment": "0.6.0-60-g1a9c38e0df9397",
"Rev": "1a9c38e0df9397d033a1ca535596de5a7c1cf18f"
},
{
"ImportPath": "github.com/beorn7/perks/quantile", "ImportPath": "github.com/beorn7/perks/quantile",
"Rev": "3ac7bf7a47d159a033b107610db8a1b6575507a4" "Rev": "3ac7bf7a47d159a033b107610db8a1b6575507a4"
}, },
......
...@@ -14962,6 +14962,27 @@ THE SOFTWARE. ...@@ -14962,6 +14962,27 @@ THE SOFTWARE.
================================================================================ ================================================================================
= vendor/github.com/bazelbuild/buildtools/api_proto licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/build licensed under: = = vendor/github.com/bazelbuild/buildtools/build licensed under: =
Copyright 2016 Google Inc. All Rights Reserved. Copyright 2016 Google Inc. All Rights Reserved.
...@@ -14983,6 +15004,111 @@ limitations under the License. ...@@ -14983,6 +15004,111 @@ limitations under the License.
================================================================================ ================================================================================
= vendor/github.com/bazelbuild/buildtools/buildozer licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/build_proto licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/edit licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/file licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/lang licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/bazelbuild/buildtools/tables licensed under: = = vendor/github.com/bazelbuild/buildtools/tables licensed under: =
Copyright 2016 Google Inc. All Rights Reserved. Copyright 2016 Google Inc. All Rights Reserved.
...@@ -15004,6 +15130,27 @@ limitations under the License. ...@@ -15004,6 +15130,27 @@ limitations under the License.
================================================================================ ================================================================================
= vendor/github.com/bazelbuild/buildtools/wspace licensed under: =
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
= vendor/github.com/bazelbuild/buildtools/LICENSE adb52eb384caedba181cd51fbcdf4b99
================================================================================
================================================================================
= vendor/github.com/beorn7/perks/quantile licensed under: = = vendor/github.com/beorn7/perks/quantile licensed under: =
Copyright (C) 2013 Blake Mizerany Copyright (C) 2013 Blake Mizerany
...@@ -56,6 +56,7 @@ fi ...@@ -56,6 +56,7 @@ fi
# won't pick them up. # won't pick them up.
REQUIRED_BINS=( REQUIRED_BINS=(
"github.com/bazelbuild/bazel-gazelle/cmd/gazelle" "github.com/bazelbuild/bazel-gazelle/cmd/gazelle"
"github.com/bazelbuild/buildtools/buildozer"
"github.com/cespare/prettybench" "github.com/cespare/prettybench"
"github.com/client9/misspell/cmd/misspell" "github.com/client9/misspell/cmd/misspell"
"github.com/cloudflare/cfssl/cmd/cfssl" "github.com/cloudflare/cfssl/cmd/cfssl"
......
...@@ -26,6 +26,7 @@ PATH="${GOBIN}:${PATH}" ...@@ -26,6 +26,7 @@ PATH="${GOBIN}:${PATH}"
# Install tools we need, but only from vendor/... # Install tools we need, but only from vendor/...
go install k8s.io/kubernetes/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle go install k8s.io/kubernetes/vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle
go install k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/buildozer
go install k8s.io/kubernetes/vendor/k8s.io/repo-infra/kazel go install k8s.io/kubernetes/vendor/k8s.io/repo-infra/kazel
touch "${KUBE_ROOT}/vendor/BUILD" touch "${KUBE_ROOT}/vendor/BUILD"
...@@ -43,3 +44,11 @@ gazelle fix \ ...@@ -43,3 +44,11 @@ gazelle fix \
"${KUBE_ROOT}" "${KUBE_ROOT}"
kazel kazel
# make targets in vendor manual
# buildozer exits 3 when no changes are made ¯\_(ツ)_/¯
# https://github.com/bazelbuild/buildtools/tree/master/buildozer#error-code
buildozer -quiet 'add tags manual' '//vendor/...:%go_binary' '//vendor/...:%go_test' && ret=$? || ret=$?
if [[ $ret != 0 && $ret != 3 ]]; then
exit 1
fi
...@@ -12,8 +12,8 @@ go_test( ...@@ -12,8 +12,8 @@ go_test(
name = "go_default_test", name = "go_default_test",
srcs = ["crd_test.go"], srcs = ["crd_test.go"],
data = [ data = [
":csi-manifests",
"//cluster/addons:addon-srcs", "//cluster/addons:addon-srcs",
"//staging/src/k8s.io/csi-api/pkg/crd:manifests",
], ],
embed = [":go_default_library"], embed = [":go_default_library"],
deps = ["//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library"], deps = ["//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library"],
...@@ -28,9 +28,7 @@ filegroup( ...@@ -28,9 +28,7 @@ filegroup(
filegroup( filegroup(
name = "csi-manifests", name = "csi-manifests",
srcs = [ srcs = glob(["manifests/**"]),
"//staging/src/k8s.io/csi-api/pkg/crd:manifests",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -65,8 +65,15 @@ filegroup( ...@@ -65,8 +65,15 @@ filegroup(
"//vendor/github.com/bazelbuild/bazel-gazelle/internal/version:all-srcs", "//vendor/github.com/bazelbuild/bazel-gazelle/internal/version:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/internal/walk:all-srcs", "//vendor/github.com/bazelbuild/bazel-gazelle/internal/walk:all-srcs",
"//vendor/github.com/bazelbuild/bazel-gazelle/internal/wspace:all-srcs", "//vendor/github.com/bazelbuild/bazel-gazelle/internal/wspace:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/api_proto:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/build:all-srcs", "//vendor/github.com/bazelbuild/buildtools/build:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/build_proto:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/buildozer:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/edit:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/file:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/lang:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/tables:all-srcs", "//vendor/github.com/bazelbuild/buildtools/tables:all-srcs",
"//vendor/github.com/bazelbuild/buildtools/wspace:all-srcs",
"//vendor/github.com/beorn7/perks/quantile:all-srcs", "//vendor/github.com/beorn7/perks/quantile:all-srcs",
"//vendor/github.com/blang/semver:all-srcs", "//vendor/github.com/blang/semver:all-srcs",
"//vendor/github.com/cespare/prettybench:all-srcs", "//vendor/github.com/cespare/prettybench:all-srcs",
......
...@@ -35,6 +35,7 @@ go_library( ...@@ -35,6 +35,7 @@ go_library(
go_binary( go_binary(
name = "gazelle", name = "gazelle",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["api.gen.pb.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/api_proto",
importpath = "github.com/bazelbuild/buildtools/api_proto",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/golang/protobuf/proto:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
syntax = "proto3";
package devtools.buildozer;
message Output {
repeated Record records = 1;
message Record {
repeated Field fields = 1;
message Field {
oneof value {
string text = 1;
int32 number = 2;
ERROR error = 3;
RepeatedString list = 5;
}
// Used internally by Buildozer to decide whether a field should be quoted
// when printing. This does not affect the contents of 'value'.
bool quote_when_printing = 7;
enum ERROR {
UNKNOWN = 0;
MISSING = 1;
}
}
}
}
message RepeatedString {
repeated string strings = 1;
}
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["build.gen.pb.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/build_proto",
importpath = "github.com/bazelbuild/buildtools/build_proto",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/golang/protobuf/proto:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_library(
name = "go_default_library",
srcs = ["main.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/buildozer",
importpath = "github.com/bazelbuild/buildtools/buildozer",
visibility = ["//visibility:private"],
deps = [
"//vendor/github.com/bazelbuild/buildtools/edit:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/tables:go_default_library",
],
)
go_binary(
name = "buildozer",
embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Entry-point for Buildozer binary.
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/bazelbuild/buildtools/edit"
"github.com/bazelbuild/buildtools/tables"
)
var (
stdout = flag.Bool("stdout", false, "write changed BUILD file to stdout")
buildifier = flag.String("buildifier", "", "format output using a specific buildifier binary. If empty, use built-in formatter")
parallelism = flag.Int("P", 0, "number of cores to use for concurrent actions")
numio = flag.Int("numio", 200, "number of concurrent actions")
commandsFile = flag.String("f", "", "file name to read commands from, use '-' for stdin (format:|-separated command line arguments to buildozer, excluding flags)")
keepGoing = flag.Bool("k", false, "apply all commands, even if there are failures")
filterRuleTypes = stringList("types", "comma-separated list of rule types to change, the default empty list means all rules")
preferEOLComments = flag.Bool("eol-comments", true, "when adding a new comment, put it on the same line if possible")
rootDir = flag.String("root_dir", "", "If present, use this folder rather than $PWD to find the root directory.")
quiet = flag.Bool("quiet", false, "suppress informational messages")
editVariables = flag.Bool("edit-variables", false, "For attributes that simply assign a variable (e.g. hdrs = LIB_HDRS), edit the build variable instead of appending to the attribute.")
isPrintingProto = flag.Bool("output_proto", false, "output serialized devtools.buildozer.Output protos instead of human-readable strings.")
tablesPath = flag.String("tables", "", "path to JSON file with custom table definitions which will replace the built-in tables")
shortenLabelsFlag = flag.Bool("shorten_labels", true, "convert added labels to short form, e.g. //foo:bar => :bar")
deleteWithComments = flag.Bool("delete_with_comments", true, "If a list attribute should be deleted even if there is a comment attached to it")
)
func stringList(name, help string) func() []string {
f := flag.String(name, "", help)
return func() []string {
if *f == "" {
return nil
}
res := strings.Split(*f, ",")
for i := range res {
res[i] = strings.TrimSpace(res[i])
}
return res
}
}
func main() {
flag.Parse()
if *tablesPath != "" {
if err := tables.ParseAndUpdateJSONDefinitions(*tablesPath, false); err != nil {
fmt.Fprintf(os.Stderr, "buildifier: failed to parse %s for -tables: %s\n", *tablesPath, err)
os.Exit(2)
}
}
edit.ShortenLabelsFlag = *shortenLabelsFlag
edit.DeleteWithComments = *deleteWithComments
edit.Opts = edit.Options{
Stdout: *stdout,
Buildifier: *buildifier,
Parallelism: *parallelism,
NumIO: *numio,
CommandsFile: *commandsFile,
KeepGoing: *keepGoing,
FilterRuleTypes: filterRuleTypes(),
PreferEOLComments: *preferEOLComments,
RootDir: *rootDir,
Quiet: *quiet,
EditVariables: *editVariables,
IsPrintingProto: *isPrintingProto,
}
os.Exit(edit.Buildozer(flag.Args()))
}
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"buildozer.go",
"edit.go",
"fix.go",
"types.go",
],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/edit",
importpath = "github.com/bazelbuild/buildtools/edit",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/bazelbuild/buildtools/api_proto:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/build:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/build_proto:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/file:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/lang:go_default_library",
"//vendor/github.com/bazelbuild/buildtools/wspace:go_default_library",
"//vendor/github.com/golang/protobuf/proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Type information for attributes.
package edit
import (
buildpb "github.com/bazelbuild/buildtools/build_proto"
"github.com/bazelbuild/buildtools/lang"
)
var typeOf = lang.TypeOf
// IsList returns true for all attributes whose type is a list.
func IsList(attr string) bool {
ty := typeOf[attr]
return ty == buildpb.Attribute_STRING_LIST ||
ty == buildpb.Attribute_LABEL_LIST ||
ty == buildpb.Attribute_OUTPUT_LIST ||
ty == buildpb.Attribute_FILESET_ENTRY_LIST ||
ty == buildpb.Attribute_INTEGER_LIST ||
ty == buildpb.Attribute_LICENSE ||
ty == buildpb.Attribute_DISTRIBUTION_SET
}
// IsIntList returns true for all attributes whose type is an int list.
func IsIntList(attr string) bool {
return typeOf[attr] == buildpb.Attribute_INTEGER_LIST
}
// IsString returns true for all attributes whose type is a string or a label.
func IsString(attr string) bool {
ty := typeOf[attr]
return ty == buildpb.Attribute_LABEL ||
ty == buildpb.Attribute_STRING ||
ty == buildpb.Attribute_OUTPUT
}
// IsStringDict returns true for all attributes whose type is a string dictionary.
func IsStringDict(attr string) bool {
return typeOf[attr] == buildpb.Attribute_STRING_DICT
}
// ContainsLabels returns true for all attributes whose type is a label or a label list.
func ContainsLabels(attr string) bool {
ty := typeOf[attr]
return ty == buildpb.Attribute_LABEL_LIST ||
ty == buildpb.Attribute_LABEL
}
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["file.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/file",
importpath = "github.com/bazelbuild/buildtools/file",
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package file provides utility file operations.
package file
import (
"fmt"
"io"
"io/ioutil"
"os"
)
// ReadFile is like ioutil.ReadFile.
func ReadFile(name string) ([]byte, os.FileInfo, error) {
fi, err := os.Stat(name)
if err != nil {
return nil, nil, err
}
data, err := ioutil.ReadFile(name)
return data, fi, err
}
// WriteFile is like ioutil.WriteFile
func WriteFile(name string, data []byte) error {
return ioutil.WriteFile(name, data, 0644)
}
// OpenReadFile is like os.Open.
func OpenReadFile(name string) io.ReadCloser {
f, err := os.Open(name)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not open %s\n", name)
os.Exit(1)
}
return f
}
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["tables.gen.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/lang",
importpath = "github.com/bazelbuild/buildtools/lang",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/bazelbuild/buildtools/build_proto:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["workspace.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/bazelbuild/buildtools/wspace",
importpath = "github.com/bazelbuild/buildtools/wspace",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/bazelbuild/buildtools/build:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package wspace provides a method to find the root of the bazel tree.
package wspace
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/bazelbuild/buildtools/build"
)
const workspaceFile = "WORKSPACE"
func alwaysTrue(fi os.FileInfo) bool {
return true
}
var repoRootFiles = map[string]func(os.FileInfo) bool{
workspaceFile: alwaysTrue,
".buckconfig": alwaysTrue,
"pants": func(fi os.FileInfo) bool {
return fi.Mode()&os.ModeType == 0 && fi.Mode()&0100 == 0100
},
}
// findContextPath finds the context path inside of a WORKSPACE-rooted source tree.
func findContextPath(rootDir string) (string, error) {
if rootDir == "" {
return os.Getwd()
}
return rootDir, nil
}
// FindWorkspaceRoot splits the current code context (the rootDir if present,
// the working directory if not.) It returns the path of the directory
// containing the WORKSPACE file, and the rest.
func FindWorkspaceRoot(rootDir string) (root string, rest string) {
wd, err := findContextPath(rootDir)
if err != nil {
return "", ""
}
if root, err = Find(wd); err != nil {
return "", ""
}
if len(wd) == len(root) {
return root, ""
}
return root, wd[len(root)+1:]
}
// Find searches from the given dir and up for the WORKSPACE file
// returning the directory containing it, or an error if none found in the tree.
func Find(dir string) (string, error) {
if dir == "" || dir == "/" || dir == "." {
return "", os.ErrNotExist
}
for repoRootFile, fiFunc := range repoRootFiles {
if fi, err := os.Stat(filepath.Join(dir, repoRootFile)); err == nil && fiFunc(fi) {
return dir, nil
} else if !os.IsNotExist(err) {
return "", err
}
}
return Find(filepath.Dir(dir))
}
// FindRepoBuildFiles parses the WORKSPACE to find BUILD files for non-Bazel
// external repositories, specifically those defined by one of these rules:
// new_local_repository(), new_git_repository(), new_http_archive()
func FindRepoBuildFiles(root string) (map[string]string, error) {
ws := filepath.Join(root, workspaceFile)
kinds := []string{
"new_local_repository",
"new_git_repository",
"new_http_archive",
}
data, err := ioutil.ReadFile(ws)
if err != nil {
return nil, err
}
ast, err := build.Parse(ws, data)
if err != nil {
return nil, err
}
files := make(map[string]string)
for _, kind := range kinds {
for _, r := range ast.Rules(kind) {
buildFile := r.AttrString("build_file")
if buildFile == "" {
continue
}
buildFile = strings.Replace(buildFile, ":", "/", -1)
files[r.Name()] = filepath.Join(root, buildFile)
}
}
return files, nil
}
...@@ -12,6 +12,7 @@ go_library( ...@@ -12,6 +12,7 @@ go_library(
go_binary( go_binary(
name = "prettybench", name = "prettybench",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -12,6 +12,7 @@ go_library( ...@@ -12,6 +12,7 @@ go_library(
go_binary( go_binary(
name = "misspell", name = "misspell",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -36,6 +36,7 @@ go_library( ...@@ -36,6 +36,7 @@ go_library(
go_binary( go_binary(
name = "cfssl", name = "cfssl",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -12,6 +12,7 @@ go_library( ...@@ -12,6 +12,7 @@ go_library(
go_binary( go_binary(
name = "cfssljson", name = "cfssljson",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -15,6 +15,7 @@ go_library( ...@@ -15,6 +15,7 @@ go_library(
go_binary( go_binary(
name = "go-junit-report", name = "go-junit-report",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -16,6 +16,7 @@ go_library( ...@@ -16,6 +16,7 @@ go_library(
go_binary( go_binary(
name = "go-bindata", name = "go-bindata",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -37,6 +37,7 @@ go_library( ...@@ -37,6 +37,7 @@ go_library(
go_binary( go_binary(
name = "ginkgo", name = "ginkgo",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -16,6 +16,7 @@ go_library( ...@@ -16,6 +16,7 @@ go_library(
go_binary( go_binary(
name = "golint", name = "golint",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -17,6 +17,7 @@ go_library( ...@@ -17,6 +17,7 @@ go_library(
go_binary( go_binary(
name = "openapi-gen", name = "openapi-gen",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
...@@ -21,6 +21,7 @@ go_library( ...@@ -21,6 +21,7 @@ go_library(
go_binary( go_binary(
name = "kazel", name = "kazel",
embed = [":go_default_library"], embed = [":go_default_library"],
tags = ["manual"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment