-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-4965: Keyring configuration storage
- Loading branch information
1 parent
fab7ccf
commit 3689439
Showing
12 changed files
with
433 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,12 @@ jobs: | |
run: go mod download | ||
- name: Setup Ginkgo | ||
run: go install github.com/onsi/ginkgo/v2/[email protected] | ||
- name: Run the tests | ||
- name: Run the tests (linux, windows) | ||
if: ${{ contains(fromJSON('["ubuntu-latest", "windows-latest"]'), matrix.platform) }} | ||
run: make tests | ||
- name: Run the tests (macOS-only) | ||
if: ${{ contains(fromJSON('["macos-latest"]'), matrix.platform) }} | ||
run: make tests-cgo | ||
|
||
golangci: | ||
name: Lint | ||
|
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,66 @@ | ||
/* | ||
Copyright (c) 2024 Red Hat, 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 reset | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/openshift-online/ocm-sdk-go/authentication/securestore" | ||
) | ||
|
||
var args struct { | ||
debug bool | ||
} | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "reset [flags] VARIABLE", | ||
Short: "Resets/removes the requested option from configuration", | ||
Long: "Resets/removes requested option from configuration", | ||
Args: cobra.ExactArgs(1), | ||
RunE: run, | ||
} | ||
|
||
func init() { | ||
flags := Cmd.Flags() | ||
flags.BoolVar( | ||
&args.debug, | ||
"debug", | ||
false, | ||
"Enable debug mode.", | ||
) | ||
} | ||
|
||
func run(cmd *cobra.Command, argv []string) error { | ||
switch argv[0] { | ||
case "keyring": | ||
keyring := os.Getenv("RH_KEYRING") | ||
if keyring == "" { | ||
return fmt.Errorf("RH_KEYRING is required to reset config") | ||
} | ||
err := securestore.RemoveConfigFromKeyring(keyring) | ||
if err != nil { | ||
return fmt.Errorf("can't reset keyring: %v", err) | ||
} | ||
default: | ||
return fmt.Errorf("unknown setting") | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.