Skip to content

Commit

Permalink
feat: adds support to envgrp import #470 (#486)
Browse files Browse the repository at this point in the history
* feat: adds support to envgrp import #470

* feat: adds import command #470
  • Loading branch information
srinandan authored Jun 27, 2024
1 parent 3a8bf32 commit 531ccab
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/cmd/envgroup/envgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ func init() {
Cmd.AddCommand(DetachCmd)
Cmd.AddCommand(UpdateCmd)
Cmd.AddCommand(DelCmd)
Cmd.AddCommand(ImpCmd)
}
51 changes: 51 additions & 0 deletions internal/cmd/envgroup/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 envgroup

import (
"internal/apiclient"

"internal/client/envgroups"

"github.com/spf13/cobra"
)

// ImpCmd to list products
var ImpCmd = &cobra.Command{
Use: "import",
Short: "Import a file containing environment group definitions",
Long: "Import a file containing environment group definitions",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetRegion(region)
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
cmd.SilenceUsage = true

err = envgroups.Import(envGrpFile)
return
},
}

var envGrpFile string

func init() {
ImpCmd.Flags().StringVarP(&org, "org", "o",
"", "Apigee organization name")
ImpCmd.Flags().StringVarP(&envGrpFile, "file", "f",
"", "File containing environment group definitions")

_ = ImpCmd.MarkFlagRequired("file")
}

0 comments on commit 531ccab

Please sign in to comment.