Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
support environment deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Jun 19, 2020
1 parent 21f65ea commit 2ef16e7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ func List() (respBody []byte, err error) {
return respBody, err
}

//GetDeployments
func GetDeployments() (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "deployments")
respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String())
return respBody, err
}

//SetEnvProperty is used to set env properties
func SetEnvProperty(name string, value string) (err error) {
//EnvProperty contains an individual org flag or property
Expand Down
36 changes: 36 additions & 0 deletions cmd/env/deployments.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2020 Google LLC
//
// 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 env

import (
"github.com/spf13/cobra"
)

//DeployCmd to manage api deployments for an environment
var DeployCmd = &cobra.Command{
Use: "deployments",
Short: "Manage deployments for the environment",
Long: "Manage deployments for the environment",
}

func init() {

DeployCmd.PersistentFlags().StringVarP(&environment, "env", "e",
"", "Apigee environment name")

_ = DeployCmd.MarkPersistentFlagRequired("env")

DeployCmd.AddCommand(GetDeployCmd)
}
1 change: 1 addition & 0 deletions cmd/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ func init() {
Cmd.AddCommand(DebugCmd)
Cmd.AddCommand(ObCmd)
Cmd.AddCommand(PropCmd)
Cmd.AddCommand(DeployCmd)
}
37 changes: 37 additions & 0 deletions cmd/env/getdeployments.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2020 Google LLC
//
// 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 env

import (
"github.com/spf13/cobra"
"github.com/srinandan/apigeecli/apiclient"
environments "github.com/srinandan/apigeecli/client/env"
)

//DeployCmd to get deployed apis in an env
var GetDeployCmd = &cobra.Command{
Use: "get",
Short: "Get deployments for an Environment",
Long: "Get deployments for an Environment",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetApigeeOrg(org)
apiclient.SetApigeeEnv(environment)
return nil
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
_, err = environments.GetDeployments()
return
},
}

0 comments on commit 2ef16e7

Please sign in to comment.