instances

package
v0.2.2-r3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

View Source
var InvokeCmd = &cobra.Command{
	Use:     "invoke [uuid] [action] [[flags]]",
	Aliases: []string{"call", "perform"},
	Short:   "Invokes NoCloud Instance Action",
	Args:    cobra.ExactArgs(2),
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx, client := MakeInstancesServiceClientOrFail()
		request := pb.InvokeRequest{
			Uuid:   args[0],
			Method: args[1],
		}
		data, err := cmd.Flags().GetString("data")
		if err != nil {
			return err
		}

		if data != "" {
			var dataMap map[string]interface{}
			err = json.Unmarshal([]byte(data), &dataMap)
			if err != nil {
				return err
			}
			dataStruct, err := structpb.NewStruct(dataMap)
			if err != nil {
				return err
			}
			request.Params = dataStruct.GetFields()
		}

		res, err := client.Invoke(ctx, &request)

		if err != nil {
			return err
		}

		if printJson, _ := cmd.Flags().GetBool("json"); !printJson {
			return PrintInstanceInvokeResponse(res)
		}

		meta, err := json.Marshal(res)
		if err != nil {
			return err
		}
		fmt.Println(string(meta))
		return nil
	},
}

GetCmd represents the list command

Functions

func MakeInstancesServiceClientOrFail

func MakeInstancesServiceClientOrFail() (context.Context, pb.InstancesServiceClient)

func PrintInstance

func PrintInstance(s *pb.Instance) error

func PrintInstanceInvokeResponse

func PrintInstanceInvokeResponse(res *pb.InvokeResponse) error

func PrintInstancesPool

func PrintInstancesPool(pool []*pb.Instance)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL