forked from LaconicNetwork/kompose
clean code
This commit is contained in:
+1
-136
@@ -54,141 +54,6 @@ func BeforeApp(c *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Ps lists all rc, svc.
|
||||
func Ps(c *cli.Context) {
|
||||
//factory := cmdutil.NewFactory(nil)
|
||||
//clientConfig, err := factory.ClientConfig()
|
||||
//if err != nil {
|
||||
// logrus.Fatalf("Failed to get Kubernetes client config: %v", err)
|
||||
//}
|
||||
//client := client.NewOrDie(clientConfig)
|
||||
//
|
||||
//if c.BoolT("svc") {
|
||||
// fmt.Printf("%-20s%-20s%-20s%-20s\n", "Name", "Cluster IP", "Ports", "Selectors")
|
||||
// for name := range p.Configs {
|
||||
// var ports string
|
||||
// var selectors string
|
||||
// services, err := client.Services(api.NamespaceDefault).Get(name)
|
||||
//
|
||||
// if err != nil {
|
||||
// logrus.Debugf("Cannot find service for: ", name)
|
||||
// } else {
|
||||
//
|
||||
// for i := range services.Spec.Ports {
|
||||
// p := strconv.Itoa(int(services.Spec.Ports[i].Port))
|
||||
// ports += ports + string(services.Spec.Ports[i].Protocol) + "(" + p + "),"
|
||||
// }
|
||||
//
|
||||
// for k, v := range services.ObjectMeta.Labels {
|
||||
// selectors += selectors + k + "=" + v + ","
|
||||
// }
|
||||
//
|
||||
// ports = strings.TrimSuffix(ports, ",")
|
||||
// selectors = strings.TrimSuffix(selectors, ",")
|
||||
//
|
||||
// fmt.Printf("%-20s%-20s%-20s%-20s\n", services.ObjectMeta.Name,
|
||||
// services.Spec.ClusterIP, ports, selectors)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if c.BoolT("rc") {
|
||||
// fmt.Printf("%-15s%-15s%-30s%-10s%-20s\n", "Name", "Containers", "Images",
|
||||
// "Replicas", "Selectors")
|
||||
// for name := range p.Configs {
|
||||
// var selectors string
|
||||
// var containers string
|
||||
// var images string
|
||||
// rc, err := client.ReplicationControllers(api.NamespaceDefault).Get(name)
|
||||
//
|
||||
// /* Should grab controller, container, image, selector, replicas */
|
||||
//
|
||||
// if err != nil {
|
||||
// logrus.Debugf("Cannot find rc for: ", string(name))
|
||||
// } else {
|
||||
//
|
||||
// for k, v := range rc.Spec.Selector {
|
||||
// selectors += selectors + k + "=" + v + ","
|
||||
// }
|
||||
//
|
||||
// for i := range rc.Spec.Template.Spec.Containers {
|
||||
// c := rc.Spec.Template.Spec.Containers[i]
|
||||
// containers += containers + c.Name + ","
|
||||
// images += images + c.Image + ","
|
||||
// }
|
||||
// selectors = strings.TrimSuffix(selectors, ",")
|
||||
// containers = strings.TrimSuffix(containers, ",")
|
||||
// images = strings.TrimSuffix(images, ",")
|
||||
//
|
||||
// fmt.Printf("%-15s%-15s%-30s%-10d%-20s\n", rc.ObjectMeta.Name, containers,
|
||||
// images, rc.Spec.Replicas, selectors)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
// Delete deletes all rc, svc.
|
||||
func Delete(c *cli.Context) {
|
||||
//factory := cmdutil.NewFactory(nil)
|
||||
//clientConfig, err := factory.ClientConfig()
|
||||
//if err != nil {
|
||||
// logrus.Fatalf("Failed to get Kubernetes client config: %v", err)
|
||||
//}
|
||||
//client := client.NewOrDie(clientConfig)
|
||||
//
|
||||
//for name := range p.Configs {
|
||||
// if len(c.String("name")) > 0 && name != c.String("name") {
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
// if c.BoolT("svc") {
|
||||
// err := client.Services(api.NamespaceDefault).Delete(name)
|
||||
// if err != nil {
|
||||
// logrus.Fatalf("Unable to delete service %s: %s\n", name, err)
|
||||
// }
|
||||
// } else if c.BoolT("rc") {
|
||||
// err := client.ReplicationControllers(api.NamespaceDefault).Delete(name)
|
||||
// if err != nil {
|
||||
// logrus.Fatalf("Unable to delete replication controller %s: %s\n", name, err)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
// Scale scales rc.
|
||||
func Scale(c *cli.Context) {
|
||||
//factory := cmdutil.NewFactory(nil)
|
||||
//clientConfig, err := factory.ClientConfig()
|
||||
//if err != nil {
|
||||
// logrus.Fatalf("Failed to get Kubernetes client config: %v", err)
|
||||
//}
|
||||
//client := client.NewOrDie(clientConfig)
|
||||
//
|
||||
//if c.Int("scale") <= 0 {
|
||||
// logrus.Fatalf("Scale must be defined and a positive number")
|
||||
//}
|
||||
//
|
||||
//for name := range p.Configs {
|
||||
// if len(c.String("rc")) == 0 || c.String("rc") == name {
|
||||
// s, err := client.ExtensionsClient.Scales(api.NamespaceDefault).Get("ReplicationController", name)
|
||||
// if err != nil {
|
||||
// logrus.Fatalf("Error retrieving scaling data: %s\n", err)
|
||||
// }
|
||||
//
|
||||
// s.Spec.Replicas = int32(c.Int("scale"))
|
||||
//
|
||||
// s, err = client.ExtensionsClient.Scales(api.NamespaceDefault).Update("ReplicationController", s)
|
||||
// if err != nil {
|
||||
// logrus.Fatalf("Error updating scaling data: %s\n", err)
|
||||
// }
|
||||
//
|
||||
// fmt.Printf("Scaling %s to: %d\n", name, s.Spec.Replicas)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
func validateFlags(opt kobject.ConvertOptions, singleOutput bool, dabFile, inputFile string) {
|
||||
if len(opt.OutFile) != 0 && opt.ToStdout {
|
||||
logrus.Fatalf("Error: --out and --stdout can't be set at the same time")
|
||||
@@ -222,7 +87,7 @@ func validateFlags(opt kobject.ConvertOptions, singleOutput bool, dabFile, input
|
||||
}
|
||||
}
|
||||
|
||||
// Convert tranforms docker compose or dab file to k8s objects
|
||||
// Convert transforms docker compose or dab file to k8s objects
|
||||
func Convert(c *cli.Context) {
|
||||
inputFile := c.String("file")
|
||||
dabFile := c.String("bundle")
|
||||
|
||||
+61
-61
@@ -110,71 +110,71 @@ func UpCommand() cli.Command {
|
||||
}
|
||||
|
||||
// PsCommand defines the kompose ps subcommand.
|
||||
func PsCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "ps",
|
||||
Usage: "Get active data in the kubernetes cluster",
|
||||
Action: func(c *cli.Context) {
|
||||
app.Ps(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "service,svc",
|
||||
Usage: "Get active services",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "replicationcontroller,rc",
|
||||
Usage: "Get active replication controller",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
//func PsCommand() cli.Command {
|
||||
// return cli.Command{
|
||||
// Name: "ps",
|
||||
// Usage: "Get active data in the kubernetes cluster",
|
||||
// Action: func(c *cli.Context) {
|
||||
// app.Ps(c)
|
||||
// },
|
||||
// Flags: []cli.Flag{
|
||||
// cli.BoolFlag{
|
||||
// Name: "service,svc",
|
||||
// Usage: "Get active services",
|
||||
// },
|
||||
// cli.BoolFlag{
|
||||
// Name: "replicationcontroller,rc",
|
||||
// Usage: "Get active replication controller",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
|
||||
// DeleteCommand defines the kompose delete subcommand.
|
||||
func DeleteCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Remove instantiated services/rc from kubernetes",
|
||||
Action: func(c *cli.Context) {
|
||||
app.Delete(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "replicationcontroller,rc",
|
||||
Usage: "Remove active replication controllers",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "service,svc",
|
||||
Usage: "Remove active services",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "name",
|
||||
Usage: "Name of the object to remove",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
//func DeleteCommand() cli.Command {
|
||||
// return cli.Command{
|
||||
// Name: "delete",
|
||||
// Usage: "Remove instantiated services/rc from kubernetes",
|
||||
// Action: func(c *cli.Context) {
|
||||
// app.Delete(c)
|
||||
// },
|
||||
// Flags: []cli.Flag{
|
||||
// cli.BoolFlag{
|
||||
// Name: "replicationcontroller,rc",
|
||||
// Usage: "Remove active replication controllers",
|
||||
// },
|
||||
// cli.BoolFlag{
|
||||
// Name: "service,svc",
|
||||
// Usage: "Remove active services",
|
||||
// },
|
||||
// cli.StringFlag{
|
||||
// Name: "name",
|
||||
// Usage: "Name of the object to remove",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
|
||||
// ScaleCommand defines the kompose up subcommand.
|
||||
func ScaleCommand() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "scale",
|
||||
Usage: "Globally scale instantiated replication controllers",
|
||||
Action: func(c *cli.Context) {
|
||||
app.Scale(c)
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{
|
||||
Name: "scale",
|
||||
Usage: "New number of replicas",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "replicationcontroller,rc",
|
||||
Usage: "A specific replication controller to scale",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
//func ScaleCommand() cli.Command {
|
||||
// return cli.Command{
|
||||
// Name: "scale",
|
||||
// Usage: "Globally scale instantiated replication controllers",
|
||||
// Action: func(c *cli.Context) {
|
||||
// app.Scale(c)
|
||||
// },
|
||||
// Flags: []cli.Flag{
|
||||
// cli.IntFlag{
|
||||
// Name: "scale",
|
||||
// Usage: "New number of replicas",
|
||||
// },
|
||||
// cli.StringFlag{
|
||||
// Name: "replicationcontroller,rc",
|
||||
// Usage: "A specific replication controller to scale",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
|
||||
// CommonFlags defines the flags that are in common for all subcommands.
|
||||
func CommonFlags() []cli.Flag {
|
||||
|
||||
Reference in New Issue
Block a user