From b4e9dfc6bc0d4e7abc69e5d208860a1832a75c49 Mon Sep 17 00:00:00 2001 From: Daniel Odvarka Date: Thu, 3 Mar 2022 12:53:59 +0100 Subject: [PATCH 1/2] remove createCalculation() --- cmd/ccboc/cmd/commands.go | 22 ---------------------- cmd/ccboc/cmd/root.go | 17 +---------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/cmd/ccboc/cmd/commands.go b/cmd/ccboc/cmd/commands.go index 4d48063..5b75523 100644 --- a/cmd/ccboc/cmd/commands.go +++ b/cmd/ccboc/cmd/commands.go @@ -333,28 +333,6 @@ func createCalculationBulk() error { return nil } -func createCalculation() error { - if teff == 0 || logG == 0 { - return fmt.Errorf("--teff and --logG must specified together") - } - - jsonData := fmt.Sprintf("{\"teff\": \"%0.1f\", \"logG\": \"%0.1f\"}", teff, logG) - body, responseError, err := request("POST", globalConfig.APIURL+"/calculations/create", bytes.NewBuffer([]byte(jsonData))) - if err != nil { - return err - } else if responseError != nil { - logrus.WithFields(logrus.Fields{"message": responseError.Message, "status_code": responseError.StatusCode}).Fatal("errors occurred") - } - - var calc *calculationsv1.Calculation - if err := json.Unmarshal(body, &calc); err != nil { - return err - } - - fmt.Printf("Calculation created: %s\n", calc.Name) - return nil -} - func request(method, endpoint string, buffer *bytes.Buffer) ([]byte, *errorResponse, error) { req, err := http.NewRequest(method, endpoint, buffer) if err != nil { diff --git a/cmd/ccboc/cmd/root.go b/cmd/ccboc/cmd/root.go index fa7a810..0646dcd 100644 --- a/cmd/ccboc/cmd/root.go +++ b/cmd/ccboc/cmd/root.go @@ -108,22 +108,10 @@ var ( createCmd = &cobra.Command{ Use: "create", - Short: "Creates a calculation/bulks in the cluster.", + Short: "Create a bulk in the cluster.", TraverseChildren: true, } - createCalcCmd = &cobra.Command{ - Use: "calculation", - Short: "Create a calculation in the cluster with specified logG and teff values.", - Run: func(cmd *cobra.Command, args []string) { - initializeConfig() - err := createCalculation() - if err != nil { - logrus.WithError(err).Fatal("create calculation command failed") - } - }, - } - createBulkCmd = &cobra.Command{ Use: "bulk", Short: "Creates a calculation bulk in the cluster using a .json file.", @@ -192,9 +180,6 @@ func init() { resultsCmd.Flags().StringVar(&path, "results-download-path", "", "Specified path to download the calculation to.") rootCmd.AddCommand(createCmd) - createCmd.AddCommand(createCalcCmd) - createCalcCmd.Flags().Float64Var(&teff, "teff", 0.0, "Teff value to create a calculation.") - createCalcCmd.Flags().Float64Var(&logG, "logG", 0.0, "LogG value to create a calculation.") createCmd.AddCommand(createBulkCmd) createBulkCmd.Flags().StringVar(&bulkFile, "bulk-file", "", "File in .json format to create a calculation bulk.") From 9dc072a5ce49756f206c692bf700f77ed0756f11 Mon Sep 17 00:00:00 2001 From: Daniel Odvarka Date: Thu, 3 Mar 2022 12:57:19 +0100 Subject: [PATCH 2/2] changes in --help and README.md - removal of createCalculation() --- README.md | 4 +--- cmd/ccboc/cmd/root.go | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index cb49b7c..e46511c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ CLI tool for ccb-operator ``` Examples of usage: -ccboc --teff=10000 --logG=4.0 create (Creates a calculation with teff=10000 and LogG=4.0) ccboc get calculation calc-1881i9dh5zvnllip (Gets the calculation with id='calc-1881i9dh5zvnllip') ccboc get calculations (Gets all active calculations) ccboc --teff=10000 --logG=4.0 get results (Downloads the result of a calculation with teff=10000 and LogG=4.0) @@ -19,7 +18,7 @@ Usage: Available Commands: completion generate the autocompletion script for the specified shell - create Creates a calculation/bulks in the cluster. + create Create a bulk in the cluster. get Get an object - calculation/bulk/workerpool. help Help about any command login Login to api server using the provided url and token. Also it generates the configuration file (default path is $HOME/.config/ccbo/config) @@ -28,5 +27,4 @@ Flags: -h, --help help for ccboc Use "ccboc [command] --help" for more information about a command. - ``` diff --git a/cmd/ccboc/cmd/root.go b/cmd/ccboc/cmd/root.go index 0646dcd..1d6eace 100644 --- a/cmd/ccboc/cmd/root.go +++ b/cmd/ccboc/cmd/root.go @@ -17,7 +17,6 @@ var ( Use: "ccboc", Short: "CLI tool for integrating with the active calculations by communicating with the API server (see https://github.com/vega-project/ccb-operator/tree/master/cmd/apiserver)", Long: "Examples of usage:" + "\n" + - "ccboc --teff=10000 --logG=4.0 create (Creates a calculation with teff=10000 and LogG=4.0)\n" + "ccboc get calculation calc-1881i9dh5zvnllip (Gets the calculation with id='calc-1881i9dh5zvnllip')\n" + "ccboc get calculations (Gets all active calculations)\n" + "ccboc --teff=10000 --logG=4.0 get results (Downloads the result of a calculation with teff=10000 and LogG=4.0)\n" +