forked from sigstore/cosign
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debug providers command. (sigstore#3728)
When trying to run cosign on a remote workstation it would be nice to have a command to confirm the OIDC provider behavior of what is/isn't enabled and in what order. This PR adds a new hidden debug subcommand, with a debug providers subcommand that prints out the list of orderd providers and whether or not they are enabled. Signed-off-by: Billy Lynch <[email protected]>
- Loading branch information
Showing
4 changed files
with
96 additions
and
14 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,43 @@ | ||
// Copyright 2024 The Sigstore 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 cli | ||
|
||
import ( | ||
"github.com/sigstore/cosign/v2/cmd/cosign/cli/debug" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func Debug() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "debug", | ||
Hidden: true, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
return cmd.Help() | ||
}, | ||
} | ||
cmd.AddCommand(debugProviders()) | ||
return cmd | ||
} | ||
|
||
func debugProviders() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "providers", | ||
Short: "Show enabled/disabled OIDC providers.", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
return debug.ProviderCmd(cmd.Context(), cmd.OutOrStdout()) | ||
}, | ||
} | ||
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 2024 The Sigstore 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 debug | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/sigstore/cosign/v2/pkg/providers" | ||
) | ||
|
||
func ProviderCmd(ctx context.Context, w io.Writer) error { | ||
for _, p := range providers.Providers() { | ||
fmt.Fprintf(w, "%s: %t\n", p.Name, p.Provider.Enabled(ctx)) | ||
} | ||
return nil | ||
} |
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