Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/cca/cca.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"

"github.com/cloud-ca/cca/cmd/cca/completion"
"github.com/cloud-ca/cca/cmd/cca/connection"
"github.com/cloud-ca/cca/cmd/cca/version"
"github.com/cloud-ca/cca/pkg/cli"
"github.com/cloud-ca/cca/pkg/client"
Expand Down Expand Up @@ -59,6 +60,7 @@ func NewCommand() *cobra.Command {
cmd.PersistentFlags().StringVar(&flg.LogLevel, "loglevel", flags.DefaultLogLevel.String(), "log level "+logutil.LevelsString())

cmd.AddCommand(completion.NewCommand(cli))
cmd.AddCommand(connection.NewCommand(cli))
cmd.AddCommand(version.NewCommand(cli))

return cmd
Expand Down
43 changes: 43 additions & 0 deletions cmd/cca/connection/connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright © 2019 cloud.ca Authors.
//
// 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 connection implements the `connection` command
package connection

import (
"github.com/cloud-ca/cca/cmd/cca/connection/get"
"github.com/cloud-ca/cca/cmd/cca/connection/list"
"github.com/cloud-ca/cca/pkg/cli"
"github.com/cloud-ca/cca/pkg/util"
"github.com/spf13/cobra"
)

// NewCommand returns a new cobra.Command for connection
func NewCommand(cli *cli.Wrapper) *cobra.Command {
cmd := &cobra.Command{
Args: cobra.NoArgs,
Use: "connection",
Short: "Manage service connections that you can create resources for",
Long: util.LongDescription(`
Service connections are the services that you can create resources for (e.g. compute, object
storage). Environments are created for a specific service which allows you to create and
manage resources within that service.
`),
}

cmd.AddCommand(get.NewCommand(cli))
cmd.AddCommand(list.NewCommand(cli))

return cmd
}
55 changes: 55 additions & 0 deletions cmd/cca/connection/get/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright © 2019 cloud.ca Authors.
//
// 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 get implements the `connection get` command
package get

import (
"github.com/cloud-ca/cca/pkg/cli"
"github.com/cloud-ca/cca/pkg/output"
"github.com/spf13/cobra"
)

type flag struct {
id string
}

// NewCommand returns a new cobra.Command for connection get
func NewCommand(cli *cli.Wrapper) *cobra.Command {
flg := &flag{}
cmd := &cobra.Command{
Args: cobra.NoArgs,
Use: "get",
Short: "Get service connection",
Long: "Get service connection",
RunE: func(cmd *cobra.Command, args []string) error {
connection, err := cli.CcaClient.ServiceConnections.Get(flg.id)
if err != nil {
return err
}
return cli.OutputBuilder.Build(func(formatter *output.Formatter) error {
return formatter.Format(connection)
})
},
}

cmd.Flags().StringVar(&flg.id, "id", "", "environment id")

err := cmd.MarkFlagRequired("id")
if err != nil {
panic(err)
}

return cmd
}
44 changes: 44 additions & 0 deletions cmd/cca/connection/list/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2019 cloud.ca Authors.
//
// 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 list implements the `connection list` command
package list

import (
"github.com/cloud-ca/cca/pkg/cli"
"github.com/cloud-ca/cca/pkg/output"
"github.com/spf13/cobra"
)

// NewCommand returns a new cobra.Command for connection list
func NewCommand(cli *cli.Wrapper) *cobra.Command {
cmd := &cobra.Command{
Args: cobra.NoArgs,
Aliases: []string{"ls"},
Use: "list",
Short: "List all service connections",
Long: "List all service connections",
RunE: func(cmd *cobra.Command, args []string) error {
connections, err := cli.CcaClient.ServiceConnections.List()
if err != nil {
return err
}
return cli.OutputBuilder.Build(func(formatter *output.Formatter) error {
return formatter.Format(connections)
})
},
}

return cmd
}