diff --git a/.github/workflows/keyfactor-starter-workflow.yml b/.github/workflows/keyfactor-starter-workflow.yml index 38905e8..a3e51bb 100644 --- a/.github/workflows/keyfactor-starter-workflow.yml +++ b/.github/workflows/keyfactor-starter-workflow.yml @@ -1,43 +1,20 @@ -name: Starter Workflow -on: workflow_dispatch +name: Keyfactor Bootstrap Workflow -jobs: - catalog-update-check: - runs-on: windows-latest - outputs: - upd_cat: ${{ steps.read-json.outputs.prop }} - steps: - - uses: actions/checkout@v4 - - name: Read json - id: read-json - shell: pwsh - run: | - $json = Get-Content integration-manifest.json | ConvertFrom-Json - echo "::set-output name=prop::$(echo $json.update_catalog)" - - #call-create-github-release-workflow: - # uses: Keyfactor/actions/.github/workflows/github-release.yml@main +on: + workflow_dispatch: + pull_request: + types: [opened, closed, synchronize, edited, reopened] + push: + create: + branches: + - 'release-*.*' - #call-dotnet-build-and-release-workflow: - # needs: [call-create-github-release-workflow] - # uses: Keyfactor/actions/.github/workflows/dotnet-build-and-release.yml@main - # with: - # release_version: ${{ needs.call-create-github-release-workflow.outputs.release_version }} - # release_url: ${{ needs.call-create-github-release-workflow.outputs.release_url }} - # release_dir: SslStoreCaProxy/bin/Release - # secrets: - # token: ${{ secrets.PRIVATE_PACKAGE_ACCESS }} - - call-generate-readme-workflow: - if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' - uses: Keyfactor/actions/.github/workflows/generate-readme.yml@main +jobs: + call-starter-workflow: + uses: keyfactor/actions/.github/workflows/starter.yml@v2 secrets: - token: ${{ secrets.APPROVE_README_PUSH }} + token: ${{ secrets.V2BUILDTOKEN}} + APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}} + gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }} + gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }} - call-update-catalog-workflow: - needs: catalog-update-check - if: needs.catalog-update-check.outputs.upd_cat == 'True' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - uses: Keyfactor/actions/.github/workflows/update-catalog.yml@main - secrets: - token: ${{ secrets.SDK_SYNC_PAT }} - \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index d1f2876..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Terraform Provider release workflow. -name: Release - -# This GitHub action creates a release when a tag that matches the pattern -# "v*" (e.g. v0.1.0) is created. -on: - push: - tags: - - 'v*' - -# Releases need permissions to read and write the repository contents. -# GitHub considers creating releases and uploading assets as writing contents. -permissions: - contents: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Allow goreleaser to access older tag information. - fetch-depth: 0 - - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' - cache: true - - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@v6 - id: import_gpg - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.PASSPHRASE }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - args: release --clean - env: - # GitHub sets the GITHUB_TOKEN secret automatically. - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PAT_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} - GPG_TTY: $(tty) \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 51e86f8..936a2f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,7 +51,7 @@ jobs: uses: actions/checkout@v4 - name: Run tests run: | - unset KFUTIL_DEBUG + export KFUTIL_DEBUG=1 go test -v ./cmd -run "^Test_StoreTypes*" Test_StoreTypes_KFC_10_2_1: runs-on: ubuntu-latest @@ -486,4 +486,4 @@ jobs: # Run the tests with coverage found in the pkg directory - name: Run tests - run: go test -v -cover ./pkg/... \ No newline at end of file + run: go test -v -cover ./pkg/... diff --git a/.gitignore b/.gitignore index ab5d9c0..1e6895f 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ vendor/ *.csv /.vs/**/* /.vscode/**/* +.DS_Store \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 3fb2cc3..ba8a4fd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -56,7 +56,7 @@ release: - glob: 'integration-manifest.json' name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' # If you want to manually examine the release before its live, uncomment this line: - draft: true + #draft: true changelog: sort: asc use: github diff --git a/CHANGELOG.md b/CHANGELOG.md index 9849273..69abb8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# v1.3.0 +## Features + +### StoreTypes +- Added `--output-to-integration-manifest` flag to `kfutil store-types get` to download a remote certificate store type definition into an `integration-manifest.json` file locally. +- Updated usage: `kfutil store-types get [-i | -n ] [-b ] [-g | --output-to-integration-manifest]` + # v1.2.1 ## Bug Fixes @@ -68,4 +75,4 @@ Production Supported CLIs: - `login`: [kfutil login](docs/kfutil_login.md) - `store-types`: [kfutil store-types](docs/kfutil_store-types.md) -- `stores rot`: [kfutil rot](docs/kfutil_stores_rot.md) \ No newline at end of file +- `stores rot`: [kfutil rot](docs/kfutil_stores_rot.md) diff --git a/README.md b/README.md index 51f5344..5ccc6fb 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,18 @@ -- [Keyfactor Command Utility (kfutil)](#keyfactor-command-utility--kfutil-) - - [Integration status: Production - Ready for use in production environments.](#integration-status--production---ready-for-use-in-production-environments) - - * [Support for Keyfactor Command Utility (kfutil)](#support-for-keyfactor-command-utility--kfutil-) - * [Quickstart](#quickstart) - + [Prerequisites:](#prerequisites-) - + [Installation:](#installation-) - + [Environmental Variables](#environmental-variables) - * [Authentication Providers](#authentication-providers) - * [Commands](#commands) - + [Login](#login) - + [Logout](#logout) - * [Commands](#commands-1) - + [Bulk operations](#bulk-operations) - - [Bulk create cert stores](#bulk-create-cert-stores) - - [Bulk create cert store types](#bulk-create-cert-store-types) - + [Root of Trust](#root-of-trust) - + [Root of Trust Quickstart](#root-of-trust-quickstart) - - [Generate Certificate List Template](#generate-certificate-list-template) - - [Generate Certificate Store List Template](#generate-certificate-store-list-template) - - [Run Root of Trust Audit](#run-root-of-trust-audit) - - [Run Root of Trust Reconcile](#run-root-of-trust-reconcile) - + [Certificate Store Inventory](#certificate-store-inventory) - - [Show the inventory of a certificate store](#show-the-inventory-of-a-certificate-store) - - [Add certificates to certificate stores](#add-certificates-to-certificate-stores) - - [Remove certificates from certificate stores](#remove-certificates-from-certificate-stores) - * [Development](#development) - + [Adding a new command](#adding-a-new-command) - # Keyfactor Command Utility (kfutil) -`kfutil` is a go-lang CLI wrapper for Keyfactor Command API. It also includes other utility/helper functions around -automating common Keyfactor Command operations. +`kfutil` is a go-lang CLI wrapper for Keyfactor Command API. It also includes other utility/helper functions around automating common Keyfactor Command operations. #### Integration status: Production - Ready for use in production environments. + + ## Support for Keyfactor Command Utility (kfutil) -Keyfactor Command Utility (kfutil) is open source and there is **no SLA** for this tool/library/client. Keyfactor will -address issues as resources become available. Keyfactor customers may request escalation by opening up a support ticket -through their Keyfactor representative. +Keyfactor Command Utility (kfutil) is open source and there is **no SLA** for this tool/library/client. Keyfactor will address issues as resources become available. Keyfactor customers may request escalation by opening up a support ticket through their Keyfactor representative. + +###### To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab. -###### To report a problem or suggest a new feature, use the **[Issues](../../issues) -** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls) -** tab. ## Quickstart @@ -54,14 +23,26 @@ through their Keyfactor representative. - OR [wget](https://www.gnu.org/software/wget/) CLI tool, used to download the release files. - [unzip](https://linuxize.com/post/how-to-unzip-files-in-linux/#installing-unzip) CLI tool, used to unzip the release - [openssl](https://www.openssl.org/source/) CLI tool, used to validate package checksum. -- `$HOME/.local/bin` in your `$PATH` and exists. +- `$HOME/.local/bin` in your `$PATH` and exists if not running as root, else `/usr/local/bin` if running as root. ### Installation: +#### Linux/MacOS ```bash -bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh) +curl -fsSL -o get-kfutil.sh https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh +chmod +x get-kfutil.sh +# Install kfutil to $HOME/.local/bin. Use -h for help and examples. +./get-kfutil.sh ```` +#### Windows (or Linux/MacOS if PowerShell is preferred) +```powershell +Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.ps1" -OutFile "install.ps1" +# Install kfutil to $HOME/AppData/Local/Microsoft/WindowsApps. +# Use Get-Help .\install.ps1 -Full for help and examples. +.\install.ps1 +``` + ### Environmental Variables All the variables listed below need to be set in your environment. The `kfutil` command will look for these variables @@ -130,10 +111,7 @@ For full documentation on the `login` command, see the [login](docs/kfutil_login *WARNING* - The `login` command will store your Keyfactor credentials in a file on your local machine. This file is not encrypted and is not secure. It is recommended that you use the `login` command only on your local machine and not on a -shared machine. Instead of using the `login` command, you can set the environmental variables listed above. **You may -also -choose to use login and provide an empty password, in this mode you will be prompted for your password each time you run -a command.** +shared machine. Instead of using the `login` command, you can set the environmental variables listed above. ```bash kfutil login diff --git a/cmd/storeTypes.go b/cmd/storeTypes.go index e4d08ac..70b9b50 100644 --- a/cmd/storeTypes.go +++ b/cmd/storeTypes.go @@ -21,7 +21,6 @@ import ( "github.com/Keyfactor/keyfactor-go-client/v2/api" "github.com/rs/zerolog/log" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" "io" "net/http" "os" @@ -71,83 +70,6 @@ var storesTypesListCmd = &cobra.Command{ }, } -var storesTypeGetCmd = &cobra.Command{ - Use: "get", - Short: "Get a specific store type by either name or ID.", - Long: `Get a specific store type by either name or ID.`, - RunE: func(cmd *cobra.Command, args []string) error { - cmd.SilenceUsage = true - // Specific flags - genericFormat, _ := cmd.Flags().GetBool("generic") - gitRef, _ := cmd.Flags().GetString(FlagGitRef) - id, _ := cmd.Flags().GetInt("id") - name, _ := cmd.Flags().GetString("name") - - // Debug + expEnabled checks - isExperimental := false - debugErr := warnExperimentalFeature(expEnabled, isExperimental) - if debugErr != nil { - return debugErr - } - informDebug(debugFlag) - - // Authenticate - authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) - kfClient, _ := initClient(configFile, profile, providerType, providerProfile, noPrompt, authConfig, false) - - // CLI Logic - if gitRef == "" { - gitRef = "main" - } - outputType := "full" - if genericFormat { - outputType = "generic" - } - var st interface{} - // Check inputs - if id < 0 && name == "" { - validStoreTypes := getValidStoreTypes("", gitRef) - prompt := &survey.Select{ - Message: "Choose a store type:", - Options: validStoreTypes, - } - var selected string - err := survey.AskOne(prompt, &selected) - if err != nil { - fmt.Println(err) - return err - } - st = selected - } else if id >= 0 && name != "" { - mexErr := fmt.Errorf("ID and Name are mutually exclusive") - log.Error().Err(mexErr).Send() - return mexErr - } else if id >= 0 { - st = id - } else if name != "" { - st = name - } else { - log.Error().Err(InvalidInputError).Send() - return InvalidInputError - } - - storeTypes, err := kfClient.GetCertificateStoreType(st) - if err != nil { - - log.Error().Err(err).Msg(fmt.Sprintf("unable to get certificate store type %s", st)) - return err - } - output, jErr := formatStoreTypeOutput(storeTypes, outputFormat, outputType) - if jErr != nil { - - log.Error().Err(jErr).Msg("unable to format certificate store type output") - return jErr - } - outputResult(output, outputFormat) - return nil - }, -} - var storesTypeCreateCmd = &cobra.Command{ Use: "create", Short: "Create a new certificate store type in Keyfactor.", @@ -484,74 +406,6 @@ func createStoreFromFile(filename string, kfClient *api.Client) (*api.Certificat return createResp, nil } -func formatStoreTypeOutput(storeType *api.CertificateStoreType, outputFormat string, outputType string) (string, error) { - var sOut interface{} - sOut = storeType - if outputType == "generic" { - // Convert to api.GenericCertificateStoreType - var genericProperties []api.StoreTypePropertyDefinitionGeneric - for _, prop := range *storeType.Properties { - genericProp := api.StoreTypePropertyDefinitionGeneric{ - Name: prop.Name, - DisplayName: prop.DisplayName, - Type: prop.Type, - DependsOn: prop.DependsOn, - DefaultValue: prop.DefaultValue, - Required: prop.Required, - } - genericProperties = append(genericProperties, genericProp) - } - - var genericEntryParameters []api.EntryParameterGeneric - for _, param := range *storeType.EntryParameters { - genericParam := api.EntryParameterGeneric{ - Name: param.Name, - DisplayName: param.DisplayName, - Type: param.Type, - RequiredWhen: param.RequiredWhen, - DependsOn: param.DependsOn, - DefaultValue: param.DefaultValue, - Options: param.Options, - } - genericEntryParameters = append(genericEntryParameters, genericParam) - } - - genericStoreType := api.CertificateStoreTypeGeneric{ - Name: storeType.Name, - ShortName: storeType.ShortName, - Capability: storeType.Capability, - SupportedOperations: storeType.SupportedOperations, - Properties: &genericProperties, - EntryParameters: &genericEntryParameters, - PasswordOptions: storeType.PasswordOptions, - //StorePathType: storeType.StorePathType, - StorePathValue: storeType.StorePathValue, - PrivateKeyAllowed: storeType.PrivateKeyAllowed, - //JobProperties: jobProperties, - ServerRequired: storeType.ServerRequired, - PowerShell: storeType.PowerShell, - BlueprintAllowed: storeType.BlueprintAllowed, - CustomAliasAllowed: storeType.CustomAliasAllowed, - } - sOut = genericStoreType - } - - switch { - case outputFormat == "yaml" || outputFormat == "yml": - output, jErr := yaml.Marshal(sOut) - if jErr != nil { - return "", jErr - } - return fmt.Sprintf("%s", output), nil - default: - output, jErr := json.MarshalIndent(sOut, "", " ") - if jErr != nil { - return "", jErr - } - return fmt.Sprintf("%s", output), nil - } -} - func getStoreTypesInternet(gitRef string) (map[string]interface{}, error) { //resp, err := http.Get("https://raw.githubusercontent.com/keyfactor/kfutil/main/store_types.json") //resp, err := http.Get("https://raw.githubusercontent.com/keyfactor/kfctl/master/storetypes/storetypes.json") @@ -641,22 +495,14 @@ func init() { storeTypesCmd.AddCommand(storesTypesListCmd) // GET commands - storeTypesCmd.AddCommand(storesTypeGetCmd) - var storeTypeID int - var storeTypeName string - var dryRun bool - var genericFormat bool - storesTypeGetCmd.Flags().IntVarP(&storeTypeID, "id", "i", -1, "ID of the certificate store type to get.") - storesTypeGetCmd.Flags().StringVarP(&storeTypeName, "name", "n", "", "Name of the certificate store type to get.") - storesTypeGetCmd.MarkFlagsMutuallyExclusive("id", "name") - storesTypeGetCmd.Flags().BoolVarP(&genericFormat, "generic", "g", false, "Output the store type in a generic format stripped of all fields specific to the Command instance.") - //storesTypeGetCmd.Flags().StringVarP(&outputFormat, "format", "f", "json", "Output format. Valid choices are: 'json', 'yaml'. Default is 'json'.") - storesTypeGetCmd.Flags().StringVarP(&gitRef, FlagGitRef, "b", "main", "The git branch or tag to reference when pulling store-types from the internet.") + storeTypesCmd.AddCommand(CreateCmdStoreTypesGet()) // CREATE command var listValidStoreTypes bool var filePath string var createAll bool + var storeTypeName string + var storeTypeID int storeTypesCmd.AddCommand(storesTypeCreateCmd) storesTypeCreateCmd.Flags().StringVarP(&storeTypeName, "name", "n", "", "Short name of the certificate store type to get. Valid choices are: "+validTypesString) storesTypeCreateCmd.Flags().BoolVarP(&listValidStoreTypes, "list", "l", false, "List valid store types.") @@ -670,6 +516,7 @@ func init() { // DELETE command var deleteAll bool + var dryRun bool storeTypesCmd.AddCommand(storesTypeDeleteCmd) storesTypeDeleteCmd.Flags().IntVarP(&storeTypeID, "id", "i", -1, "ID of the certificate store type to delete.") storesTypeDeleteCmd.Flags().StringVarP(&storeTypeName, "name", "n", "", "Name of the certificate store type to delete.") diff --git a/cmd/storeTypes_get.go b/cmd/storeTypes_get.go new file mode 100644 index 0000000..9608b1c --- /dev/null +++ b/cmd/storeTypes_get.go @@ -0,0 +1,331 @@ +/* +Copyright 2023 The Keyfactor Command 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 cmd + +import ( + "encoding/json" + "fmt" + "github.com/AlecAivazis/survey/v2" + "github.com/Keyfactor/keyfactor-go-client/v2/api" + "github.com/rs/zerolog/log" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "gopkg.in/yaml.v3" + "kfutil/pkg/cmdutil/flags" + "kfutil/pkg/keyfactor/v1" +) + +// Ensure that StoreTypesGetFlags implements Flags +var _ flags.Flags = &StoreTypesGetFlags{} +var _ flags.Options = &StoreTypesGetOptions{} + +type StoreTypesGetFlags struct { + // storeTypeID is the ID of the certificate store type to get. + storeTypeID *int + // storeTypeName is the name of the certificate store type to get. + storeTypeName *string + // genericFormat strips all fields specific to the Command instance from the output. + genericFormat *bool + // gitRef is the git branch or tag to reference when pulling store-types from the internet. + gitRef *string + // outputToIntegrationManifest updates the integration manifest with the store type. It overrides the store type in the manifest if it already exists. + outputToIntegrationManifest *bool +} + +func CreateStoreTypesGetFlags() *StoreTypesGetFlags { + var storeTypeID int + var storeTypeName string + var genericFormat bool + var gitRef string + var outputToIntegrationManifest bool + + return &StoreTypesGetFlags{ + storeTypeID: &storeTypeID, + storeTypeName: &storeTypeName, + genericFormat: &genericFormat, + gitRef: &gitRef, + outputToIntegrationManifest: &outputToIntegrationManifest, + } +} + +func (f *StoreTypesGetFlags) AddFlags(flags *pflag.FlagSet) { + flags.IntVarP(f.storeTypeID, "id", "i", -1, "ID of the certificate store type to get.") + flags.StringVarP(f.storeTypeName, "name", "n", "", "Name of the certificate store type to get.") + flags.BoolVarP(f.genericFormat, "generic", "g", false, "Output the store type in a generic format stripped of all fields specific to the Command instance.") + flags.StringVarP(f.gitRef, FlagGitRef, "b", "main", "The git branch or tag to reference when pulling store-types from the internet.") + flags.BoolVarP(f.outputToIntegrationManifest, "output-to-integration-manifest", "", false, "Update the integration manifest with the store type. It overrides the store type in the manifest if it already exists. If the integration manifest does not exist in the current directory, it will be created.") +} + +func CreateCmdStoreTypesGet() *cobra.Command { + storeTypesGetFlags := CreateStoreTypesGetFlags() + + cmd := &cobra.Command{ + Use: StoreTypesGetUsage, + Short: StoreTypesGetShort, + Long: StoreTypesGetLong, + RunE: func(cmd *cobra.Command, args []string) error { + // Silence usage on error + cmd.SilenceUsage = true + + // Debug + expEnabled checks + debugErr := warnExperimentalFeature(expEnabled, false) + if debugErr != nil { + return debugErr + } + informDebug(debugFlag) + + // Compute the runtime options from flags passed to the command + options, err := storeTypesGetFlags.ToOptions(cmd, args) + if err != nil { + return fmt.Errorf("failed to get runtime options from flags: %s", err) + } + if options.storeTypeInterface == nil { + return fmt.Errorf("store type not specified - this should never happen") + } + + // Authenticate + authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) + kfClient, _ := initClient(configFile, profile, providerType, providerProfile, noPrompt, authConfig, false) + + if kfClient == nil { + return fmt.Errorf("failed to initialize Keyfactor client") + } + + storeTypes, err := kfClient.GetCertificateStoreType(options.storeTypeInterface) + if err != nil { + log.Error().Err(err).Msg(fmt.Sprintf("unable to get certificate store type %s", options.storeTypeInterface)) + return err + } + log.Trace().Msg(fmt.Sprintf("storeTypes: %+v", storeTypes)) + output, jErr := formatStoreTypeOutput(storeTypes, outputFormat, options.outputType) + if jErr != nil { + log.Error().Err(jErr).Msg("unable to format certificate store type output") + return jErr + } + + // If outputToIntegrationManifest is true, update the integration manifest with the store type + if options.outputToIntegrationManifest { + log.Debug().Msg("Writing store type to integration manifest") + imv1 := manifestv1.CreateIntegrationManifest() + err = imv1.LoadFromFilesystem() + if err != nil { + return err + } + + err = imv1.CopyIntoStoreType(output) + if err != nil { + return err + } + + err = imv1.SaveToFilesystem() + if err != nil { + return err + } + + _, err = cmd.OutOrStdout().Write([]byte(fmt.Sprintf("Successfully updated integration manifest with store type %s\n", options.storeTypeInterface))) + } else { + _, err = cmd.OutOrStdout().Write([]byte(output)) + if err != nil { + return err + } + } + + return nil + }, + } + + // Add the flags + storeTypesGetFlags.AddFlags(cmd.Flags()) + + return cmd +} + +type StoreTypesGetOptions struct { + storeTypeID int + storeTypeName string + genericFormat bool + gitRef string + storeTypeInterface interface{} + outputType string + outputToIntegrationManifest bool +} + +func (f *StoreTypesGetFlags) ToOptions(cmd *cobra.Command, args []string) (*StoreTypesGetOptions, error) { + log.Debug().Msg("call: storeTypesGetFlags.ToOptions") + if len(args) > 0 { + return nil, fmt.Errorf("unexpected arguments: %v", args) + } + + options := &StoreTypesGetOptions{} + + // Global flags + flags.GetDebugFlag(cmd) + + // Get the values from the flags + if f.storeTypeID != nil { + options.storeTypeID = *f.storeTypeID + log.Debug().Msg(fmt.Sprintf("storeTypeID: %d", options.storeTypeID)) + } + + if f.storeTypeName != nil { + options.storeTypeName = *f.storeTypeName + log.Debug().Msg(fmt.Sprintf("storeTypeName: %s", options.storeTypeName)) + } + + if f.genericFormat != nil { + options.genericFormat = *f.genericFormat + log.Debug().Msg(fmt.Sprintf("genericFormat: %t", options.genericFormat)) + } + + if f.gitRef != nil { + options.gitRef = *f.gitRef + log.Debug().Msg(fmt.Sprintf("gitRef: %s", options.gitRef)) + } + + if f.outputToIntegrationManifest != nil { + options.outputToIntegrationManifest = *f.outputToIntegrationManifest + log.Debug().Msg(fmt.Sprintf("outputToIntegrationManifest: %t", options.outputToIntegrationManifest)) + } + + log.Debug().Msg("complete: storeTypesGetFlags.ToOptions") + return options, options.Validate() +} + +func (f *StoreTypesGetOptions) Validate() error { + log.Debug().Msg("call: storeTypesGetFlags.Validate") + // storeTypeID and storeTypeName are mutually exclusive + if f.storeTypeID > 0 && f.storeTypeName != "" { + return fmt.Errorf("only one of --id or --name can be provided") + } + + // Check inputs and prompt if necessary + // The f.storeTypeInterface is used to pass the store type to the API + if f.storeTypeID < 0 && f.storeTypeName == "" { + validStoreTypes := getValidStoreTypes("", f.gitRef) + prompt := &survey.Select{ + Message: "Choose a store type:", + Options: validStoreTypes, + } + var selected string + err := survey.AskOne(prompt, &selected) + if err != nil { + fmt.Println(err) + return err + } + f.storeTypeInterface = selected + } else if f.storeTypeID >= 0 { + f.storeTypeInterface = f.storeTypeID + } else if f.storeTypeName != "" { + f.storeTypeInterface = f.storeTypeName + } else { + log.Error().Err(InvalidInputError).Send() + return InvalidInputError + } + + // Set the default git ref if it is empty + if f.gitRef == "" { + f.gitRef = "main" + } + + // Set the output type to full unless genericFormat is true + f.outputType = "full" + if f.genericFormat { + f.outputType = "generic" + } + + // If outputToIntegrationManifest is true, set the output type to generic + if f.outputToIntegrationManifest { + f.outputType = "generic" + } + + log.Debug().Msg("complete: storeTypesGetFlags.Validate") + return nil +} + +func formatStoreTypeOutput(storeType *api.CertificateStoreType, outputFormat string, outputType string) (string, error) { + var sOut interface{} + sOut = storeType + if outputType == "generic" { + // Convert to api.GenericCertificateStoreType + var genericProperties []api.StoreTypePropertyDefinitionGeneric + for _, prop := range *storeType.Properties { + genericProp := api.StoreTypePropertyDefinitionGeneric{ + Name: prop.Name, + DisplayName: prop.DisplayName, + Type: prop.Type, + DependsOn: prop.DependsOn, + DefaultValue: prop.DefaultValue, + Required: prop.Required, + } + genericProperties = append(genericProperties, genericProp) + } + + var genericEntryParameters []api.EntryParameterGeneric + for _, param := range *storeType.EntryParameters { + genericParam := api.EntryParameterGeneric{ + Name: param.Name, + DisplayName: param.DisplayName, + Type: param.Type, + RequiredWhen: param.RequiredWhen, + DependsOn: param.DependsOn, + DefaultValue: param.DefaultValue, + Options: param.Options, + } + genericEntryParameters = append(genericEntryParameters, genericParam) + } + + genericStoreType := api.CertificateStoreTypeGeneric{ + Name: storeType.Name, + ShortName: storeType.ShortName, + Capability: storeType.Capability, + SupportedOperations: storeType.SupportedOperations, + Properties: &genericProperties, + EntryParameters: &genericEntryParameters, + PasswordOptions: storeType.PasswordOptions, + //StorePathType: storeType.StorePathType, + StorePathValue: storeType.StorePathValue, + PrivateKeyAllowed: storeType.PrivateKeyAllowed, + //JobProperties: jobProperties, + ServerRequired: storeType.ServerRequired, + PowerShell: storeType.PowerShell, + BlueprintAllowed: storeType.BlueprintAllowed, + CustomAliasAllowed: storeType.CustomAliasAllowed, + } + sOut = genericStoreType + } + + switch { + case outputFormat == "yaml" || outputFormat == "yml": + output, jErr := yaml.Marshal(sOut) + if jErr != nil { + return "", jErr + } + return fmt.Sprintf("%s", output), nil + default: + output, jErr := json.MarshalIndent(sOut, "", " ") + if jErr != nil { + return "", jErr + } + return fmt.Sprintf("%s", output), nil + } +} + +const ( + StoreTypesGetUsage = `get [-i | -n ] [-b ] [-g | --output-to-integration-manifest]` + StoreTypesGetShort = `Get a specific store type by either name or ID.` + StoreTypesGetLong = StoreTypesGetShort +) diff --git a/cmd/storeTypes_get_test.go b/cmd/storeTypes_get_test.go new file mode 100644 index 0000000..735a2be --- /dev/null +++ b/cmd/storeTypes_get_test.go @@ -0,0 +1,114 @@ +/* +Copyright 2023 The Keyfactor Command 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 cmd + +import ( + "encoding/json" + "github.com/stretchr/testify/assert" + "kfutil/pkg/cmdtest" + manifestv1 "kfutil/pkg/keyfactor/v1" + "os" + "testing" +) + +func Test_StoreTypesGet(t *testing.T) { + t.Run("WithName", func(t *testing.T) { + testCmd := RootCmd + + output, err := cmdtest.TestExecuteCommand(t, testCmd, []string{"store-types", "get", "--name", "PEM", "--debug"}...) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + var storeType map[string]interface{} + if err := json.Unmarshal([]byte(output), &storeType); err != nil { + t.Fatalf("Error unmarshalling JSON: %v", err) + } + + assert.NotNil(t, storeType["Name"], "Expected store type to have a name") + assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name") + assert.NotNil(t, storeType["StoreType"], "Expected store type to have a store type") + + // verify that the store type is an integer + _, ok := storeType["StoreType"].(float64) + assert.True(t, ok, "Expected store type to be an integer") + // verify short name is a string + _, ok = storeType["ShortName"].(string) + assert.True(t, ok, "Expected short name to be a string") + // verify name is a string + _, ok = storeType["Name"].(string) + assert.True(t, ok, "Expected name to be a string") + // check that shortname == AWS + assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") + }) + + t.Run("GenericOutput", func(t *testing.T) { + testCmd := RootCmd + output, err := cmdtest.TestExecuteCommand(t, testCmd, []string{"store-types", "get", "--name", "PEM", "-g", "--debug"}...) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + var storeType map[string]interface{} + if err := json.Unmarshal(output, &storeType); err != nil { + t.Fatalf("Error unmarshalling JSON: %v", err) + } + + assert.NotNil(t, storeType["Name"], "Expected store type to have a Name") + assert.NotNil(t, storeType["ShortName"], "Expected store type to have ShortName") + + assert.Nil(t, storeType["StoreType"], "Expected StoreType to to be nil") + assert.Nil(t, storeType["InventoryJobType"], "Expected InventoryJobType to be nil") + assert.Nil(t, storeType["InventoryEndpoint"], "Expected InventoryEndpoint to be nil") + assert.Nil(t, storeType["ManagementJobType"], "Expected ManagementJobType to be nil") + assert.Nil(t, storeType["DiscoveryJobType"], "Expected DiscoveryJobType to be nil") + assert.Nil(t, storeType["EnrollmentJobType"], "Expected EnrollmentJobType to be nil") + assert.Nil(t, storeType["ImportType"], "Expected ImportType to be nil") + + // verify short name is a string + _, ok := storeType["ShortName"].(string) + assert.True(t, ok, "Expected short name to be a string") + // verify name is a string + _, ok = storeType["Name"].(string) + assert.True(t, ok, "Expected name to be a string") + // check that shortname == PEM + assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") + }) + + t.Run("OutputToManifest", func(t *testing.T) { + testCmd := RootCmd + _, err := cmdtest.TestExecuteCommand(t, testCmd, []string{"store-types", "get", "--name", "PEM", "--output-to-integration-manifest", "--debug"}...) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + + // Verify that integration-manifest.json was created + manifest := manifestv1.IntegrationManifest{} + err = manifest.LoadFromFilesystem() + if err != nil { + t.Fatalf("Error loading integration manifest: %v", err) + } + + if len(manifest.About.Orchestrator.StoreTypes) != 1 { + t.Fatalf("Expected 1 store type, got %d", len(manifest.About.Orchestrator.StoreTypes)) + } + + // Clean up + err = os.Remove("integration-manifest.json") + if err != nil { + t.Errorf("Error removing integration-manifest.json: %v", err) + } + }) +} diff --git a/cmd/storeTypes_test.go b/cmd/storeTypes_test.go index 2bd93cd..cb46cb7 100644 --- a/cmd/storeTypes_test.go +++ b/cmd/storeTypes_test.go @@ -110,70 +110,6 @@ func Test_StoreTypesFetchTemplatesCmd(t *testing.T) { } } -func Test_StoreTypesGetCmd(t *testing.T) { - testCmd := RootCmd - // Attempt to get the AWS store type because it comes with the product - testCmd.SetArgs([]string{"store-types", "get", "--name", "PEM"}) - output := captureOutput(func() { - err := testCmd.Execute() - assert.NoError(t, err) - }) - var storeType map[string]interface{} - if err := json.Unmarshal([]byte(output), &storeType); err != nil { - t.Fatalf("Error unmarshalling JSON: %v", err) - } - - assert.NotNil(t, storeType["Name"], "Expected store type to have a name") - assert.NotNil(t, storeType["ShortName"], "Expected store type to have short name") - assert.NotNil(t, storeType["StoreType"], "Expected store type to have a store type") - - // verify that the store type is an integer - _, ok := storeType["StoreType"].(float64) - assert.True(t, ok, "Expected store type to be an integer") - // verify short name is a string - _, ok = storeType["ShortName"].(string) - assert.True(t, ok, "Expected short name to be a string") - // verify name is a string - _, ok = storeType["Name"].(string) - assert.True(t, ok, "Expected name to be a string") - // check that shortname == AWS - assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") -} - -func Test_StoreTypesGetGenericCmd(t *testing.T) { - testCmd := RootCmd - // Attempt to get the AWS store type because it comes with the product - testCmd.SetArgs([]string{"store-types", "get", "--name", "PEM", "--generic"}) - output := captureOutput(func() { - err := testCmd.Execute() - assert.NoError(t, err) - }) - var storeType map[string]interface{} - if err := json.Unmarshal([]byte(output), &storeType); err != nil { - t.Fatalf("Error unmarshalling JSON: %v", err) - } - - assert.NotNil(t, storeType["Name"], "Expected store type to have a Name") - assert.NotNil(t, storeType["ShortName"], "Expected store type to have ShortName") - - assert.Nil(t, storeType["StoreType"], "Expected StoreType to to be nil") - assert.Nil(t, storeType["InventoryJobType"], "Expected InventoryJobType to be nil") - assert.Nil(t, storeType["InventoryEndpoint"], "Expected InventoryEndpoint to be nil") - assert.Nil(t, storeType["ManagementJobType"], "Expected ManagementJobType to be nil") - assert.Nil(t, storeType["DiscoveryJobType"], "Expected DiscoveryJobType to be nil") - assert.Nil(t, storeType["EnrollmentJobType"], "Expected EnrollmentJobType to be nil") - assert.Nil(t, storeType["ImportType"], "Expected ImportType to be nil") - - // verify short name is a string - _, ok := storeType["ShortName"].(string) - assert.True(t, ok, "Expected short name to be a string") - // verify name is a string - _, ok = storeType["Name"].(string) - assert.True(t, ok, "Expected name to be a string") - // check that shortname == PEM - assert.Equal(t, storeType["ShortName"], "PEM", "Expected short name to be PEM") -} - func Test_StoreTypesCreateFromTemplatesCmd(t *testing.T) { testCmd := RootCmd // test diff --git a/docs/kfutil.md b/docs/kfutil.md index 811cfe8..17dc9ed 100644 --- a/docs/kfutil.md +++ b/docs/kfutil.md @@ -16,7 +16,7 @@ A CLI wrapper around the Keyfactor Platform API. --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") -h, --help help for kfutil --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) @@ -30,6 +30,7 @@ A CLI wrapper around the Keyfactor Platform API. * [kfutil containers](kfutil_containers.md) - Keyfactor certificate store container API and utilities. * [kfutil export](kfutil_export.md) - Keyfactor instance export utilities. +* [kfutil helm](kfutil_helm.md) - Helm utilities for configuring Keyfactor Helm charts * [kfutil import](kfutil_import.md) - Keyfactor instance import utilities. * [kfutil logout](kfutil_logout.md) - Removes the credentials file '$HOME/.keyfactor/command_config.json'. * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. @@ -39,4 +40,4 @@ A CLI wrapper around the Keyfactor Platform API. * [kfutil stores](kfutil_stores.md) - Keyfactor certificate stores APIs and utilities. * [kfutil version](kfutil_version.md) - Shows version of kfutil -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_containers.md b/docs/kfutil_containers.md index e8132ba..18ba1df 100644 --- a/docs/kfutil_containers.md +++ b/docs/kfutil_containers.md @@ -22,7 +22,7 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -37,4 +37,4 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s * [kfutil containers get](kfutil_containers_get.md) - Get certificate store container by ID or name. * [kfutil containers list](kfutil_containers_list.md) - List certificate store containers. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_containers_get.md b/docs/kfutil_containers_get.md index 38226a1..ee74716 100644 --- a/docs/kfutil_containers_get.md +++ b/docs/kfutil_containers_get.md @@ -27,7 +27,7 @@ kfutil containers get [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil containers get [flags] * [kfutil containers](kfutil_containers.md) - Keyfactor certificate store container API and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_containers_list.md b/docs/kfutil_containers_list.md index 53312dd..49553aa 100644 --- a/docs/kfutil_containers_list.md +++ b/docs/kfutil_containers_list.md @@ -26,7 +26,7 @@ kfutil containers list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil containers list [flags] * [kfutil containers](kfutil_containers.md) - Keyfactor certificate store container API and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_export.md b/docs/kfutil_export.md index 8ec7bf1..856a683 100644 --- a/docs/kfutil_export.md +++ b/docs/kfutil_export.md @@ -38,7 +38,7 @@ kfutil export [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -51,4 +51,4 @@ kfutil export [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_helm.md b/docs/kfutil_helm.md index c5a60e4..6f0c7c1 100644 --- a/docs/kfutil_helm.md +++ b/docs/kfutil_helm.md @@ -1,10 +1,10 @@ ## kfutil helm -Keyfactor Helm Chart Utilities +Helm utilities for configuring Keyfactor Helm charts ### Synopsis -Keyfactor Helm Chart Utilities used to configure charts and assist in the deployment of Keyfactor products. +Helm utilities for configuring Keyfactor Helm charts ### Examples @@ -21,21 +21,25 @@ kubectl helm uo | helm install -f - keyfactor-universal-orchestrator keyfactor/k ### Options inherited from parent commands ``` - --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") - --config string Full path to config file in JSON format. (default is $HOME/.keyfactor/command_config.json) - --debug Enable debug logging. (USE AT YOUR OWN RISK, this may log sensitive information to the console.) - --domain string Domain to use for authenticating to Keyfactor Command. - --exp Enable experimental features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --hostname string Hostname to use for authenticating to Keyfactor Command. - --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. - --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing password here in plain text. - --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. - --username string Username to use for authenticating to Keyfactor Command. + --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") + --auth-provider-profile string The profile to use defined in the securely stored config. If not specified the config named 'default' will be used if it exists. (default "default") + --auth-provider-type string Provider type choices: (azid) + --config string Full path to config file in JSON format. (default is $HOME/.keyfactor/command_config.json) + --debug Enable debugFlag logging. + --domain string Domain to use for authenticating to Keyfactor Command. + --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) + --format text How to format the CLI output. Currently only text is supported. (default "text") + --hostname string Hostname to use for authenticating to Keyfactor Command. + --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) + --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. + --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing kfcPassword here in plain text. + --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. + --username string Username to use for authenticating to Keyfactor Command. ``` ### SEE ALSO * [kfutil](kfutil.md) - Keyfactor CLI utilities -* [kfutil helm uo](kfutil_helm_uo.md) - Keyfactor Helm Chart Utilities for the Containerized Universal Orchestrator +* [kfutil helm uo](kfutil_helm_uo.md) - Configure the Keyfactor Universal Orchestrator Helm Chart -###### Auto generated by spf13/cobra on 3-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_helm_uo.md b/docs/kfutil_helm_uo.md index 19bfc4b..37984b3 100644 --- a/docs/kfutil_helm_uo.md +++ b/docs/kfutil_helm_uo.md @@ -16,30 +16,34 @@ kfutil helm uo [-t ] [-o ] [-f ] [-e @. If no version is specified, the latest version will be downloaded. - -h, --help help for uo - -o, --out string Path to output the modified values.yaml file. This file can then be used with helm install -f to override the default values. - -t, --token string Token used for related authentication - required for private repositories - -f, --values strings Filename, directory, or URL to a default values.yaml file to use for the chart + -e, --extension strings List of extensions to install. Should be in the format @. If no version is specified, the latest version will be downloaded. + -h, --help help for uo + -o, --out string Path to output the modified values.yaml file. This file can then be used with helm install -f to override the default values. + -t, --token string Token used for related authentication - required for private repositories + -f, --values strings Filename, directory, or URL to a default values.yaml file to use for the chart ``` ### Options inherited from parent commands ``` - --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") - --config string Full path to config file in JSON format. (default is $HOME/.keyfactor/command_config.json) - --debug Enable debug logging. (USE AT YOUR OWN RISK, this may log sensitive information to the console.) - --domain string Domain to use for authenticating to Keyfactor Command. - --exp Enable experimental features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --hostname string Hostname to use for authenticating to Keyfactor Command. - --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. - --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing password here in plain text. - --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. - --username string Username to use for authenticating to Keyfactor Command. + --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") + --auth-provider-profile string The profile to use defined in the securely stored config. If not specified the config named 'default' will be used if it exists. (default "default") + --auth-provider-type string Provider type choices: (azid) + --config string Full path to config file in JSON format. (default is $HOME/.keyfactor/command_config.json) + --debug Enable debugFlag logging. + --domain string Domain to use for authenticating to Keyfactor Command. + --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) + --format text How to format the CLI output. Currently only text is supported. (default "text") + --hostname string Hostname to use for authenticating to Keyfactor Command. + --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) + --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. + --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing kfcPassword here in plain text. + --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. + --username string Username to use for authenticating to Keyfactor Command. ``` ### SEE ALSO * [kfutil helm](kfutil_helm.md) - Helm utilities for configuring Keyfactor Helm charts -###### Auto generated by spf13/cobra on 3-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_import.md b/docs/kfutil_import.md index 8ecabaf..e93526c 100644 --- a/docs/kfutil_import.md +++ b/docs/kfutil_import.md @@ -37,7 +37,7 @@ kfutil import [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -50,4 +50,4 @@ kfutil import [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_logout.md b/docs/kfutil_logout.md index 5d18142..6699e58 100644 --- a/docs/kfutil_logout.md +++ b/docs/kfutil_logout.md @@ -26,7 +26,7 @@ kfutil logout [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil logout [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs.md b/docs/kfutil_orchs.md index 33cb758..b1ca1c8 100644 --- a/docs/kfutil_orchs.md +++ b/docs/kfutil_orchs.md @@ -22,7 +22,7 @@ A collections of APIs and utilities for interacting with Keyfactor orchestrators --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -36,9 +36,10 @@ A collections of APIs and utilities for interacting with Keyfactor orchestrators * [kfutil](kfutil.md) - Keyfactor CLI utilities * [kfutil orchs approve](kfutil_orchs_approve.md) - Approve orchestrator by machine/client name. * [kfutil orchs disapprove](kfutil_orchs_disapprove.md) - Disapprove orchestrator by machine/client name. +* [kfutil orchs ext](kfutil_orchs_ext.md) - Download and configure extensions for Keyfactor Command Universal Orchestrator * [kfutil orchs get](kfutil_orchs_get.md) - Get orchestrator by machine/client name. * [kfutil orchs list](kfutil_orchs_list.md) - List orchestrators. * [kfutil orchs logs](kfutil_orchs_logs.md) - Get orchestrator logs by machine/client name. * [kfutil orchs reset](kfutil_orchs_reset.md) - Reset orchestrator by machine/client name. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_approve.md b/docs/kfutil_orchs_approve.md index 621856d..d0a6f29 100644 --- a/docs/kfutil_orchs_approve.md +++ b/docs/kfutil_orchs_approve.md @@ -27,7 +27,7 @@ kfutil orchs approve [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil orchs approve [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_disapprove.md b/docs/kfutil_orchs_disapprove.md index 827015f..959f1e7 100644 --- a/docs/kfutil_orchs_disapprove.md +++ b/docs/kfutil_orchs_disapprove.md @@ -27,7 +27,7 @@ kfutil orchs disapprove [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil orchs disapprove [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_ext.md b/docs/kfutil_orchs_ext.md index 1ab442d..b02a176 100644 --- a/docs/kfutil_orchs_ext.md +++ b/docs/kfutil_orchs_ext.md @@ -23,33 +23,37 @@ ext -t -e @,@ -o ./app/extension ### Options ``` - -c, --config strings Filename, directory, or URL to an extension configuration file to use for the extension - -y, --confirm Automatically confirm the download of extensions - -e, --extensions strings List of extensions to download. Should be in the format :. If no version is specified, the latest official version will be downloaded. - -h, --help help for ext - --org string Github organization to download extensions from. Default is keyfactor. - -o, --out string Path to the extensions directory to download extensions into. Default is ./extensions - -P, --prune Remove extensions from the extensions directory that are not in the extension configuration file or specified on the command line - -t, --token string Token used for related authentication - required for private repositories - -u, --update Update existing extensions if they are out of date. + -c, --config strings Filename, directory, or URL to an extension configuration file to use for the extension + -y, --confirm Automatically confirm the download of extensions + -e, --extension strings List of extensions to download. Should be in the format @. If no version is specified, the latest official version will be downloaded. + -h, --help help for ext + --org string Github organization to download extensions from. Default is keyfactor. + -o, --out string Path to the extensions directory to download extensions into. Default is ./extensions + -P, --prune Remove extensions from the extensions directory that are not in the extension configuration file or specified on the command line + -t, --token string Token used for related authentication - required for private repositories + -u, --update Update existing extensions if they are out of date. ``` ### Options inherited from parent commands ``` - --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") - --debug Enable debug logging. (USE AT YOUR OWN RISK, this may log sensitive information to the console.) - --domain string Domain to use for authenticating to Keyfactor Command. - --exp Enable experimental features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --hostname string Hostname to use for authenticating to Keyfactor Command. - --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. - --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing password here in plain text. - --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. - --username string Username to use for authenticating to Keyfactor Command. + --api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI") + --auth-provider-profile string The profile to use defined in the securely stored config. If not specified the config named 'default' will be used if it exists. (default "default") + --auth-provider-type string Provider type choices: (azid) + --debug Enable debugFlag logging. + --domain string Domain to use for authenticating to Keyfactor Command. + --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) + --format text How to format the CLI output. Currently only text is supported. (default "text") + --hostname string Hostname to use for authenticating to Keyfactor Command. + --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) + --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. + --password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing kfcPassword here in plain text. + --profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists. + --username string Username to use for authenticating to Keyfactor Command. ``` ### SEE ALSO * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 3-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_get.md b/docs/kfutil_orchs_get.md index bb490cd..df00c3d 100644 --- a/docs/kfutil_orchs_get.md +++ b/docs/kfutil_orchs_get.md @@ -27,7 +27,7 @@ kfutil orchs get [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil orchs get [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_list.md b/docs/kfutil_orchs_list.md index 0c420c2..82bc7bb 100644 --- a/docs/kfutil_orchs_list.md +++ b/docs/kfutil_orchs_list.md @@ -26,7 +26,7 @@ kfutil orchs list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil orchs list [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_logs.md b/docs/kfutil_orchs_logs.md index 3433e11..9f5d37e 100644 --- a/docs/kfutil_orchs_logs.md +++ b/docs/kfutil_orchs_logs.md @@ -27,7 +27,7 @@ kfutil orchs logs [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil orchs logs [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_orchs_reset.md b/docs/kfutil_orchs_reset.md index d1bab35..adb3545 100644 --- a/docs/kfutil_orchs_reset.md +++ b/docs/kfutil_orchs_reset.md @@ -27,7 +27,7 @@ kfutil orchs reset [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil orchs reset [flags] * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam.md b/docs/kfutil_pam.md index 60bfd07..c48fe7f 100644 --- a/docs/kfutil_pam.md +++ b/docs/kfutil_pam.md @@ -24,7 +24,7 @@ programmatically create, delete, edit, and list PAM Providers. --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -44,4 +44,4 @@ programmatically create, delete, edit, and list PAM Providers. * [kfutil pam types-list](kfutil_pam_types-list.md) - Returns a list of all available PAM provider types. * [kfutil pam update](kfutil_pam_update.md) - Updates an existing PAM Provider, currently only supported from file. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_create.md b/docs/kfutil_pam_create.md index 5a43452..0c385a4 100644 --- a/docs/kfutil_pam_create.md +++ b/docs/kfutil_pam_create.md @@ -27,7 +27,7 @@ kfutil pam create [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil pam create [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_delete.md b/docs/kfutil_pam_delete.md index 72b6db0..d9336fe 100644 --- a/docs/kfutil_pam_delete.md +++ b/docs/kfutil_pam_delete.md @@ -27,7 +27,7 @@ kfutil pam delete [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil pam delete [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_get.md b/docs/kfutil_pam_get.md index d604669..f5c6f1f 100644 --- a/docs/kfutil_pam_get.md +++ b/docs/kfutil_pam_get.md @@ -27,7 +27,7 @@ kfutil pam get [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil pam get [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_list.md b/docs/kfutil_pam_list.md index 93192dd..4586851 100644 --- a/docs/kfutil_pam_list.md +++ b/docs/kfutil_pam_list.md @@ -26,7 +26,7 @@ kfutil pam list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil pam list [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_types-create.md b/docs/kfutil_pam_types-create.md index 1596092..cbe1e16 100644 --- a/docs/kfutil_pam_types-create.md +++ b/docs/kfutil_pam_types-create.md @@ -34,7 +34,7 @@ kfutil pam types-create [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -47,4 +47,4 @@ kfutil pam types-create [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_types-list.md b/docs/kfutil_pam_types-list.md index 67a85fd..16bc1ca 100644 --- a/docs/kfutil_pam_types-list.md +++ b/docs/kfutil_pam_types-list.md @@ -26,7 +26,7 @@ kfutil pam types-list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil pam types-list [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_pam_update.md b/docs/kfutil_pam_update.md index b94ade6..71e2e32 100644 --- a/docs/kfutil_pam_update.md +++ b/docs/kfutil_pam_update.md @@ -27,7 +27,7 @@ kfutil pam update [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil pam update [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_status.md b/docs/kfutil_status.md index d38b4e8..6a343e9 100644 --- a/docs/kfutil_status.md +++ b/docs/kfutil_status.md @@ -26,7 +26,7 @@ kfutil status [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil status [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types.md b/docs/kfutil_store-types.md index 3f86087..573c687 100644 --- a/docs/kfutil_store-types.md +++ b/docs/kfutil_store-types.md @@ -22,7 +22,7 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s * [kfutil store-types list](kfutil_store-types_list.md) - List certificate store types. * [kfutil store-types templates-fetch](kfutil_store-types_templates-fetch.md) - Fetches store type templates from Keyfactor's Github. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types_create.md b/docs/kfutil_store-types_create.md index 0f62092..2727116 100644 --- a/docs/kfutil_store-types_create.md +++ b/docs/kfutil_store-types_create.md @@ -18,7 +18,7 @@ kfutil store-types create [flags] -b, --git-ref string The git branch or tag to reference when pulling store-types from the internet. (default "main") -h, --help help for create -l, --list List valid store types. - -n, --name string Short name of the certificate store type to get. Valid choices are: AKV, AzureApp, AzureAppGW, AzureSP, Fortigate, HCVKV, HCVPKI, IISU, K8SCert, K8SCluster, K8SJKS, K8SNS, K8SPKCS12, K8SSecret, K8STLSSecr, RFDER, RFJKS, RFKDB, RFORA, RFPEM, RFPkcs12, SAMPLETYPE, Signum, VMware-NSX, WinCerMgmt, WinCert + -n, --name string Short name of the certificate store type to get. Valid choices are: AKV, AzureApp, AzureAppGW, AzureSP, Fortigate, HCVKV, HCVKVJKS, HCVKVP12, HCVKVPEM, HCVKVPFX, HCVPKI, IISU, K8SCert, K8SCluster, K8SJKS, K8SNS, K8SPKCS12, K8SSecret, K8STLSSecr, RFDER, RFJKS, RFKDB, RFORA, RFPEM, RFPkcs12, SAMPLETYPE, Signum, VMware-NSX, WinCerMgmt, WinCert ``` ### Options inherited from parent commands @@ -31,7 +31,7 @@ kfutil store-types create [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -44,4 +44,4 @@ kfutil store-types create [flags] * [kfutil store-types](kfutil_store-types.md) - Keyfactor certificate store types APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types_delete.md b/docs/kfutil_store-types_delete.md index bd8ca96..d22e7e9 100644 --- a/docs/kfutil_store-types_delete.md +++ b/docs/kfutil_store-types_delete.md @@ -30,7 +30,7 @@ kfutil store-types delete [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -43,4 +43,4 @@ kfutil store-types delete [flags] * [kfutil store-types](kfutil_store-types.md) - Keyfactor certificate store types APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types_get.md b/docs/kfutil_store-types_get.md index ba0c173..37158fe 100644 --- a/docs/kfutil_store-types_get.md +++ b/docs/kfutil_store-types_get.md @@ -7,17 +7,18 @@ Get a specific store type by either name or ID. Get a specific store type by either name or ID. ``` -kfutil store-types get [flags] +kfutil store-types get [-i | -n ] [-g] [-b ] [-o] [flags] ``` ### Options ``` - -g, --generic Output the store type in a generic format stripped of all fields specific to the Command instance. - -b, --git-ref string The git branch or tag to reference when pulling store-types from the internet. (default "main") - -h, --help help for get - -i, --id int ID of the certificate store type to get. (default -1) - -n, --name string Name of the certificate store type to get. + -g, --generic Output the store type in a generic format stripped of all fields specific to the Command instance. + -b, --git-ref string The git branch or tag to reference when pulling store-types from the internet. (default "main") + -h, --help help for get + -i, --id int ID of the certificate store type to get. (default -1) + -n, --name string Name of the certificate store type to get. + --output-to-integration-manifest Update the integration manifest with the store type. It overrides the store type in the manifest if it already exists. If the integration manifest does not exist in the current directory, it will be created. ``` ### Options inherited from parent commands @@ -30,7 +31,7 @@ kfutil store-types get [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -43,4 +44,4 @@ kfutil store-types get [flags] * [kfutil store-types](kfutil_store-types.md) - Keyfactor certificate store types APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types_list.md b/docs/kfutil_store-types_list.md index b70fc58..b2f1ee9 100644 --- a/docs/kfutil_store-types_list.md +++ b/docs/kfutil_store-types_list.md @@ -26,7 +26,7 @@ kfutil store-types list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil store-types list [flags] * [kfutil store-types](kfutil_store-types.md) - Keyfactor certificate store types APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_store-types_templates-fetch.md b/docs/kfutil_store-types_templates-fetch.md index 0e49250..9c1779e 100644 --- a/docs/kfutil_store-types_templates-fetch.md +++ b/docs/kfutil_store-types_templates-fetch.md @@ -13,7 +13,8 @@ kfutil store-types templates-fetch [flags] ### Options ``` - -h, --help help for templates-fetch + -b, --git-ref string The git branch or tag to reference when pulling store-types from the internet. (default "main") + -h, --help help for templates-fetch ``` ### Options inherited from parent commands @@ -26,7 +27,7 @@ kfutil store-types templates-fetch [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +40,4 @@ kfutil store-types templates-fetch [flags] * [kfutil store-types](kfutil_store-types.md) - Keyfactor certificate store types APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores.md b/docs/kfutil_stores.md index 1f0bd1a..5514e70 100644 --- a/docs/kfutil_stores.md +++ b/docs/kfutil_stores.md @@ -22,7 +22,7 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -42,4 +42,4 @@ A collections of APIs and utilities for interacting with Keyfactor certificate s * [kfutil stores list](kfutil_stores_list.md) - List certificate stores. * [kfutil stores rot](kfutil_stores_rot.md) - Root of trust utility -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_delete.md b/docs/kfutil_stores_delete.md index cc081dc..83376a5 100644 --- a/docs/kfutil_stores_delete.md +++ b/docs/kfutil_stores_delete.md @@ -28,7 +28,7 @@ kfutil stores delete [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -41,4 +41,4 @@ kfutil stores delete [flags] * [kfutil stores](kfutil_stores.md) - Keyfactor certificate stores APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_export.md b/docs/kfutil_stores_export.md index 09824c5..5db501e 100644 --- a/docs/kfutil_stores_export.md +++ b/docs/kfutil_stores_export.md @@ -29,7 +29,7 @@ kfutil stores export [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -42,4 +42,4 @@ kfutil stores export [flags] * [kfutil stores](kfutil_stores.md) - Keyfactor certificate stores APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_get.md b/docs/kfutil_stores_get.md index 079b342..8862379 100644 --- a/docs/kfutil_stores_get.md +++ b/docs/kfutil_stores_get.md @@ -27,7 +27,7 @@ kfutil stores get [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -40,4 +40,4 @@ kfutil stores get [flags] * [kfutil stores](kfutil_stores.md) - Keyfactor certificate stores APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_import.md b/docs/kfutil_stores_import.md index 270457b..917e089 100644 --- a/docs/kfutil_stores_import.md +++ b/docs/kfutil_stores_import.md @@ -22,7 +22,7 @@ Tools for generating import templates and importing certificate stores --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -37,4 +37,4 @@ Tools for generating import templates and importing certificate stores * [kfutil stores import csv](kfutil_stores_import_csv.md) - Create certificate stores from CSV file. * [kfutil stores import generate-template](kfutil_stores_import_generate-template.md) - For generating a CSV template with headers for bulk store creation. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_import_csv.md b/docs/kfutil_stores_import_csv.md index 24fde15..02648b5 100644 --- a/docs/kfutil_stores_import_csv.md +++ b/docs/kfutil_stores_import_csv.md @@ -34,7 +34,7 @@ kfutil stores import csv --file --store-type-id --store-type-id --store-t --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -45,4 +45,4 @@ kfutil stores import generate-template --store-type-id --store-t * [kfutil stores import](kfutil_stores_import.md) - Import a file with certificate store parameters and create them in keyfactor. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_inventory.md b/docs/kfutil_stores_inventory.md index 9f8b972..7eba851 100644 --- a/docs/kfutil_stores_inventory.md +++ b/docs/kfutil_stores_inventory.md @@ -22,7 +22,7 @@ Commands related to certificate store inventory management --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -38,4 +38,4 @@ Commands related to certificate store inventory management * [kfutil stores inventory remove](kfutil_stores_inventory_remove.md) - Removes a certificate from the certificate store inventory. * [kfutil stores inventory show](kfutil_stores_inventory_show.md) - Show the inventory of a certificate store. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_inventory_add.md b/docs/kfutil_stores_inventory_add.md index 724c5b0..0bfe300 100644 --- a/docs/kfutil_stores_inventory_add.md +++ b/docs/kfutil_stores_inventory_add.md @@ -40,7 +40,7 @@ kfutil stores inventory add [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -53,4 +53,4 @@ kfutil stores inventory add [flags] * [kfutil stores inventory](kfutil_stores_inventory.md) - Commands related to certificate store inventory management -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_inventory_remove.md b/docs/kfutil_stores_inventory_remove.md index f6972c0..0bfffc3 100644 --- a/docs/kfutil_stores_inventory_remove.md +++ b/docs/kfutil_stores_inventory_remove.md @@ -36,7 +36,7 @@ kfutil stores inventory remove [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -49,4 +49,4 @@ kfutil stores inventory remove [flags] * [kfutil stores inventory](kfutil_stores_inventory.md) - Commands related to certificate store inventory management -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_inventory_show.md b/docs/kfutil_stores_inventory_show.md index 2044c31..5888bfd 100644 --- a/docs/kfutil_stores_inventory_show.md +++ b/docs/kfutil_stores_inventory_show.md @@ -30,7 +30,7 @@ kfutil stores inventory show [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -43,4 +43,4 @@ kfutil stores inventory show [flags] * [kfutil stores inventory](kfutil_stores_inventory.md) - Commands related to certificate store inventory management -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_list.md b/docs/kfutil_stores_list.md index c68c3bc..e23c6d6 100644 --- a/docs/kfutil_stores_list.md +++ b/docs/kfutil_stores_list.md @@ -26,7 +26,7 @@ kfutil stores list [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil stores list [flags] * [kfutil stores](kfutil_stores.md) - Keyfactor certificate stores APIs and utilities. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_rot.md b/docs/kfutil_stores_rot.md index 2d7f26f..d103ae8 100644 --- a/docs/kfutil_stores_rot.md +++ b/docs/kfutil_stores_rot.md @@ -34,7 +34,7 @@ kfutil stores rot reconcile --import-csv --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -50,4 +50,4 @@ kfutil stores rot reconcile --import-csv * [kfutil stores rot generate-template](kfutil_stores_rot_generate-template.md) - For generating Root Of Trust template(s) * [kfutil stores rot reconcile](kfutil_stores_rot_reconcile.md) - Reconcile either takes in or will generate an audit report and then add/remove certs as needed. -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_rot_audit.md b/docs/kfutil_stores_rot_audit.md index f64f109..278edb0 100644 --- a/docs/kfutil_stores_rot_audit.md +++ b/docs/kfutil_stores_rot_audit.md @@ -34,7 +34,7 @@ kfutil stores rot audit [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -47,4 +47,4 @@ kfutil stores rot audit [flags] * [kfutil stores rot](kfutil_stores_rot.md) - Root of trust utility -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_rot_generate-template.md b/docs/kfutil_stores_rot_generate-template.md index d059fb2..bc02377 100644 --- a/docs/kfutil_stores_rot_generate-template.md +++ b/docs/kfutil_stores_rot_generate-template.md @@ -45,4 +45,4 @@ kfutil stores rot generate-template [flags] * [kfutil stores rot](kfutil_stores_rot.md) - Root of trust utility -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_stores_rot_reconcile.md b/docs/kfutil_stores_rot_reconcile.md index 66b2632..a5e17e1 100644 --- a/docs/kfutil_stores_rot_reconcile.md +++ b/docs/kfutil_stores_rot_reconcile.md @@ -39,7 +39,7 @@ kfutil stores rot reconcile [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -52,4 +52,4 @@ kfutil stores rot reconcile [flags] * [kfutil stores rot](kfutil_stores_rot.md) - Root of trust utility -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/docs/kfutil_version.md b/docs/kfutil_version.md index 02f3da7..d9da81a 100644 --- a/docs/kfutil_version.md +++ b/docs/kfutil_version.md @@ -26,7 +26,7 @@ kfutil version [flags] --debug Enable debugFlag logging. --domain string Domain to use for authenticating to Keyfactor Command. --exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.) - --format string Output format. (text/json) (default "text") + --format text How to format the CLI output. Currently only text is supported. (default "text") --hostname string Hostname to use for authenticating to Keyfactor Command. --log-insecure Log insecure API requests. (USE AT YOUR OWN RISK, this WILL log sensitive information to the console.) --no-prompt Do not prompt for any user input and assume defaults or environmental variables are set. @@ -39,4 +39,4 @@ kfutil version [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 4-Oct-2023 +###### Auto generated by spf13/cobra on 9-Nov-2023 diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..d75619f --- /dev/null +++ b/install.ps1 @@ -0,0 +1,456 @@ +# Copyright 2023 The Keyfactor Command 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. + +<# +.SYNOPSIS +This script installs the Keyfactor Command Utility (kfutil). + +.DESCRIPTION +This script downloads and installs the Keyfactor Command Utility. It can be run +with or without administrator privileges. If run without administrator privileges, +the script will install the utility into the user's home directory. If run with +administrator privileges, the script can install the utility into a custom directory. + +.PARAMETER Uninstall +Indicates that the script should perform an uninstallation. + +.PARAMETER BinaryName +The name of the binary to install. Defaults to "kfutil". Don't change this unless +you know what you're doing. + +.PARAMETER Version +The version of the binary to install. If not specified, the script will install +the latest stable release. If specified, the script will install the specified +version. If the specified version is not a stable release, the script will warn +the user that the version is not stable. + +.PARAMETER InstallDir +The directory to install the binary into. If not specified, the script will +install the binary into the user's home directory. If specified, the script will +install the binary into the specified directory, but will require administrator +privileges to do so if the directory is not in the user's home directory. + +.PARAMETER VerifyChecksum +Indicates that the script should verify the SHA256 checksum of the downloaded +binary. Defaults to $true. + +.EXAMPLE +PS> .\install.ps1 +Installs the latest stable release of the Keyfactor Command Utility into the +user's home directory. + +.EXAMPLE +PS> .\install.ps1 -Version v1.0.0 -InstallDir C:\Windows\System32\WindowsPowerShell\v1.0 +Installs version 1.0.0 of the Keyfactor Command Utility into the specified directory. + +.EXAMPLE +PS> .\install.ps1 -Uninstall +Uninstalls the Keyfactor Command Utility from the directory in the PATH. + +.NOTES +Additional information about the script. + +.LINK +https://github.com/Keyfactor/kfutil + +#> + +param( + [string]$BinaryName = "kfutil", + [string]$Version, + [string]$InstallDir = [System.IO.Path]::Combine([System.Environment]::GetFolderPath("UserProfile"), "AppData", "Local", "Microsoft", "WindowsApps"), + [bool]$VerifyChecksum = $true, + [switch]$Uninstall +) + +function Get-Architecture { + param( [bool]$IsPowershellCore ) + # If script is running on PowerShell Core host, use uname + if ($IsPowershellCore) { + $ARCH = uname -m + + switch -Wildcard ($ARCH) { + "armv5*" { $ARCH = "armv5" } + "armv6*" { $ARCH = "armv6" } + "armv7*" { $ARCH = "arm" } + "aarch64" { $ARCH = "arm64" } + "arm64" { $ARCH = "arm64" } + "x86" { $ARCH = "386" } + "x86_64" { $ARCH = "amd64" } + "i686" { $ARCH = "386" } + "i386" { $ARCH = "386" } + } + + return $ARCH + } + + $ARCH = (Get-WmiObject Win32_Processor).Architecture + + switch ($ARCH) { + 0 { $ARCH = "386" } # x86 + 5 { $ARCH = "arm" } # ARM + 9 { $ARCH = "amd64" } # x64 + 12 { $ARCH = "arm64" } # ARM64 + default { $ARCH = "unknown" } + } + + # Return the architecture + return $ARCH +} + +function Get-OperatingSystem { + param ( [bool]$IsPowershellCore ) + [string]$OS = $null + + if ($IsPowershellCore) { + # If script is running on PowerShell Core host, use Automatic Variables + + if ($IsLinux) { + $OS = "linux" + } + elseif ($IsMacOS) { + $OS = "darwin" + } + elseif ($IsWindows) { + $OS = "windows" + } + } else { + # Otherwise, ask .NET for the OS description + + if ([System.Environment]::OSVersion.Platform -eq "Win32NT") { + $OS = "windows" + } + } + + # If we couldn't determine the OS, fail the installation + if ([string]::IsNullOrWhiteSpace($OS)) { + throw "Unable to determine operating system" + } + + # Return the OS + return $OS +} + +function Test-SupportedHost { + param ( + [string]$OS, + [string]$Architecture + ) + + $SupportedBuilds = @( + "darwin-amd64", + "darwin-arm64", + "linux-386", + "linux-amd64", + "linux-arm", + "linux-arm64", + "linux-ppc64le", + "linux-s390x", + "windows-386", + "windows-amd64", + "windows-arm", + "windows-arm64" + ) + + $matchFound = $false + foreach ($build in $supportedBuilds) { + if ("${build}" -eq "${OS}-${Architecture}") { + $matchFound = $true + break + } + } + + if (!$matchFound) { + throw "Unsupported operating system and architecture combination: ${OS}-${Architecture}" + } +} + +function Get-InstallVersion { + param ( + [string]$Version + ) + + [string]$SemVer = $null + + $RemoteReleaseUrl = "https://api.github.com/repos/keyfactor/$BinaryName/releases" + $Releases = (Invoke-WebRequest -UseBasicParsing $RemoteReleaseUrl | ConvertFrom-Json) + + if (![string]::IsNullOrWhiteSpace($Version)) { + # Strip the leading 'v' from the version string + $SemVer = $Version -replace '^v','' + + # Verify that the version exists as a release before continuing + $Release = $Releases | Where-Object { $_.tag_name -eq "v$SemVer" } + if ([string]::IsNullOrWhiteSpace($Release.tag_name)) { + throw "Cannot find release $Version for $BinaryName" + } + + Write-Host "$BinaryName version $Version exists" + } else { + # If no version was specified, get the latest release + $LatestRelease = $Releases | Where-Object { -not $_.prerelease } | Sort-Object -Property created_at -Descending | Select-Object -First 1 + $SemVer = $LatestRelease.tag_name -replace '^v','' + } + + return $SemVer +} + +function Test-IsVersionInstalled { + param ( + [string]$BinaryName, + [string]$Version + ) + + try { + $BinaryPath = (Get-Command $BinaryName -ErrorAction Stop).Path + + $InstalledVersion = [string](& $BinaryPath version).Split(' ')[-1] -replace '^v','' + if ($InstalledVersion -eq $Version) { + Write-Host "$BinaryName version $Version is already installed" + return $true + } else { + Write-Host "Changing from $BinaryName version $InstalledVersion to $Version" + return $false + } + } + catch { + return $false + } + + return $false +} + +function New-TempInstallDir { + # Get the base temporary folder + $BaseTempPath = [System.IO.Path]::GetTempPath() + + # Create a unique directory name with a prefix + $UniqueTempDir = [System.IO.Path]::Combine($BaseTempPath, "$BinaryName-installer-" + [Guid]::NewGuid().ToString()) + + # Create the directory + New-Item -ItemType Directory -Path $UniqueTempDir | Out-Null + + # Return the path + return $UniqueTempDir +} + +function Get-BinaryAndSum { + param ( + [string]$BaseTempDir, + [string]$BinaryName, + [string]$Version, + [string]$OS, + [string]$Architecture + ) + + $ReleaseUrl = "https://github.com/Keyfactor/${BinaryName}/releases/download/v${Version}" + $Dist = "${BinaryName}_${Version}_${OS}_${Architecture}.zip" + + $DistUrl = "${ReleaseUrl}/${Dist}" + $SumUrl = "${ReleaseUrl}/${BinaryName}_${Version}_SHA256SUMS" + + Write-Host "Downloading $BinaryName $Version for $OS-$Architecture" + + # Download the binary and checksum + $DistPath = [System.IO.Path]::Combine($BaseTempDir, $Dist) + $SumPath = [System.IO.Path]::Combine($BaseTempDir, "${BinaryName}.sum") + + Invoke-WebRequest -UseBasicParsing -OutFile $DistPath $DistUrl -ErrorAction Stop + Invoke-WebRequest -UseBasicParsing -OutFile $SumPath $SumUrl -ErrorAction Stop + + return @{ + dist = $Dist + dist_path = $DistPath + sum_path = $SumPath + } +} + +function Test-Checksum { + param ( + [string]$Dist, + [string]$DistPath, + [string]$SumPath + ) + + if (-not $VerifyChecksum) { + Write-Host "Skipping checksum verification" + return + } + + Write-Host "Verifying checksum... " -NoNewline + + # Extract the expected checksum from the SHA256SUMS file + $ExpectedSum = [string](Get-Content $SumPath | Select-String -Pattern $Dist | Select-Object -First 1 | ForEach-Object { $_.ToString().Split(' ')[0] }).ToUpper() + + # Calculate the actual checksum of the binary + $ActualSum = [string](Get-FileHash $DistPath -Algorithm SHA256 | Select-Object -ExpandProperty Hash).ToUpper() + + if ($ExpectedSum -ne $ActualSum) { + throw "SHA sum of $BinaryName binary does not match. Expected $ExpectedSum, got $ActualSum. Aborting." + } + + Write-Host "Done." +} + +function Install-Binary { + param ( + [string]$BaseTempDir, + [string]$DistPath, + [string]$InstallDir, + [string]$BinaryName, + [string]$Os + ) + + Write-Host "Preparing to install $BinaryName into ${InstallDir}" + + $TempBinDir = [System.IO.Path]::Combine($BaseTempDir, "bin") + + # Unzip the binary to the temp directory + Expand-Archive -Path $DistPath -DestinationPath $TempBinDir + + # Create the install directory if it doesn't exist + if (-not (Test-Path $InstallDir)) { + New-Item -ItemType Directory -Path $InstallDir | Out-Null + } + + # Adjust the binary name if we're on Windows + if ($Os -eq "windows") { + $BinaryName = $BinaryName + ".exe" + } + + # Copy the binary to the install directory + $TempBinDir = [System.IO.Path]::Combine($TempBinDir, $BinaryName) + Copy-Item -Path $TempBinDir -Destination $InstallDir -Recurse -Force -ErrorAction Stop + + Write-Host "$BinaryName installed into $([System.IO.Path]::Combine(${InstallDir},$BinaryName))" +} + +function Uninstall-Binary { + param ( + [string]$BinaryName + ) + + try { + Get-Command $BinaryName -ErrorAction Stop | Out-Null + } + catch { + Write-Warning "$BinaryName is not installed." + return + } + + $BinaryPath = (Get-Command $BinaryName).Path + + Write-Host "Uninstalling $BinaryName from $BinaryPath... " -NoNewline + + # Uninstall binary + Remove-Item -Path $BinaryPath -Recurse -Force + + + try { + Get-Command $BinaryName -ErrorAction Stop + } + catch { + Write-Host "Done." + return + } + + throw "$BinaryName is still installed. Uninstallation failed." +} + +function Test-InstalledVersion { + param ( + [string]$BinaryName, + [string]$Version, + [string]$InstallDir + ) + + try { + Get-Command $BinaryName -ErrorAction Stop | Out-Null + } + catch { + throw "$BinaryName not found. Is $InstallDir in your PATH?" + } + + $InstalledVersion = [string](& $BinaryName version).Split(' ')[-1] -replace '^v','' + if ($InstalledVersion -eq $Version) { + Write-Host "$BinaryName $Version is installed and available." + } else { + # If the Version is an RC or otherwise prerelease, we'll allow it to be installed + # but we'll warn the user that it's not the latest stable version + if ($Version -match "-" -and $Version.Split('-')[0] -eq $InstalledVersion) { + Write-Warning "$BinaryName $Version is installed, but is not an official release. Behavior may be unstable; use at your own risk." + return + } + + throw "Installed version of $BinaryName ($InstalledVersion) does not match requested version ($Version)" + } + + return +} + +function Clear-InstallArtifacts { + param ( + [string]$BaseTempDir + ) + + if ([string]::IsNullOrWhiteSpace($BaseTempDir)) { + return + } + + Write-Host "Cleaning up temporary files... " -NoNewline + + # Remove the temporary directory + Remove-Item -Path $BaseTempDir -Recurse -Force + + Write-Host "Done." +} + +try +{ + if ($Uninstall) { + Uninstall-Binary -BinaryName $BinaryName + exit 0 + } + + $isPowershellCore = $PSVersionTable.PSEdition -eq "Core" + $UniqueTempDir = $null + + # Get the architecture and operating system + $Architecture = Get-Architecture -IsPowershellCore $isPowershellCore + $Os = Get-OperatingSystem -IsPowershellCore $isPowershellCore + + # Verify that the host is supported, and deps on the host are met + Test-SupportedHost -OS $Os -Architecture $Architecture + + # Verify or get the version to install + $Version = Get-InstallVersion -Version $Version + + # Check if the binary is already installed + if (-Not (Test-IsVersionInstalled -BinaryName $BinaryName -Version $Version)) { + $UniqueTempDir = New-TempInstallDir + $files = Get-BinaryAndSum -BaseTempDir $UniqueTempDir -BinaryName $BinaryName -Version $Version -OS $Os -Architecture $Architecture + Test-Checksum -Dist $files.dist -DistPath $files.dist_path -SumPath $files.sum_path + Install-Binary -BaseTempDir $UniqueTempDir -DistPath $files.dist_path -InstallDir $InstallDir -BinaryName $BinaryName -Os $Os + + Test-InstalledVersion -BinaryName $BinaryName -Version $Version -InstallDir $InstallDir + } + + Clear-InstallArtifacts -BaseTempDir $UniqueTempDir +} +catch +{ + Write-Output $_ + Clear-InstallArtifacts -BaseTempDir $UniqueTempDir + exit 1 +} diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index 9ccd20a..d209422 --- a/install.sh +++ b/install.sh @@ -14,16 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Use parameter expansion to provide default values. : "${BINARY_NAME:=kfutil}" : "${USE_SUDO:=false}" : "${VERIFY_CHECKSUM:=true}" - -if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then - : "${KFUTIL_INSTALL_DIR:=/usr/local/bin}" - else - : "${KFUTIL_INSTALL_DIR:=${HOME}/.local/bin}" -fi - +: "${INSTALL_DIR:=${HOME}/.local/bin}" HAS_CURL="$(type "curl" &>/dev/null && echo true || echo false)" HAS_WGET="$(type "wget" &>/dev/null && echo true || echo false)" @@ -42,18 +37,20 @@ runAsRoot() { # fail_trap is executed if an error occurs. fail_trap() { - result=$? - if [ "$result" != "0" ]; then - if [[ ${#INPUT_ARGUMENTS[@]} -ne 0 ]]; then - echo "Failed to install $BINARY_NAME with the arguments provided: ${INPUT_ARGUMENTS[*]}" - usage - else - echo "Failed to install $BINARY_NAME" + result=$? + if [ "$result" != "0" ]; then + if [[ ${#INPUT_ARGUMENTS[@]} -ne 0 ]]; then + echo "Failed to install $BINARY_NAME with the arguments provided: ${INPUT_ARGUMENTS[*]}" + + usage + else + echo "Failed to install $BINARY_NAME" + fi + echo "" + echo -e "For support, go to https://github.com/Keyfactor/kfutil" fi - echo -e "For support, go to https://github.com/Keyfactor/kfutil" - fi - cleanup - exit $result + cleanup + exit $result } # Get host architecture @@ -73,12 +70,12 @@ initArch() { # Get host OS initOS() { - OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') + OS=$(echo $(uname) | tr '[:upper:]' '[:lower:]') - case "$OS" in + case "$OS" in # Minimalist GNU for Windows - mingw*|cygwin*) OS='windows';; - esac + mingw* | cygwin*) OS='windows' ;; + esac } # Verify that the host OS/Arch is supported @@ -92,7 +89,6 @@ verifySupported() { "linux-arm64" "linux-ppc64le" "linux-s390x" - "windows-amd64" ) match_found=false @@ -110,7 +106,7 @@ verifySupported() { fi if [ "${HAS_CURL}" != "true" ] && [ "${HAS_WGET}" != "true" ]; then - echo "Either curl or wget is required" + echo "Either curl or wget is required." exit 1 fi @@ -118,7 +114,7 @@ verifySupported() { echo "jq is required" exit 1 fi - + if [ "${HAS_UNZIP}" != "true" ]; then echo "unzip is required" exit 1 @@ -155,30 +151,30 @@ getVersion() { VERSION=$(echo "$VERSION" | tr -d 'v') # Verify that the version exists as a release before continuing - if ! echo "$releases_response" | jq '.[] | select(.tag_name == "v'"$VERSION"'")' >/dev/null; then + if ! echo "$releases_response" | jq '.[] | select(.tag_name == "v'"$VERSION"'")' >/dev/null; then printf "Cannot find release '%s' for %s.\n" "$VERSION" "$remote_release_url" exit 1 else - echo "kfutil version $VERSION exists" + echo "$BINARY_NAME version $VERSION exists" fi fi } -# checkkfutilInstalledVersion checks which version of kfutil is installed and +# checkBinaryInstalledVersion checks which version of kfutil is installed and # if it needs to be changed. -checkkfutilInstalledVersion() { - if [[ -f "${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" ]]; then +checkBinaryInstalledVersion() { + if [[ -f "${INSTALL_DIR}/${BINARY_NAME}" ]]; then local version - version=$("${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" version) + version=$("${INSTALL_DIR}/${BINARY_NAME}" version) raw_version=$version version=${raw_version#*version } version=${version%%\%*} version=$(echo "$version" | tr -d 'v') if [[ "$version" == "$VERSION" ]]; then - echo "kfutil ${version} is already installed" + echo "kfutil ${version} is already installed in ${INSTALL_DIR}/${BINARY_NAME}" return 0 else - echo "Changing from kfutil 'v${version}' to 'v${VERSION}'." + echo "Changing from ${BINARY_NAME} 'v${version}' to 'v${VERSION}'." return 1 fi else @@ -190,7 +186,7 @@ checkkfutilInstalledVersion() { downloadFile() { local download_url local base_url - base_url="https://github.com/Keyfactor/kfutil/releases/download/v${VERSION}" + base_url="https://github.com/Keyfactor/${BINARY_NAME}/releases/download/v${VERSION}" KFUTIL_DIST="kfutil_${VERSION}_${OS}_${ARCH}.zip" download_url="${base_url}/${KFUTIL_DIST}" checksum_url="${base_url}/kfutil_${VERSION}_SHA256SUMS" @@ -211,6 +207,11 @@ downloadFile() { # verifyChecksum verifies the SHA256 checksum of the binary package. verifyChecksum() { + if [ "${VERIFY_CHECKSUM}" == "false" ]; then + echo "Skipping checksum verification" + return 0 + fi + local sum local expected_sum @@ -231,10 +232,10 @@ installFile() { tmp_bin_dir="${BASE_TEMP_DIR}/bin" mkdir -p "$tmp_bin_dir" unzip "$KFUTIL_TMP_FILE" -d "$tmp_bin_dir" >/dev/null - echo "Preparing to install $BINARY_NAME into ${KFUTIL_INSTALL_DIR}" - runAsRoot mkdir -p "$KFUTIL_INSTALL_DIR" - runAsRoot cp "${tmp_bin_dir}/$BINARY_NAME" "$KFUTIL_INSTALL_DIR/$BINARY_NAME" - echo "$BINARY_NAME installed into $KFUTIL_INSTALL_DIR/$BINARY_NAME" + echo "Preparing to install $BINARY_NAME into ${INSTALL_DIR}" + runAsRoot mkdir -p "$INSTALL_DIR" + runAsRoot cp "${tmp_bin_dir}/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME" + echo "$BINARY_NAME installed into $INSTALL_DIR/$BINARY_NAME" testVersion } @@ -244,12 +245,12 @@ testVersion() { set +e command -v $BINARY_NAME >/dev/null 2>&1 if [ "$?" = "1" ]; then - echo "$BINARY_NAME not found. Is $KFUTIL_INSTALL_DIR on your "'$PATH?' + echo "$BINARY_NAME not found. Is $INSTALL_DIR in your "'$PATH?' exit 1 fi local version - version=$("${KFUTIL_INSTALL_DIR}/${BINARY_NAME}" version) + version=$("${INSTALL_DIR}/${BINARY_NAME}" version) raw_version=$version version=${raw_version#*version } version=${version%%\%*} @@ -258,8 +259,8 @@ testVersion() { if [[ "$version" == "$VERSION" ]]; then echo "$BINARY_NAME $version is installed and available." else - echo "$BINARY_NAME $version is installed, but wanted version $VERSION." - exit 1 + echo "$BINARY_NAME $version is installed, but wanted version $VERSION." + exit 1 fi set -e @@ -271,13 +272,67 @@ cleanup() { fi } +uninstall_fail_trap() { + result=$? + + if [[ "$result" -ne "0" ]]; then + echo "Failed to uninstall $BINARY_NAME." + + echo "You may need to use 'sudo' to uninstall. Refer to the usage:" + usage + fi + + exit $result +} + +uninstall() { + set +e + if ! current_install_dir=$(which $BINARY_NAME); then + echo "$BINARY_NAME is not installed" + exit 0 + fi + trap uninstall_fail_trap EXIT + set -e + + printf "Uninstalling %s from %s... " "$BINARY_NAME" "${current_install_dir}" + + # Uninstall binary + runAsRoot rm -f "$current_install_dir" + + set +e + command -v $BINARY_NAME >/dev/null 2>&1 + if [ "$?" != "1" ]; then + echo "$BINARY_NAME is still installed. Uninstallation failed." + exit 1 + fi + set -e + + echo "Done." +} + usage() { - echo "Usage: get-kfutil [-v] [-h]" + echo "Usage: $0 [-v] [-d] [-h]" echo " -v -- kfutil version to install in the form of v0.0.0" + echo " -d -- The install directory for kfutil. Defaults to ${HOME}/.local/bin" echo " -h -- Print this usage message" echo "" echo "Or, set the following environment variables:" - echo " VERSION -- kfutil version to install in the form of v0.0.0" + echo " USE_SUDO -- Whether to use sudo or not. Defaults to false." + echo " VERSION -- kfutil version to install in the form of v0.0.0" + echo " INSTALL_DIR -- The install directory for kfutil. Defaults to ${HOME}/.local/bin" + echo " BINARY_NAME -- The name of the binary to install. Defaults to kfutil" + echo " VERIFY_CHECKSUM -- Whether or not to verify the downloaded binary checksum. Defaults to true." + echo "" + echo "Uninstall kfutil:" + echo " $0 --uninstall" + echo "" + echo "Examples:" + echo " Install the latest stable release into ${HOME}/.local/bin:" + echo " $0" + echo " Install a specific version of kfutil into /usr/local/bin:" + echo " USE_SUDO=true VERSION=v1.2.0 INSTALL_DIR=/usr/local/bin $0" + echo " or" + echo " sudo $0 -v v1.2.0 -d /usr/local/bin" } # Trap if any command in a pipeline exits non-zero @@ -287,13 +342,18 @@ set -e # Parse command line arguments INPUT_ARGUMENTS=("$@") set -u -while getopts v:h option -do - case "${option}" - in - v) VERSION=${OPTARG};; - h) usage && exit 0;; - *) usage && exit 1;; +# If INPUT_ARGUMENTS contains --uninstall, uninstall kfutil and exit. +if [[ ${#INPUT_ARGUMENTS[@]} -gt 0 && " ${INPUT_ARGUMENTS[*]} " == *" --uninstall "* ]]; then + uninstall + exit 0 +fi + +while getopts v:d:h option; do + case "${option}" in + v) VERSION=${OPTARG} && echo "Setting target version to ${VERSION}" ;; + d) INSTALL_DIR=${OPTARG} && echo "Setting install directory to ${INSTALL_DIR}" ;; + h) usage && exit 0 ;; + *) usage && exit 1 ;; esac done set +u @@ -303,10 +363,10 @@ initOS verifySupported getVersion -if ! checkkfutilInstalledVersion; then +if ! checkBinaryInstalledVersion; then downloadFile verifyChecksum installFile fi -cleanup \ No newline at end of file +cleanup diff --git a/pkg/keyfactor/v1/integration_manifest.go b/pkg/keyfactor/v1/integration_manifest.go new file mode 100644 index 0000000..bba34f4 --- /dev/null +++ b/pkg/keyfactor/v1/integration_manifest.go @@ -0,0 +1,215 @@ +/* +Copyright 2023 The Keyfactor Command 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 manifestv1 + +import ( + "encoding/json" + "github.com/rs/zerolog/log" + "os" +) + +const ( + jsonIndent = " " + imSchema = "https://keyfactor.github.io/integration-manifest-schema.json" +) + +// IntegrationManifest is the structure of the integration manifest file generated from +// https://keyfactor.github.io/integration-manifest-schema.json +type IntegrationManifest struct { + Schema string `json:"$schema"` + Name string `json:"name"` + IntegrationType string `json:"integration_type"` + Status string `json:"status"` + Description string `json:"description"` + SupportLevel string `json:"support_level"` + ReleaseDir string `json:"release_dir"` + LinkGithub bool `json:"link_github"` + UpdateCatalog bool `json:"update_catalog"` + WinSupport string `json:"winSupport,omitempty"` + LinSupport string `json:"linSupport,omitempty"` + PamRegDLL string `json:"pamRegDLL,omitempty"` + About IntegrationAbout `json:"about,omitempty"` +} + +type IntegrationAbout struct { + Orchestrator OrchestratorDetails `json:"orchestrator,omitempty"` + Pam PamDetails `json:"pam,omitempty"` +} + +type OrchestratorDetails struct { + UOFramework string `json:"UOFramework,omitempty"` + PamSupport bool `json:"pam_support"` + Win WinSupport `json:"win,omitempty"` + Linux LinuxSupport `json:"linux,omitempty"` + StoreTypes []StoreType `json:"store_types,omitempty"` +} + +type WinSupport struct { + SupportsManagementAdd bool `json:"supportsManagementAdd"` + SupportsManagementRemove bool `json:"supportsManagementRemove"` + SupportsCreateStore bool `json:"supportsCreateStore"` + SupportsDiscovery bool `json:"supportsDiscovery"` + SupportsReenrollment bool `json:"supportsReenrollment"` + SupportsInventory bool `json:"supportsInventory"` +} + +type LinuxSupport struct { + SupportsManagementAdd bool `json:"supportsManagementAdd"` + SupportsManagementRemove bool `json:"supportsManagementRemove"` + SupportsCreateStore bool `json:"supportsCreateStore"` + SupportsDiscovery bool `json:"supportsDiscovery"` + SupportsReenrollment bool `json:"supportsReenrollment"` + SupportsInventory bool `json:"supportsInventory"` +} + +type StoreType struct { + Name string `json:"Name,omitempty"` + ShortName string `json:"ShortName,omitempty"` + Capability string `json:"Capability,omitempty"` + LocalStore bool `json:"LocalStore"` + SupportedOperations OperationSupport `json:"SupportedOperations,omitempty"` + Properties []PropertyDetail `json:"Properties,omitempty"` + EntryParameters []EntryParameter `json:"EntryParameters,omitempty"` + PasswordOptions interface{} `json:"PasswordOptions,omitempty"` + StorePathType string `json:"StorePathType,omitempty"` + StorePathValue string `json:"StorePathValue,omitempty"` + PrivateKeyAllowed string `json:"PrivateKeyAllowed,omitempty"` + JobProperties []string `json:"JobProperties,omitempty"` + ServerRequired bool `json:"ServerRequired"` + PowerShell bool `json:"PowerShell"` + BlueprintAllowed bool `json:"BlueprintAllowed"` + CustomAliasAllowed string `json:"CustomAliasAllowed,omitempty"` +} + +type OperationSupport struct { + Add bool `json:"Add"` + Remove bool `json:"Remove"` + Enrollment bool `json:"Enrollment"` + Discovery bool `json:"Discovery"` + Inventory bool `json:"Inventory"` +} + +type PropertyDetail struct { + Name string `json:"Name,omitempty"` + DisplayName string `json:"DisplayName,omitempty"` + Type string `json:"Type,omitempty"` + DependsOn string `json:"DependsOn,omitempty"` + DefaultValue string `json:"DefaultValue,omitempty"` + Required bool `json:"Required"` +} + +type EntryParameter struct { + Name string `json:"Name,omitempty"` + DisplayName string `json:"DisplayName,omitempty"` + Type string `json:"Type,omitempty"` + RequiredWhen Requirement `json:"RequiredWhen,omitempty"` + DefaultValue string `json:"DefaultValue,omitempty"` + DependsOn string `json:"DependsOn,omitempty"` + Options string `json:"Options,omitempty"` +} + +type Requirement struct { + HasPrivateKey bool `json:"HasPrivateKey"` + OnAdd bool `json:"OnAdd"` + OnRemove bool `json:"OnRemove"` + OnReenrollment bool `json:"OnReenrollment"` +} + +type PamDetails struct { + AssemblyName string `json:"assemblyName,omitempty"` + ProviderName string `json:"providerName,omitempty"` + FullyQualifiedClassName string `json:"fullyQualifiedClassName,omitempty"` + DbName string `json:"dbName,omitempty"` +} + +func CreateIntegrationManifest() *IntegrationManifest { + return &IntegrationManifest{ + Schema: imSchema, + } +} + +// LoadFromFilesystem loads an integration manifest from the current working directory. +// If the file does not exist, it returns nil +func (im *IntegrationManifest) LoadFromFilesystem() error { + // Load the integration manifest from the current working directory + manifestFileBytes, err := os.Open("integration-manifest.json") + if err != nil { + log.Debug().Msg("Could not open integration-manifest.json - it may not exist") + return nil + } + + // Marshal the integration manifest into the IntegrationManifest struct + err = json.NewDecoder(manifestFileBytes).Decode(&im) + if err != nil { + return err + } + + return nil +} + +// SaveToFilesystem saves an integration manifest to the current working directory +func (im *IntegrationManifest) SaveToFilesystem() error { + imJsonString, err := im.Marshal() + if err != nil { + return err + } + + // Overwrite or create the integration manifest file + manifestFile, err := os.OpenFile("integration-manifest.json", os.O_WRONLY|os.O_CREATE, 0666) + if err != nil { + return err + } + + // Write the integration manifest to the file + _, err = manifestFile.WriteString(imJsonString) + if err != nil { + return err + } + + return nil +} + +func (im *IntegrationManifest) CopyIntoStoreType(source string) error { + // Marshal the source string into a StoreType + var storeType StoreType + err := json.Unmarshal([]byte(source), &storeType) + if err != nil { + return err + } + + // Either overwrite an existing StoreType or append a new one + for i, st := range im.About.Orchestrator.StoreTypes { + if st.Name == storeType.Name { + im.About.Orchestrator.StoreTypes[i] = storeType + return nil + } + } + im.About.Orchestrator.StoreTypes = append(im.About.Orchestrator.StoreTypes, storeType) + + return nil +} + +func (im *IntegrationManifest) Marshal() (string, error) { + // Marshal the IntegrationManifest struct into a string + manifestBytes, err := json.MarshalIndent(im, "", jsonIndent) + if err != nil { + log.Debug().Msg("Could not marshal integration manifest") + return "", err + } + + return string(manifestBytes), nil +} diff --git a/pkg/keyfactor/v1/integration_manifest_test.go b/pkg/keyfactor/v1/integration_manifest_test.go new file mode 100644 index 0000000..17252ee --- /dev/null +++ b/pkg/keyfactor/v1/integration_manifest_test.go @@ -0,0 +1,355 @@ +/* +Copyright 2023 The Keyfactor Command 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 manifestv1 + +import ( + "encoding/json" + "os" + "reflect" + "testing" +) + +func TestIntegrationManifest_CopyInto(t *testing.T) { + // newStoreJsonString intentionally has values that don't exist in StoreType. + newStoreJsonString := ` +{ + "Name": "CloudDBCert", + "ShortName": "CloudDBCert", + "Capability": "CertificateManagement", + "LocalStore": true, + "SupportedOperations": { + "Add": true, + "Create": true, + "Discovery": false, + "Enrollment": true, + "Remove": true + }, + "Properties": [ + { + "Name": "CloudRegion", + "DisplayName": "Cloud Region", + "Type": "String", + "DependsOn": null, + "DefaultValue": "us-west-1", + "Required": true + }, + { + "Name": "ResourceGroupName", + "DisplayName": "Resource Group Name", + "Type": "String", + "DependsOn": null, + "DefaultValue": null, + "Required": true + }, + { + "Name": "ResourceType", + "DisplayName": "Resource Type", + "Type": "String", + "DependsOn": null, + "DefaultValue": "SQLDatabase", + "Required": true + }, + { + "Name": "AdminUsername", + "DisplayName": "Admin Username", + "Type": "String", + "DependsOn": null, + "DefaultValue": null, + "Required": true + }, + { + "Name": "AdminPassword", + "DisplayName": "Admin Password", + "Type": "Secret", + "DependsOn": null, + "DefaultValue": null, + "Required": true + }, + { + "Name": "UseEncryption", + "DisplayName": "Use Encryption", + "Type": "Bool", + "DependsOn": null, + "DefaultValue": "false", + "Required": false + } + ], + "EntryParameters": [ + { + "Name": "Environment", + "DisplayName": "Environment", + "Type": "Dropdown", + "Values": ["Development", "Staging", "Production"], + "DefaultValue": "Development", + "Required": true + } + ], + "PasswordOptions": { + "EntrySupported": true, + "StoreRequired": true, + "Style": "PasswordComplex" + }, + "StorePathType": "CloudService", + "StorePathValue": "/subscriptions/subid/resourceGroups/rgname/providers/Microsoft.DBforMySQL/servers/servername", + "PrivateKeyAllowed": "Optional", + "JobProperties": ["Backup", "Rotation"], + "ServerRequired": false, + "PowerShell": true, + "BlueprintAllowed": true, + "CustomAliasAllowed": "Allowed", + "ServerRegistration": 2, + "InventoryEndpoint": "/CloudInventory/Update", + "InventoryJobType": "ac4b1d4a-46e0-4f13-95d6-1e57b314d2b1", + "ManagementJobType": "b1a5f93b-e480-4f8a-9850-e3b125fba5f9", + "DiscoveryJobType": "e3d1c3b9-6e92-4893-a5d5-67d5c7053a6b", + "EnrollmentJobType": "1d2c5f59-5be4-4f5d-9ed6-d6b458aadf58" +} +` + + // Marshal newStoreJsonString into a StoreType struct for later + var newStore StoreType + err := json.Unmarshal([]byte(newStoreJsonString), &newStore) + if err != nil { + t.Fatalf("MarshalJSON returned an error: %v", err) + } + + t.Run("FromBlankIM", func(t *testing.T) { + // Initialize an IntegrationManifest struct + im := IntegrationManifest{} + + // Use CopyInto to copy data from the newStoreJsonString into the IntegrationManifest struct + err = im.CopyIntoStoreType(newStoreJsonString) + if err != nil { + t.Fatalf("CopyInto returned an error: %v", err) + } + + // Compare the values in the IntegrationManifest struct to the values in the StoreType struct + if !reflect.DeepEqual(im.About.Orchestrator.StoreTypes[0], newStore) { + t.Errorf("CopyInto did not copy the values from the StoreType struct into the IntegrationManifest struct") + } + }) + + t.Run("FromExistingIM", func(t *testing.T) { + // Initialize an IntegrationManifest struct with test data + im := getTestIntegrationManifest() + + // Use CopyInto to copy data from the newStoreJsonString into the IntegrationManifest struct + err = im.CopyIntoStoreType(newStoreJsonString) + if err != nil { + t.Fatalf("CopyInto returned an error: %v", err) + } + + // Compare the values in the IntegrationManifest struct to the values in the StoreType struct + if !reflect.DeepEqual(im.About.Orchestrator.StoreTypes[1], newStore) { + t.Errorf("CopyInto did not copy the values from the StoreType struct into the IntegrationManifest struct") + } + }) + + // Testing to ensure that CopyInto will overwrite existing stores with the same name + t.Run("FromExistingIMWithExistingStore", func(t *testing.T) { + // Initialize an IntegrationManifest struct with test data + im := getTestIntegrationManifest() + + // Change the name of the existing store to match the new store + im.About.Orchestrator.StoreTypes[0].Name = newStore.Name + + // Use CopyInto to copy data from the newStoreJsonString into the IntegrationManifest struct + err = im.CopyIntoStoreType(newStoreJsonString) + if err != nil { + t.Fatalf("CopyInto returned an error: %v", err) + } + + // Compare the values in the IntegrationManifest struct to the values in the StoreType struct + if !reflect.DeepEqual(im.About.Orchestrator.StoreTypes[0], newStore) { + t.Errorf("CopyInto did not copy the values from the StoreType struct into the IntegrationManifest struct") + } + }) +} + +func TestIntegrationManifest_LoadFromFilesystem(t *testing.T) { + // Marshal test IM to a string and write it to an IM + originalIm := getTestIntegrationManifest() + imString, err := json.Marshal(originalIm) + if err != nil { + t.Fatalf("MarshalJSON returned an error: %v", err) + } + + err = os.WriteFile("integration-manifest.json", imString, 0644) + if err != nil { + t.Fatalf("WriteFile returned an error: %v", err) + } + + // Initialize a blank IntegrationManifest struct + im := IntegrationManifest{} + + // Load the integration manifest from the current working directory + err = im.LoadFromFilesystem() + if err != nil { + t.Fatalf("LoadFromFilesystem returned an error: %v", err) + } + + // Test if the old and new IntegrationManifest structs are deeply equal + if !reflect.DeepEqual(im, originalIm) { + t.Errorf("LoadFromFilesystem did not load the integration manifest correctly") + } + + // Clean up the integration manifest file + err = os.Remove("integration-manifest.json") + if err != nil { + t.Fatalf("Remove returned an error: %v", err) + } +} + +func TestIntegrationManifest_Marshal(t *testing.T) { + // Marshal test IM to a string + originalIm := getTestIntegrationManifest() + imString, err := json.MarshalIndent(originalIm, "", jsonIndent) + if err != nil { + t.Fatalf("MarshalJSON returned an error: %v", err) + } + + // Marshal the IntegrationManifest struct into a string + im, err := originalIm.Marshal() + if err != nil { + t.Fatalf("Marshal returned an error: %v", err) + } + + // Test if the old and new IntegrationManifest structs are deeply equal + if !reflect.DeepEqual(im, string(imString)) { + t.Errorf("Marshal did not marshal the integration manifest correctly") + } +} + +func TestIntegrationManifest_SaveToFilesystem(t *testing.T) { + im := getTestIntegrationManifest() + err := im.SaveToFilesystem() + if err != nil { + t.Fatalf("SaveToFilesystem returned an error: %v", err) + } + + // Load the integration manifest from the current working directory + err = im.LoadFromFilesystem() + if err != nil { + t.Fatalf("LoadFromFilesystem returned an error: %v", err) + } + + // Test if the old and new IntegrationManifest structs are deeply equal + if !reflect.DeepEqual(im, getTestIntegrationManifest()) { + t.Errorf("SaveToFilesystem did not save the integration manifest correctly") + } + + // Clean up the integration manifest file + err = os.Remove("integration-manifest.json") + if err != nil { + t.Errorf("Remove returned an error: %v", err) + } +} + +func getTestIntegrationManifest() IntegrationManifest { + return IntegrationManifest{ + Schema: imSchema, + Name: "ExampleIntegration", + IntegrationType: "orchestrator", + Status: "production", + Description: "This is an example integration for demonstration purposes.", + SupportLevel: "community", + ReleaseDir: "/path/to/release/directory", + LinkGithub: true, + UpdateCatalog: true, + WinSupport: "Full", + LinSupport: "Partial", + PamRegDLL: "example.dll", + About: IntegrationAbout{ + Orchestrator: OrchestratorDetails{ + UOFramework: "ExampleFramework", + PamSupport: true, + Win: WinSupport{ + SupportsManagementAdd: true, + SupportsManagementRemove: true, + SupportsCreateStore: true, + SupportsDiscovery: true, + SupportsReenrollment: true, + SupportsInventory: true, + }, + Linux: LinuxSupport{ + SupportsManagementAdd: true, + SupportsManagementRemove: true, + SupportsCreateStore: true, + SupportsDiscovery: true, + SupportsReenrollment: true, + SupportsInventory: true, + }, + StoreTypes: []StoreType{ + { + Name: "ExampleStore", + ShortName: "ExStore", + Capability: "ExStore", + LocalStore: false, + SupportedOperations: OperationSupport{ + Add: true, + Remove: true, + Enrollment: true, + Discovery: true, + Inventory: true, + }, + Properties: []PropertyDetail{ + { + Name: "exampleProperty", + DisplayName: "Example Property", + Type: "String", + DependsOn: "previousProperty", + DefaultValue: "defaultValue", + Required: true, + }, + }, + EntryParameters: []EntryParameter{ + { + Name: "exampleParameter", + DisplayName: "Example Parameter", + Type: "int", + RequiredWhen: Requirement{ + HasPrivateKey: true, + OnAdd: true, + OnRemove: false, + OnReenrollment: true, + }, + DefaultValue: "10", + DependsOn: "otherParameter", + Options: "10,20,30", + }, + }, + PasswordOptions: nil, + StorePathType: "FileSystem", + StorePathValue: "/path/to/store", + PrivateKeyAllowed: "Optional", + JobProperties: []string{"prop1", "prop2"}, + ServerRequired: true, + PowerShell: true, + BlueprintAllowed: true, + CustomAliasAllowed: "ByPolicy", + }, + }, + }, + Pam: PamDetails{ + AssemblyName: "Example.Assembly", + ProviderName: "ExampleProvider", + FullyQualifiedClassName: "Example.Namespace.ProviderClass", + DbName: "ExampleDB", + }, + }, + } +} diff --git a/readme_source.md b/readme_source.md index 3649ea9..346ab89 100644 --- a/readme_source.md +++ b/readme_source.md @@ -11,10 +11,22 @@ ### Installation: +#### Linux/MacOS ```bash -bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh) +curl -fsSL -o get-kfutil.sh https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh +chmod +x get-kfutil.sh +# Install kfutil to $HOME/.local/bin. Use -h for help and examples. +./get-kfutil.sh ```` +#### Windows (or Linux/MacOS if PowerShell is preferred) +```powershell +Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.ps1" -OutFile "install.ps1" +# Install kfutil to $HOME/AppData/Local/Microsoft/WindowsApps. +# Use Get-Help .\install.ps1 -Full for help and examples. +.\install.ps1 +``` + ### Environmental Variables All the variables listed below need to be set in your environment. The `kfutil` command will look for these variables