-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
322d075
commit dd3bb37
Showing
10 changed files
with
298 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright Mia srl | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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 extensions | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/mia-platform/miactl/internal/client" | ||
"github.com/mia-platform/miactl/internal/clioptions" | ||
"github.com/mia-platform/miactl/internal/encoding" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetOneCmd return a new cobra command to get a single extension | ||
func GetOneCmd(options *clioptions.CLIOptions) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "get", | ||
Short: "Get a registered extension", | ||
Long: "Get details for a single registered extension for the company.", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
restConfig, err := options.ToRESTConfig() | ||
cobra.CheckErr(err) | ||
|
||
client, err := client.APIClientForConfig(restConfig) | ||
cobra.CheckErr(err) | ||
|
||
if restConfig.CompanyID == "" { | ||
return ErrRequiredCompanyID | ||
} | ||
if options.EntityID == "" { | ||
return ErrRequiredExtensionID | ||
} | ||
|
||
extensibilityClient := New(client) | ||
extension, err := extensibilityClient.GetOne(cmd.Context(), restConfig.CompanyID, options.EntityID) | ||
cobra.CheckErr(err) | ||
|
||
serialized, err := encoding.MarshalData(extension, options.OutputFormat, encoding.MarshalOptions{Indent: true}) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(string(serialized)) | ||
return nil | ||
}, | ||
} | ||
|
||
options.AddOutputFormatFlag(cmd.Flags(), encoding.JSON) | ||
addExtensionIDFlag(options, cmd) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Mia srl | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// 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 extensions | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mia-platform/miactl/internal/clioptions" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetOneCmdCommandBuilder(t *testing.T) { | ||
opts := clioptions.NewCLIOptions() | ||
cmd := GetOneCmd(opts) | ||
require.NotNil(t, cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.