Skip to content

Commit

Permalink
feature: reorganize climc codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed May 7, 2020
1 parent 618e721 commit 1843ba3
Show file tree
Hide file tree
Showing 228 changed files with 651 additions and 235 deletions.
8 changes: 2 additions & 6 deletions cmd/climc/climc.go → cmd/climc/entry/climc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package main
package entry

import (
"context"
Expand All @@ -32,10 +32,6 @@ import (

"yunion.io/x/onecloud/cmd/climc/promputils"
"yunion.io/x/onecloud/cmd/climc/shell"
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
"yunion.io/x/onecloud/pkg/mcclient"
)

Expand Down Expand Up @@ -270,7 +266,7 @@ func executeSubcommand(
}
}

func main() {
func ClimcMain() {
parser, e := getSubcommandsParser()
if e != nil {
showErrorAndExit(e)
Expand Down
15 changes: 15 additions & 0 deletions cmd/climc/entry/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2019 Yunion
//
// 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 entry // import "yunion.io/x/onecloud/cmd/climc/entry"
27 changes: 27 additions & 0 deletions cmd/climc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"yunion.io/x/onecloud/cmd/climc/entry"
_ "yunion.io/x/onecloud/cmd/climc/shell"
_ "yunion.io/x/onecloud/cmd/climc/shell/ansible"
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudevent"
_ "yunion.io/x/onecloud/cmd/climc/shell/cloudnet"
_ "yunion.io/x/onecloud/cmd/climc/shell/compute"
_ "yunion.io/x/onecloud/cmd/climc/shell/etcd"
_ "yunion.io/x/onecloud/cmd/climc/shell/events"
_ "yunion.io/x/onecloud/cmd/climc/shell/identity"
_ "yunion.io/x/onecloud/cmd/climc/shell/image"
_ "yunion.io/x/onecloud/cmd/climc/shell/itsm"
_ "yunion.io/x/onecloud/cmd/climc/shell/k8s"
_ "yunion.io/x/onecloud/cmd/climc/shell/logger"
_ "yunion.io/x/onecloud/cmd/climc/shell/meter"
_ "yunion.io/x/onecloud/cmd/climc/shell/misc"
_ "yunion.io/x/onecloud/cmd/climc/shell/monitor"
_ "yunion.io/x/onecloud/cmd/climc/shell/notify"
_ "yunion.io/x/onecloud/cmd/climc/shell/servicetree"
_ "yunion.io/x/onecloud/cmd/climc/shell/yunionconf"
)

func main() {
entry.ClimcMain()
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package ansible

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package ansible

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package ansible

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
32 changes: 32 additions & 0 deletions cmd/climc/shell/ansible/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2019 Yunion
//
// 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 ansible

import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
)

var (
R = shell.R
printList = printutils.PrintJSONList
printObject = printutils.PrintJSONObject
printBatchResults = printutils.PrintJSONBatchResults

InvalidUpdateError = shell.InvalidUpdateError
printObjectRecursive = printutils.PrintJSONObjectRecursive

exportList = shell.ExportList
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package ansible

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package ansible

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package cloudevent

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package cloudevent

import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
)

func init() {
type CloudmetaOptions struct {
PROVIDER_ID string `help:"provider_id"`
REGION_ID string `help:"region_id"`
ZONE_ID string `help:"zone_id"`
}
R(&CloudmetaOptions{}, "instance-type-list", "query backend service for its version", func(s *mcclient.ClientSession, args *CloudmetaOptions) error {
return nil
})
}
var (
R = shell.R
printList = printutils.PrintJSONList
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"fmt"
Expand All @@ -26,7 +26,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
objectshell "yunion.io/x/onecloud/pkg/multicloud/objectstore"
"yunion.io/x/onecloud/pkg/multicloud/objectstore"
)

func init() {
Expand Down Expand Up @@ -188,7 +188,7 @@ func init() {
StorageClass string `help:"storage CLass"`
Acl string `help:"object acl." choices:"private|public-read|public-read-write"`

objectshell.ObjectHeaderOptions
objectstore.ObjectHeaderOptions
}
R(&BucketUploadObjectsOptions{}, "bucket-object-upload", "Upload an object into a bucket", func(s *mcclient.ClientSession, args *BucketUploadObjectsOptions) error {
var body io.Reader
Expand Down Expand Up @@ -325,7 +325,7 @@ func init() {

Key []string `help:"Optional object key" json:"key"`

objectshell.ObjectHeaderOptions
objectstore.ObjectHeaderOptions
}
R(&BucketSetMetadataOptions{}, "bucket-set-metadata", "Set metadata of object", func(s *mcclient.ClientSession, args *BucketSetMetadataOptions) error {
input := api.BucketMetadataInput{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"fmt"
Expand Down
34 changes: 34 additions & 0 deletions cmd/climc/shell/compute/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019 Yunion
//
// 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 compute

import (
"yunion.io/x/onecloud/cmd/climc/shell"
"yunion.io/x/onecloud/pkg/util/printutils"
)

var (
R = shell.R
printList = printutils.PrintJSONList
printObject = printutils.PrintJSONObject
printBatchResults = printutils.PrintJSONBatchResults

InvalidUpdateError = shell.InvalidUpdateError
printObjectRecursive = printutils.PrintJSONObjectRecursive

exportList = shell.ExportList

printObjectRecursiveEx = printutils.PrintJSONObjectRecursiveEx
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/jsonutils"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"yunion.io/x/onecloud/pkg/mcclient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package shell
package compute

import (
"fmt"
Expand Down

0 comments on commit 1843ba3

Please sign in to comment.