1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 13:29:11 +01:00

Running glide update -v to pulldown all the required depedencies

This commit is contained in:
Hugues Alary
2018-05-22 19:14:00 -07:00
parent 450a5c290b
commit fad9e8dc39
1481 changed files with 199396 additions and 6 deletions

View File

@@ -0,0 +1,92 @@
// Copyright 2015 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.
// concat_table is an example client of the bigquery client library.
// It concatenates two BigQuery tables and writes the result to another table.
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"cloud.google.com/go/bigquery"
"golang.org/x/net/context"
)
var (
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
src1 = flag.String("src1", "", "The ID of the first BigQuery table to concatenate")
src2 = flag.String("src2", "", "The ID of the second BigQuery table to concatenate")
dest = flag.String("dest", "", "The ID of the BigQuery table to write the result to")
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
)
func main() {
flag.Parse()
flagsOk := true
for _, f := range []string{"project", "dataset", "src1", "src2", "dest"} {
if flag.Lookup(f).Value.String() == "" {
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
flagsOk = false
}
}
if !flagsOk {
os.Exit(1)
}
if *src1 == *src2 || *src1 == *dest || *src2 == *dest {
log.Fatalf("Different values must be supplied for each of --src1, --src2 and --dest")
}
ctx := context.Background()
client, err := bigquery.NewClient(ctx, *project)
if err != nil {
log.Fatalf("Creating bigquery client: %v", err)
}
s1 := client.Dataset(*dataset).Table(*src1)
s2 := client.Dataset(*dataset).Table(*src2)
d := client.Dataset(*dataset).Table(*dest)
// Concatenate data.
job, err := client.Copy(ctx, d, bigquery.Tables{s1, s2}, bigquery.WriteTruncate)
if err != nil {
log.Fatalf("Concatenating: %v", err)
}
fmt.Printf("Job for concatenation operation: %+v\n", job)
fmt.Printf("Waiting for job to complete.\n")
for range time.Tick(*pollint) {
status, err := job.Status(ctx)
if err != nil {
fmt.Printf("Failure determining status: %v", err)
break
}
if !status.Done() {
continue
}
if err := status.Err(); err == nil {
fmt.Printf("Success\n")
} else {
fmt.Printf("Failure: %+v\n", err)
}
break
}
}

View File

@@ -0,0 +1,95 @@
// Copyright 2015 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.
// load is an example client of the bigquery client library.
// It loads a file from Google Cloud Storage into a BigQuery table.
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"cloud.google.com/go/bigquery"
"golang.org/x/net/context"
)
var (
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
table = flag.String("table", "", "The ID of a BigQuery table to load data into")
bucket = flag.String("bucket", "", "The name of a Google Cloud Storage bucket to load data from")
object = flag.String("object", "", "The name of a Google Cloud Storage object to load data from. Must exist within the bucket specified by --bucket")
skiprows = flag.Int64("skiprows", 0, "The number of rows of the source data to skip when loading")
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
)
func main() {
flag.Parse()
flagsOk := true
for _, f := range []string{"project", "dataset", "table", "bucket", "object"} {
if flag.Lookup(f).Value.String() == "" {
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
flagsOk = false
}
}
if !flagsOk {
os.Exit(1)
}
ctx := context.Background()
client, err := bigquery.NewClient(ctx, *project)
if err != nil {
log.Fatalf("Creating bigquery client: %v", err)
}
table := client.Dataset(*dataset).Table(*table)
gcs := client.NewGCSReference(fmt.Sprintf("gs://%s/%s", *bucket, *object))
gcs.SkipLeadingRows = *skiprows
// Load data from Google Cloud Storage into a BigQuery table.
job, err := client.Copy(
ctx, table, gcs,
bigquery.MaxBadRecords(1),
bigquery.AllowQuotedNewlines(),
bigquery.WriteTruncate)
if err != nil {
log.Fatalf("Loading data: %v", err)
}
fmt.Printf("Job for data load operation: %+v\n", job)
fmt.Printf("Waiting for job to complete.\n")
for range time.Tick(*pollint) {
status, err := job.Status(ctx)
if err != nil {
fmt.Printf("Failure determining status: %v", err)
break
}
if !status.Done() {
continue
}
if err := status.Err(); err == nil {
fmt.Printf("Success\n")
} else {
fmt.Printf("Failure: %+v\n", err)
}
break
}
}

View File

