Add flag package to limit visibility.

PiperOrigin-RevId: 294297004
This commit is contained in:
Adin Scannell 2020-02-10 13:56:17 -08:00 committed by gVisor bot
parent a6f9361c2f
commit 3e8b38d08b
31 changed files with 72 additions and 27 deletions

View File

@ -19,6 +19,7 @@ go_binary(
"//pkg/sentry/platform",
"//runsc/boot",
"//runsc/cmd",
"//runsc/flag",
"//runsc/specutils",
"@com_github_google_subcommands//:go_default_library",
],
@ -54,6 +55,7 @@ go_binary(
"//pkg/sentry/platform",
"//runsc/boot",
"//runsc/cmd",
"//runsc/flag",
"//runsc/specutils",
"@com_github_google_subcommands//:go_default_library",
],

View File

@ -50,6 +50,7 @@ go_library(
"//runsc/boot/platforms",
"//runsc/console",
"//runsc/container",
"//runsc/flag",
"//runsc/fsgofer",
"//runsc/fsgofer/filter",
"//runsc/specutils",

View File

@ -21,12 +21,12 @@ import (
"strings"
"syscall"
"flag"
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/boot/platforms"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -20,11 +20,11 @@ import (
"path/filepath"
"syscall"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -17,10 +17,10 @@ package cmd
import (
"context"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -22,12 +22,12 @@ import (
"syscall"
"time"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/sentry/control"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Debug implements subcommands.Command for the "debug" command.

View File

@ -19,11 +19,11 @@ import (
"fmt"
"os"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Delete implements subcommands.Command for the "delete" command.

View File

@ -27,12 +27,12 @@ import (
"strings"
"syscall"
"flag"
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -20,11 +20,11 @@ import (
"os"
"time"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Events implements subcommands.Command for the "events" command.

View File

@ -27,7 +27,6 @@ import (
"syscall"
"time"
"flag"
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
"gvisor.dev/gvisor/pkg/log"
@ -37,6 +36,7 @@ import (
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/console"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -23,7 +23,6 @@ import (
"strings"
"syscall"
"flag"
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/sys/unix"
@ -32,6 +31,7 @@ import (
"gvisor.dev/gvisor/pkg/sync"
"gvisor.dev/gvisor/pkg/unet"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/fsgofer"
"gvisor.dev/gvisor/runsc/fsgofer/filter"
"gvisor.dev/gvisor/runsc/specutils"

View File

@ -18,8 +18,8 @@ import (
"context"
"fmt"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/flag"
)
// NewHelp returns a help command for the given commander.

View File

@ -23,8 +23,8 @@ import (
"os"
"path"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/flag"
)
// Install implements subcommands.Command.

View File

@ -21,11 +21,11 @@ import (
"strings"
"syscall"
"flag"
"github.com/google/subcommands"
"golang.org/x/sys/unix"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Kill implements subcommands.Command for the "kill" command.

View File

@ -22,11 +22,11 @@ import (
"text/tabwriter"
"time"
"flag"
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// List implements subcommands.Command for the "list" command for the "list" command.

View File

@ -17,10 +17,10 @@ package cmd
import (
"context"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Pause implements subcommands.Command for the "pause" command.

View File

@ -18,11 +18,11 @@ import (
"context"
"fmt"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/sentry/control"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// PS implements subcommands.Command for the "ps" command.

View File

@ -19,10 +19,10 @@ import (
"path/filepath"
"syscall"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -17,10 +17,10 @@ package cmd
import (
"context"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Resume implements subcommands.Command for the "resume" command.

View File

@ -18,10 +18,10 @@ import (
"context"
"syscall"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)

View File

@ -20,8 +20,8 @@ import (
"os"
"path/filepath"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/flag"
)
var specTemplate = []byte(`{

View File

@ -17,10 +17,10 @@ package cmd
import (
"context"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// Start implements subcommands.Command for the "start" command.

View File

@ -19,11 +19,11 @@ import (
"encoding/json"
"os"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
// State implements subcommands.Command for the "state" command.

View File

@ -25,9 +25,9 @@ import (
"strconv"
"text/tabwriter"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/sentry/kernel"
"gvisor.dev/gvisor/runsc/flag"
)
// Syscalls implements subcommands.Command for the "syscalls" command.

View File

@ -20,10 +20,10 @@ import (
"os"
"syscall"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
)
const (

View File

@ -13,6 +13,7 @@ go_binary(
visibility = ["//runsc/container:__pkg__"],
deps = [
"//pkg/unet",
"//runsc/flag",
"//runsc/testutil",
"@com_github_google_subcommands//:go_default_library",
"@com_github_kr_pty//:go_default_library",

View File

@ -21,9 +21,9 @@ import (
"os"
"time"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/unet"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/testutil"
)

View File

@ -30,9 +30,9 @@ import (
sys "syscall"
"time"
"flag"
"github.com/google/subcommands"
"github.com/kr/pty"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/testutil"
)

9
runsc/flag/BUILD Normal file
View File

@ -0,0 +1,9 @@
load("//tools:defs.bzl", "go_library")
package(licenses = ["notice"])
go_library(
name = "flag",
srcs = ["flag.go"],
visibility = ["//:sandbox"],
)

33
runsc/flag/flag.go Normal file
View File

@ -0,0 +1,33 @@
// Copyright 2019 The gVisor Authors.
//
// 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 flag
import (
"flag"
)
type FlagSet = flag.FlagSet
var (
NewFlagSet = flag.NewFlagSet
String = flag.String
Bool = flag.Bool
Int = flag.Int
Uint = flag.Uint
CommandLine = flag.CommandLine
Parse = flag.Parse
)
const ContinueOnError = flag.ContinueOnError

View File

@ -28,14 +28,13 @@ import (
"syscall"
"time"
"flag"
"github.com/google/subcommands"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/refs"
"gvisor.dev/gvisor/pkg/sentry/platform"
"gvisor.dev/gvisor/runsc/boot"
"gvisor.dev/gvisor/runsc/cmd"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)