-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 00a7f49
Showing
9,938 changed files
with
3,050,741 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/broker/broker | ||
bin/class/class |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "broker" | ||
shortDesc: "This command interacts with Cluster Service Brokers" | ||
command: "./broker" | ||
tree: | ||
- name: "list" | ||
shortDesc: "Lists all Cluster Service Brokers" | ||
command: "./broker list" | ||
- name: "get" | ||
shortDesc: "Gets a particular Cluster Service Broker" | ||
command: "./broker get" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "class" | ||
shortDesc: "This command interacts with Cluster Service Classes" | ||
command: "./class" | ||
tree: | ||
- name: "list" | ||
shortDesc: "Lists all Cluster Service Classes" | ||
command: "./class list" | ||
- name: "get" | ||
shortDesc: "Gets a particular Cluster Service Class" | ||
command: "./class get" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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 main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/jberkhahn/service-catalog-plugins/pkg/utils" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const usage = `Usage: | ||
kubectl plugin broker SUBCOMMAND | ||
Available subcommands: | ||
list | ||
get | ||
` | ||
|
||
const getUsage = `Usage: | ||
kubectl plugin broker get BROKERNAME | ||
` | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
utils.Exit1(usage) | ||
} | ||
|
||
scClient, _ := utils.NewClient() | ||
if os.Args[1] == "list" { | ||
ListBroker() | ||
} else if os.Args[1] == "get" { | ||
if len(os.Args) != 3 { | ||
utils.Exit1(getUsage) | ||
} | ||
brokerName := os.Args[2] | ||
broker, err := scClient.ServicecatalogV1beta1().ClusterServiceBrokers().Get(brokerName, v1.GetOptions{}) | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Unable to find broker %s (%s)", brokerName, err)) | ||
} | ||
table := utils.NewTable("BROKER NAME", "NAMESPACE", "URL") | ||
table.AddRow(broker.Name, broker.Namespace, broker.Spec.URL) | ||
err = table.Print() | ||
} else { | ||
utils.Exit1(usage) | ||
} | ||
} | ||
|
||
func ListBroker() { | ||
scClient, _ := utils.NewClient() | ||
brokers, err := scClient.ServicecatalogV1beta1().ClusterServiceBrokers().List(v1.ListOptions{}) | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Unable to list brokers (%s)", err)) | ||
} | ||
|
||
table := utils.NewTable("BROKER NAME", "NAMESPACE", "URL") | ||
for _, v := range brokers.Items { | ||
table.AddRow(v.Name, v.Namespace, v.Spec.URL) | ||
err = table.Print() | ||
} | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Error printing result (%s)", err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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 main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/jberkhahn/service-catalog-plugins/pkg/utils" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const usage = `Usage: | ||
kubectl plugin class SUBCOMMAND | ||
Available subcommands: | ||
list | ||
get | ||
` | ||
|
||
const getUsage = `Usage: | ||
kubectl plugin class get CLASSNAME | ||
` | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
utils.Exit1(usage) | ||
} | ||
|
||
scClient, _ := utils.NewClient() | ||
if os.Args[1] == "list" { | ||
classes, err := scClient.ServicecatalogV1beta1().ClusterServiceClasses().List(v1.ListOptions{}) | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Unable to list classes (%s)", err)) | ||
} | ||
|
||
table := utils.NewTable("CLASS NAME", "NAMESPACE", "BROKER NAME") | ||
for _, v := range classes.Items { | ||
table.AddRow(v.Name, v.Namespace, v.Spec.ClusterServiceBrokerName) | ||
err = table.Print() | ||
} | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Error printing result (%s)", err)) | ||
} | ||
} else if os.Args[1] == "get" { | ||
if len(os.Args) != 3 { | ||
utils.Exit1(getUsage) | ||
} | ||
className := os.Args[2] | ||
class, err := scClient.ServicecatalogV1beta1().ClusterServiceClasses().Get(className, v1.GetOptions{}) | ||
if err != nil { | ||
utils.Exit1(fmt.Sprintf("Unable to find class %s (%s)", className, err)) | ||
} | ||
table := utils.NewTable("CLASS NAME", "NAMESPACE", "BROKER NAME") | ||
table.AddRow(class.Name, class.Namespace, class.Spec.ClusterServiceBrokerName) | ||
err = table.Print() | ||
} else { | ||
utils.Exit1(usage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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 utils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"text/tabwriter" | ||
) | ||
|
||
// Table defines a tabular output - obviously in table format | ||
type Table struct { | ||
headers []string | ||
rows [][]string | ||
} | ||
|
||
// NewTable creates a new table based on the passed in header names | ||
func NewTable(headers ...string) *Table { | ||
return &Table{ | ||
headers: headers, | ||
} | ||
} | ||
|
||
// AddRow will append the specified row to the table | ||
func (t *Table) AddRow(row ...string) { | ||
t.rows = append(t.rows, row) | ||
} | ||
|
||
// Print prints the table to the screen | ||
func (t *Table) Print() error { | ||
padding := 3 | ||
|
||
w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, ' ', 0) | ||
|
||
//Print header | ||
printStr := "" | ||
for _, h := range t.headers { | ||
printStr = printStr + h + "\t" | ||
} | ||
fmt.Fprintln(w, printStr) | ||
|
||
//Print rows | ||
for _, rows := range t.rows { | ||
printStr = "" | ||
for _, row := range rows { | ||
printStr = printStr + row + "\t" | ||
} | ||
fmt.Fprintln(w, printStr) | ||
} | ||
fmt.Fprintln(w) | ||
|
||
return w.Flush() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2016 The Kubernetes 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 utils | ||
|
||
import "fmt" | ||
|
||
// Green will print the specified string in green text | ||
func Green(str string) string { | ||
return fmt.Sprintf("\x1b[32;1m%s\x1b[0m", str) | ||
} | ||
|
||
// Red will print the specified string in red text | ||
func Red(str string) string { | ||
return fmt.Sprintf("\x1b[31;1m%s\x1b[0m", str) | ||
} | ||
|
||
// Entity will print the specified string in bold text | ||
func Entity(str string) string { | ||
return fmt.Sprintf("\x1b[36;1m%s\x1b[0m", str) | ||
} | ||
|
||
// Error will print the specified error string in red text | ||
func Error(msg string) { | ||
fmt.Printf("%s\n\n%s\n\n", Red("ERROR"), msg) | ||
} | ||
|
||
// Ok will print "OK" in green | ||
func Ok() { | ||
fmt.Printf("%s\n\n", Green("OK")) | ||
} |
Oops, something went wrong.