@@ -0,0 +1,100 @@
// Copyright 2015 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.
// query is an example client of the bigquery client library.
// It submits a query and writes the result to a table.
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
"cloud.google.com/go/bigquery"
"golang.org/x/net/context"
)
var (
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
q = flag.String("q", "", "The query string")
dest = flag.String("dest", "", "The ID of the BigQuery table to write the result to. If unset, an ephemeral table ID will be generated.")
pollint = flag.Duration("pollint", 10*time.Second, "Polling interval for checking job status")
wait = flag.Bool("wait", false, "Whether to wait for the query job to complete.")
)
func main() {
flag.Parse()
flagsOk := true
for _, f := range []string{"project", "dataset", "q"} {
if flag.Lookup(f).Value.String() == "" {
fmt.Fprintf(os.Stderr, "Flag --%s is required\n", f)
flagsOk = false
}
}
if !flagsOk {
os.Exit(1)
}
ctx := context.Background()
client, err := bigquery.NewClient(ctx, *project)
if err != nil {
log.Fatalf("Creating bigquery client: %v", err)
}
d := &bigquery.Table{}
if *dest != "" {
d = client.Dataset(*dataset).Table(*dest)
}
query := &bigquery.Query{
Q: *q,
DefaultProjectID: *project,
DefaultDatasetID: *dataset,
}
// Query data.
job, err := client.Copy(ctx, d, query, bigquery.WriteTruncate)
if err != nil {
log.Fatalf("Querying: %v", err)
}
fmt.Printf("Submitted query. Job ID: %s\n", job.ID())
if !*wait {
return
}
fmt.Printf("Waiting for job to complete.\n")
for range time.Tick(*pollint) {
status, err := job.Status(ctx)
if err != nil {
fmt.Printf("Failure determining status: %v", err)
break
}
if !status.Done() {
continue
}
if err := status.Err(); err == nil {
fmt.Printf("Success\n")
} else {
fmt.Printf("Failure: %+v\n", err)
}
break
}
}

View File

@@ -0,0 +1,143 @@
// Copyright 2015 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.
// read is an example client of the bigquery client library.
// It reads from a table, returning the data via an Iterator.
package main
import (
"flag"
"fmt"
"log"
"os"
"regexp"
"strings"
"text/tabwriter"
"cloud.google.com/go/bigquery"
"golang.org/x/net/context"
)
var (
project = flag.String("project", "", "The ID of a Google Cloud Platform project")
dataset = flag.String("dataset", "", "The ID of a BigQuery dataset")
table = flag.String("table", ".*", "A regular expression to match the IDs of tables to read.")
jobID = flag.String("jobid", "", "The ID of a query job that has already been submitted."+
" If set, --dataset, --table will be ignored, and results will be read from the specified job.")
)
func printValues(ctx context.Context, it *bigquery.Iterator) {
// one-space padding.
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
for it.Next(ctx) {
var vals bigquery.ValueList
if err := it.Get(&vals); err != nil {
fmt.Printf("err calling get: %v\n", err)
} else {
sep := ""
for _, v := range vals {
fmt.Fprintf(tw, "%s%v", sep, v)
sep = "\t"
}
fmt.Fprintf(tw, "\n")
}
}
tw.Flush()
fmt.Printf("\n")
if err := it.Err(); err != nil {
fmt.Printf("err reading: %v\n", err)
}
}
func printTable(ctx context.Context, client *bigquery.Client, t *bigquery.Table) {
it, err := client.Read(ctx, t)
if err != nil {
log.Fatalf("Reading: %v", err)
}
id := t.FullyQualifiedName()
fmt.Printf("%s\n%s\n", id, strings.Repeat("-", len(id)))
printValues(ctx, it)
}
func printQueryResults(ctx context.Context, client *bigquery.Client, queryJobID string) {
job, err := client.JobFromID(ctx, queryJobID)
if err != nil {
log.Fatalf("Loading job: %v", err)
}
it, err := client.Read(ctx, job)
if err != nil {
log.Fatalf("Reading: %v", err)
}
// TODO: print schema.
printValues(ctx, it)
}
func main() {
flag.Parse()
flagsOk := true
if flag.Lookup("project").Value.String() == "" {
fmt.Fprintf(os.Stderr, "Flag --project is required\n")
flagsOk = false
}
var sourceFlagCount int
if flag.Lookup("dataset").Value.String() != "" {
sourceFlagCount++
}
if flag.Lookup("jobid").Value.String() != "" {
sourceFlagCount++
}
if sourceFlagCount != 1 {
fmt.Fprintf(os.Stderr, "Exactly one of --dataset or --jobid must be set\n")
flagsOk = false
}
if !flagsOk {
os.Exit(1)
}
ctx := context.Background()
tableRE, err := regexp.Compile(*table)
if err != nil {
fmt.Fprintf(os.Stderr, "--table is not a valid regular expression: %q\n", *table)
os.Exit(1)
}
client, err := bigquery.NewClient(ctx, *project)
if err != nil {
log.Fatalf("Creating bigquery client: %v", err)
}
if *jobID != "" {
printQueryResults(ctx, client, *jobID)
return
}
ds := client.Dataset(*dataset)
var tables []*bigquery.Table
tables, err = ds.ListTables(context.Background())
if err != nil {
log.Fatalf("Listing tables: %v", err)
}
for _, t := range tables {
if tableRE.MatchString(t.TableID) {
printTable(ctx, client, t)
}
}
}