<commit_before>/*
Copyright 2016 Skippbox, Ltd.

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"

	"github.com/Sirupsen/logrus"
	"github.com/skippbox/kubeless/pkg/controller"
	"github.com/spf13/cobra"
)

var installCmd = &cobra.Command{
	Use:   "install",
	Short: "Install Kubeless controller",
	Long: `This command helps to install the Kubeless controller and along with Apache Kafka to handle event-based functions.

By default we will install the latest release of bitnami/kubeless-controller image.
Use your own controller by specifying --controller-image flag.
`,
	Run: func(cmd *cobra.Command, args []string) {
		okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
		nokayResponses := []string{"n", "N", "no", "No", "NO"}
		fmt.Println("We are going to install the controller in the kubeless namespace. Are you OK with this: [Y/N]")
		var text string
		_, err := fmt.Scanln(&text)
		if err != nil {
			logrus.Fatal(err)
		}

		//getting versions
		ctlImage, err := cmd.Flags().GetString("controller-image")
		if err != nil {
			logrus.Fatal(err)
		}
		kafkaVer, err := cmd.Flags().GetString("kafka-version")
		if err != nil {
			logrus.Fatal(err)
		}

		if containsString(okayResponses, text) {
			cfg := controller.NewControllerConfig("", "")
			c := controller.New(cfg)
			c.Init()
			c.InstallKubeless(ctlImage)
			c.InstallMsgBroker(kafkaVer)
		} else if containsString(nokayResponses, text) {
			return
		} else {
			fmt.Println("Please type yes or no and then press enter:")
		}
	},
}

func containsString(slice []string, element string) bool {<commit_msg>Default to YES when installing if no input is provided, since its a non-destructive operation<commit_after>/*
Copyright 2016 Skippbox, Ltd.

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"

	"github.com/Sirupsen/logrus"
	"github.com/skippbox/kubeless/pkg/controller"
	"github.com/spf13/cobra"
)

var installCmd = &cobra.Command{
	Use:   "install",
	Short: "Install Kubeless controller",
	Long: `This command helps to install the Kubeless controller and along with Apache Kafka to handle event-based functions.

By default we will install the latest release of bitnami/kubeless-controller image.
Use your own controller by specifying --controller-image flag.
`,
	Run: func(cmd *cobra.Command, args []string) {
		okayResponses := []string{"y", "Y", "yes", "Yes", "YES"}
		fmt.Println("We are going to install the controller into the kubeless namespace. [Y/n]?")
		var text string
		n, _ := fmt.Scanln(&text)
		if n < 1 {
			// If no value is provided, default to Yes
			text = "Y"
		}

		//getting versions
		ctlImage, err := cmd.Flags().GetString("controller-image")
		if err != nil {
			logrus.Fatal(err)
		}
		kafkaVer, err := cmd.Flags().GetString("kafka-version")
		if err != nil {
			logrus.Fatal(err)
		}

		if containsString(okayResponses, text) {
			cfg := controller.NewControllerConfig("", "")
			c := controller.New(cfg)
			c.Init()
			c.InstallKubeless(ctlImage)
			c.InstallMsgBroker(kafkaVer)
		} else {
			fmt.Println("Kubeless wasn't installed, exiting.")
			return
		}
	},
}

func containsString(slice []string, element string) bool {
{'fraction_non_alphanumeric': 0.1127202510258267, 'fraction_numerical': 0.005068790731354091, 'mean_word_length': 4.047503045066992, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2846940', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1285, 'n_words': 455}