Skip to content

Commit

Permalink
WebAccel配下のリソースでシェル補完用のLabel抽出処理を実装 (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamamoto-febc authored Jun 20, 2024
1 parent cd0047f commit ff17c0c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/commands/webaccel/labels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2017-2023 The sacloud/usacloud 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 webaccel

import (
"github.com/sacloud/usacloud/pkg/core"
"github.com/sacloud/webaccel-api-go"
)

func init() {
core.LabelsExtractors = append(core.LabelsExtractors, extractLabels)
}

func extractLabels(v interface{}) *core.Labels {
if v, ok := v.(*webaccel.Site); ok {
return &core.Labels{
Id: v.ID,
Name: v.Name,
}
}
return nil
}
1 change: 1 addition & 0 deletions pkg/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/sacloud/usacloud/pkg/commands/root"
updateSelf "github.com/sacloud/usacloud/pkg/commands/update-self"
"github.com/sacloud/usacloud/pkg/commands/version"
_ "github.com/sacloud/usacloud/pkg/commands/webaccel" // webaccel向けのcore.LabelsExtractorsの設定用
"github.com/sacloud/usacloud/pkg/commands/webaccel/webaccelerator"
"github.com/sacloud/usacloud/pkg/core"
"github.com/spf13/cobra"
Expand Down

0 comments on commit ff17c0c

Please sign in to comment.