-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
2,098 additions
and
1,040 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Copyright 2024 Stacklok, Inc. | ||
// | ||
// 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 provider | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"google.golang.org/grpc" | ||
|
||
"github.com/stacklok/minder/internal/util/cli" | ||
minderv1 "github.com/stacklok/minder/pkg/api/protobuf/go/minder/v1" | ||
) | ||
|
||
var deleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete a given provider available in a specific project", | ||
Long: `The minder provider delete command deletes a given provider available in a specific project.`, | ||
RunE: cli.GRPCClientWrapRunE(DeleteProviderCommand), | ||
} | ||
|
||
func init() { | ||
ProviderCmd.AddCommand(deleteCmd) | ||
|
||
deleteCmd.Flags().StringP("name", "n", "", "Name of the provider to delete") | ||
deleteCmd.Flags().StringP("id", "i", "", "ID of the provider to delete") | ||
// We allow deleting by name or ID but not both. One of them must be specified. | ||
deleteCmd.MarkFlagsMutuallyExclusive("name", "id") | ||
deleteCmd.MarkFlagsOneRequired("name", "id") | ||
} | ||
|
||
// DeleteProviderCommand deletes the provider in a specific project | ||
func DeleteProviderCommand(ctx context.Context, cmd *cobra.Command, conn *grpc.ClientConn) error { | ||
client := minderv1.NewProvidersServiceClient(conn) | ||
|
||
project := viper.GetString("project") | ||
name := viper.GetString("name") | ||
id := viper.GetString("id") | ||
|
||
if id != "" { | ||
resp, err := client.DeleteProviderByID(ctx, &minderv1.DeleteProviderByIDRequest{ | ||
Context: &minderv1.Context{ | ||
Project: &project, | ||
}, | ||
Id: id, | ||
}) | ||
if err != nil { | ||
return cli.MessageAndError("Error deleting provider by id", err) | ||
} | ||
cmd.Println("Successfully deleted provider with id:", resp.Id) | ||
} else { | ||
// delete provider by name | ||
resp, err := client.DeleteProvider(ctx, &minderv1.DeleteProviderRequest{ | ||
Context: &minderv1.Context{Provider: &name, Project: &project}, | ||
}) | ||
if err != nil { | ||
return cli.MessageAndError("Error deleting provider by name", err) | ||
} | ||
cmd.Println("Successfully deleted provider with name:", resp.Name) | ||
} | ||
|
||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
--- | ||
title: minder provider delete | ||
--- | ||
## minder provider delete | ||
|
||
Delete a given provider available in a specific project | ||
|
||
### Synopsis | ||
|
||
The minder provider delete command deletes a given provider available in a specific project. | ||
|
||
``` | ||
minder provider delete [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for delete | ||
-i, --id string ID of the provider to delete | ||
-n, --name string Name of the provider to delete | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--config string Config file (default is $PWD/config.yaml) | ||
--grpc-host string Server host (default "api.stacklok.com") | ||
--grpc-insecure Allow establishing insecure connections | ||
--grpc-port int Server port (default 443) | ||
--identity-client string Identity server client ID (default "minder-cli") | ||
--identity-url string Identity server issuer URL (default "https://auth.stacklok.com") | ||
-j, --project string ID of the project | ||
-p, --provider string Name of the provider, i.e. github (default "github") | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [minder provider](minder_provider.md) - Manage providers within a minder control plane | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.