Documentation
¶
Overview ¶
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CreateCmd = &cobra.Command{ Use: "create [path to template]", Aliases: []string{"crt", "c"}, Short: "Create Playbook", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { if _, err := os.Stat(args[0]); os.IsNotExist(err) { return errors.New("Template doesn't exist at path " + args[0]) } var format string { pathSlice := strings.Split(args[0], ".") format = pathSlice[len(pathSlice)-1] } template, err := os.ReadFile(args[0]) switch format { case "json": case "yml", "yaml": template, err = yaml.YAMLToJSON(template) default: return errors.New("Unsupported template format " + format) } if err != nil { fmt.Println("Error while parsing template") return err } playbook := &pb.Playbook{} err = json.Unmarshal(template, playbook) if err != nil { fmt.Println("Error while parsing template") return err } ctx, client := MakePlaybooksServiceClientOrFail() res, err := client.Create(ctx, &pb.CreatePlaybookRequest{ Playbook: playbook, }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, map[string]string{"uuid": res.Playbook.Uuid}) if err != nil { return err } if !ok { fmt.Println("Result:", res.Playbook.Uuid) } return nil }, }
var DeleteCmd = &cobra.Command{ Use: "delete [UUID]", Aliases: []string{"del", "rm", "r"}, Short: "Delete Ansible Playbook", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakePlaybooksServiceClientOrFail() res, err := client.Delete(ctx, &pb.DeletePlaybookRequest{ Uuid: args[0], }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("Successfully deleted") } return nil }, }
DeleteCmd represents the delete command
var GetCmd = &cobra.Command{ Use: "get [UUID]", Short: "Get Ansible Playbook", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakePlaybooksServiceClientOrFail() res, err := client.Get(ctx, &pb.GetPlaybookRequest{ Uuid: args[0], }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println(res) } return nil }, }
GetCmd represents the get command
var ListCmd = &cobra.Command{ Use: "list", Aliases: []string{"l", "ls"}, Short: "List Ansible Playbook", Args: cobra.MinimumNArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakePlaybooksServiceClientOrFail() res, err := client.List(ctx, &pb.ListPlaybooksRequest{}) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("--------------------------------") for _, playbook := range res.GetPlaybooks() { fmt.Println(playbook) fmt.Println("--------------------------------") } } return nil }, }
ListCmd represents the list command
Functions ¶
func MakePlaybooksServiceClientOrFail ¶
func MakePlaybooksServiceClientOrFail() (context.Context, pb.PlaybooksServiceClient)
Types ¶
This section is empty.