diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 02735b95..9959e5f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,14 +38,14 @@ jobs: run: echo "Running tests for KF 10.x.x" ### Store Type Tests - Test_StoreTypes_KFC_10_4_5: + Test_StoreTypes_KFC_10_5_0: runs-on: ubuntu-latest needs: - build - kf_10_x_x env: - SECRET_NAME: "command-config-1045-clean" - KEYFACTOR_HOSTNAME: "int1045-test-clean.kfdelivery.com" + SECRET_NAME: "command-config-1050-clean" + KEYFACTOR_HOSTNAME: "int1050-test-clean.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -56,14 +56,17 @@ jobs: run: | export KFUTIL_DEBUG=1 go test -v ./cmd -run "^Test_StoreTypes*" - Test_StoreTypes_KFC_10_2_1: + + ### Store Tests + Test_Stores_KFC_10_5_0: runs-on: ubuntu-latest needs: - build - kf_10_x_x + - Test_StoreTypes_KFC_10_5_0 env: - SECRET_NAME: "command-config-1021-clean" - KEYFACTOR_HOSTNAME: "int1021-test-clean.kfdelivery.com" + SECRET_NAME: "command-config-1050" + KEYFACTOR_HOSTNAME: "integrations1050-lab.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -71,18 +74,18 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_StoreTypes*" + run: go test -v ./cmd -run "^Test_Stores_*" - Test_StoreTypes_KFC_10_1_1: + ### PAM Tests + Test_PAM_KFC_10_5_0: runs-on: ubuntu-latest needs: - build - kf_10_x_x + - Test_StoreTypes_KFC_10_5_0 env: - SECRET_NAME: "command-config-1011-clean" - KEYFACTOR_HOSTNAME: "int1011-test-clean.kfdelivery.com" + SECRET_NAME: "command-config-1050" + KEYFACTOR_HOSTNAME: "integrations1050-lab.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -92,74 +95,57 @@ jobs: - name: Run tests run: | unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_StoreTypes*" + go test -v ./cmd -run "^Test_PAM*" - # Test_StoreTypes_KFC_10_1_1: - # runs-on: ubuntu-latest - # needs: - # - build - # - kf_10_x_x - # env: - # SECRET_NAME: "command-config-1011-clean" - # KEYFACTOR_HOSTNAME: "int1011-test-clean.kfdelivery.com" - # KEYFACTOR_DOMAIN: "command" - # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Run tests - # run: | - # unset KFUTIL_DEBUG - # go test -v ./cmd -run "^Test_StoreTypes*" - ### Store Tests - Test_Stores_KFC_10_4_5: - runs-on: ubuntu-latest + ### PAM Tests AKV Auth Provider + Test_AKV_PAM_KFC_10_5_0: + runs-on: self-hosted needs: - - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_4_5 + - Test_PAM_KFC_10_5_0 env: - SECRET_NAME: "command-config-1045" - KEYFACTOR_HOSTNAME: "integrations1045-lab.kfdelivery.com" - KEYFACTOR_DOMAIN: "command" - KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} + SECRET_NAME: "command-config-1050-az" steps: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Install dependencies + run: go mod download && go mod tidy + - name: Get secret from Azure Key Vault + run: | + . ./examples/auth/akv/akv_auth.sh + cat $HOME/.keyfactor/command_config.json + - name: Install kfutil + run: | + make install - name: Run tests - run: go test -v ./cmd -run "^Test_Stores_*" - Test_Stores_KFC_10_2_1: + run: | + go test -v ./cmd -run "^Test_PAM*" + + + ## KFC 11.x.x + kf_11_x_x: runs-on: ubuntu-latest needs: - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_2_1 - env: - SECRET_NAME: "command-config-1021" - KEYFACTOR_HOSTNAME: "integrations1021-lab.kfdelivery.com" - KEYFACTOR_DOMAIN: "command" - KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_Stores_*" + run: echo "Running tests for KF 11.x.x" - Test_Stores_KFC_10_1_1: + ### Store Type Tests + Test_StoreTypes_KFC_11_2_0: runs-on: ubuntu-latest needs: - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_1_1 + - kf_11_x_x env: - SECRET_NAME: "command-config-1011" - KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + SECRET_NAME: "command-config-1120-clean" + KEYFACTOR_HOSTNAME: "int1120-test-clean.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -169,38 +155,16 @@ jobs: - name: Run tests run: | unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_Stores_*" - - # Test_Stores_KFC_10_1_1: - # runs-on: ubuntu-latest - # needs: - # - build - # - kf_10_x_x - # - Test_StoreTypes_KFC_10_1_1 - # env: - # SECRET_NAME: "command-config-1011" - # KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" - # KEYFACTOR_DOMAIN: "command" - # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Run tests - # run: | - # unset KFUTIL_DEBUG - # go test -v ./cmd -run "^Test_Stores_*" + go test -v ./cmd -run "^Test_StoreTypes*" - ### PAM Tests - Test_PAM_KFC_10_4_5: + Test_StoreTypes_KFC_11_1_2: runs-on: ubuntu-latest needs: - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_4_5 + - kf_11_x_x env: - SECRET_NAME: "command-config-1045" - KEYFACTOR_HOSTNAME: "integrations1045-lab.kfdelivery.com" + SECRET_NAME: "command-config-1112-clean" + KEYFACTOR_HOSTNAME: "int1112-test-clean.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -210,17 +174,19 @@ jobs: - name: Run tests run: | unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_PAM*" + go test -v ./cmd -run "^Test_StoreTypes*" + - Test_PAM_KFC_10_2_1: + ### Store Tests + Test_Stores_KFC_11_2_0: runs-on: ubuntu-latest needs: - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_2_1 + - kf_11_x_x + - Test_StoreTypes_KFC_11_2_0 env: - SECRET_NAME: "command-config-1021" - KEYFACTOR_HOSTNAME: "integrations1021-lab.kfdelivery.com" + SECRET_NAME: "command-config-1120" + KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -228,18 +194,16 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_PAM*" - Test_PAM_KFC_10_1_1: + run: go test -v ./cmd -run "^Test_Stores_*" + Test_Stores_KFC_11_1_2: runs-on: ubuntu-latest needs: - build - - kf_10_x_x - - Test_StoreTypes_KFC_10_1_1 + - kf_11_x_x + - Test_StoreTypes_KFC_11_1_2 env: - SECRET_NAME: "command-config-1011" - KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" + SECRET_NAME: "command-config-1112" + KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com" KEYFACTOR_DOMAIN: "command" KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} @@ -247,95 +211,65 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_PAM*" - # Test_PAM_KFC_10_1_1: - # runs-on: ubuntu-latest - # needs: - # - build - # - kf_10_x_x - # - Test_StoreTypes_KFC_10_1_1 - # env: - # SECRET_NAME: "command-config-1011" - # KEYFACTOR_HOSTNAME: "integrations1011-lab.kfdelivery.com" - # KEYFACTOR_DOMAIN: "command" - # KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - # KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - # steps: - # - name: Checkout code - # uses: actions/checkout@v4 - # - name: Run tests - # run: | - # unset KFUTIL_DEBUG - # go test -v ./cmd -run "^Test_PAM*" + run: go test -v ./cmd -run "^Test_Stores_*" - ### PAM Tests AKV Auth Provider - Test_AKV_PAM_KFC_10_4_5: - runs-on: self-hosted + ### PAM Tests + Test_PAM_KFC_11_2_0: + runs-on: ubuntu-latest needs: - - Test_PAM_KFC_10_4_5 + - build + - kf_11_x_x + - Test_StoreTypes_KFC_11_2_0 env: - SECRET_NAME: "command-config-1045-az" + SECRET_NAME: "command-config-1120" + KEYFACTOR_HOSTNAME: "integrations1120-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.20" - - name: Install dependencies - run: go mod download && go mod tidy - - name: Get secret from Azure Key Vault - run: | - . ./examples/auth/akv/akv_auth.sh - cat $HOME/.keyfactor/command_config.json - - name: Install kfutil - run: | - make install - name: Run tests run: | + unset KFUTIL_DEBUG go test -v ./cmd -run "^Test_PAM*" - Test_AKV_PAM_KFC_10_2_1: - runs-on: self-hosted + + Test_PAM_KFC_11_1_2: + runs-on: ubuntu-latest needs: - - Test_PAM_KFC_10_2_1 + - build + - kf_11_x_x + - Test_StoreTypes_KFC_11_1_2 env: - SECRET_NAME: "command-config-1021-az" + SECRET_NAME: "command-config-1112" + KEYFACTOR_HOSTNAME: "integrations1112-lab.kfdelivery.com" + KEYFACTOR_DOMAIN: "command" + KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} + KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} steps: - name: Checkout code uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.20" - - name: Install dependencies - run: go mod download && go mod tidy - - name: Get secret from Azure Key Vault - run: | - . ./examples/auth/akv/akv_auth.sh - cat $HOME/.keyfactor/command_config.json - - name: Install kfutil - run: | - make install - name: Run tests run: | + unset KFUTIL_DEBUG go test -v ./cmd -run "^Test_PAM*" - Test_AKV_PAM_KFC_10_1_1: + + ### PAM Tests AKV Auth Provider + Test_AKV_PAM_KFC_11_2_0: runs-on: self-hosted needs: - - Test_PAM_KFC_10_1_1 + - Test_PAM_KFC_11_2_0 env: - SECRET_NAME: "command-config-1011-az" + SECRET_NAME: "command-config-1120-az" steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.20" + go-version: "1.21" - name: Install dependencies run: go mod download && go mod tidy - name: Get secret from Azure Key Vault @@ -350,93 +284,19 @@ jobs: go test -v ./cmd -run "^Test_PAM*" - - ## KFC 11.x.x - kf_11_x_x: - runs-on: ubuntu-latest - needs: - - build - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run tests - run: echo "Running tests for KF 11.x.x" - - ### Store Type Tests - Test_StoreTypes_KFC_11_0_0: - runs-on: ubuntu-latest - needs: - - build - - kf_11_x_x - env: - SECRET_NAME: "command-config-1100-clean" - KEYFACTOR_HOSTNAME: "int11-test-clean.kfdelivery.com" - KEYFACTOR_DOMAIN: "command" - KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_StoreTypes*" - - ### Store Tests - Test_Stores_KFC_11_0_0: - runs-on: ubuntu-latest - needs: - - build - - kf_11_x_x - - Test_StoreTypes_KFC_11_0_0 - env: - SECRET_NAME: "command-config-1100" - KEYFACTOR_HOSTNAME: "integrations1100-lab.kfdelivery.com" - KEYFACTOR_DOMAIN: "command" - KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run tests - run: go test -v ./cmd -run "^Test_Stores_*" - - ### PAM Tests - Test_PAM_KFC_11_0_0: - runs-on: ubuntu-latest - needs: - - build - - kf_11_x_x - - Test_StoreTypes_KFC_11_0_0 - env: - SECRET_NAME: "command-config-1100" - KEYFACTOR_HOSTNAME: "integrations1100-lab.kfdelivery.com" - KEYFACTOR_DOMAIN: "command" - KEYFACTOR_USERNAME: ${{ secrets.LAB_USERNAME }} - KEYFACTOR_PASSWORD: ${{ secrets.LAB_PASSWORD }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run tests - run: | - unset KFUTIL_DEBUG - go test -v ./cmd -run "^Test_PAM*" - - - ### PAM Tests AKV Auth Provider - Test_AKV_PAM_KFC_11_0_0: + Test_AKV_PAM_KFC_11_1_2: runs-on: self-hosted needs: - - Test_PAM_KFC_11_0_0 + - Test_PAM_KFC_11_1_2 env: - SECRET_NAME: "command-config-1100-az" + SECRET_NAME: "command-config-1112-az" steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.20" + go-version: "1.21" - name: Install dependencies run: go mod download && go mod tidy - name: Get secret from Azure Key Vault diff --git a/artifacts/pam/pam-create-template-v11.json b/artifacts/pam/pam-create-template-v11.json new file mode 100644 index 00000000..aae40df8 --- /dev/null +++ b/artifacts/pam/pam-create-template-v11.json @@ -0,0 +1,23 @@ +{ + "name": "string", + "remote": true, + "area": 0, + "services": { + "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + }, + "providerTypeParamValues": [ + { + "id": 0, + "value": "string", + "instanceId": 0, + "instanceGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "providerTypeParam": { + "id": 0, + "name": "string", + "displayName": "string", + "instanceLevel": true + } + } + ], + "securedAreaId": 0 +} \ No newline at end of file diff --git a/cmd/auth_providers.go b/cmd/auth_providers.go index ed030330..c2af068e 100644 --- a/cmd/auth_providers.go +++ b/cmd/auth_providers.go @@ -1,4 +1,4 @@ -// Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/certificates.go b/cmd/certificates.go index aa0f0989..0384474c 100644 --- a/cmd/certificates.go +++ b/cmd/certificates.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/constants.go b/cmd/constants.go index bc3a2b1c..0f209ce6 100644 --- a/cmd/constants.go +++ b/cmd/constants.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +13,10 @@ // limitations under the License. package cmd -import "fmt" +import ( + "fmt" + "time" +) const ( ColorRed = "\033[31m" @@ -25,6 +28,10 @@ const ( XKeyfactorRequestedWith = "APIClient" XKeyfactorApiVersion = "1" FlagGitRef = "git-ref" + FlagFromFile = "from-file" + DebugFuncEnter = "entered: %s" + DebugFuncExit = "exiting: %s" + DebugFuncCall = "calling: %s" ) var ProviderTypeChoices = []string{ @@ -36,4 +43,5 @@ var ValidAuthProviders = [2]string{"azure-id", "azid"} var ( StoreTypeReadError = fmt.Errorf("error reading store type from configuration file") InvalidInputError = fmt.Errorf("invalid input") + CLINow = time.Now().Unix() ) diff --git a/cmd/containers.go b/cmd/containers.go index 85dfca70..2b29dfe6 100644 --- a/cmd/containers.go +++ b/cmd/containers.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/export.go b/cmd/export.go index 442d1b62..1624f651 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,43 +18,30 @@ import ( "context" "encoding/json" "fmt" - "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor" + kfc "github.com/Keyfactor/keyfactor-go-client-sdk/v11/api/command" "github.com/Keyfactor/keyfactor-go-client/v2/api" + "github.com/rs/zerolog/log" "github.com/spf13/cobra" - "log" "os" "strconv" ) -var exportPath string -var fCollections bool -var fMetadata bool -var fExpirationAlerts bool -var fIssuedAlerts bool -var fDeniedAlerts bool -var fPendingAlerts bool -var fNetworks bool -var fWorkflowDefinitions bool -var fReports bool -var fSecurityRoles bool -var fAll bool - type exportModelsReport struct { - ID *int32 `json:"-"` - Scheduled *int32 `json:"Scheduled,omitempty"` - DisplayName *string `json:"DisplayName,omitempty"` - Description *string `json:"Description,omitempty"` - ReportPath *string `json:"ReportPath,omitempty"` - VersionNumber *string `json:"VersionNumber,omitempty"` - Categories *string `json:"Categories,omitempty"` - ShortName *string `json:"ShortName,omitempty"` - InNavigator *bool `json:"InNavigator,omitempty"` - Favorite *bool `json:"Favorite,omitempty"` - RemoveDuplicates *bool `json:"RemoveDuplicates,omitempty"` - UsesCollection *bool `json:"UsesCollection,omitempty"` - ReportParameter []keyfactor.ModelsReportParameters `json:"ReportParameter,omitempty"` - Schedules []keyfactor.ModelsReportSchedule `json:"Schedules,omitempty"` - AcceptedScheduleFormats []string `json:"AcceptedScheduleFormats,omitempty"` + ID *int32 `json:"-"` + Scheduled *int32 `json:"Scheduled,omitempty"` + DisplayName *string `json:"DisplayName,omitempty"` + Description *string `json:"Description,omitempty"` + ReportPath *string `json:"ReportPath,omitempty"` + VersionNumber *string `json:"VersionNumber,omitempty"` + Categories *string `json:"Categories,omitempty"` + ShortName *string `json:"ShortName,omitempty"` + InNavigator *bool `json:"InNavigator,omitempty"` + Favorite *bool `json:"Favorite,omitempty"` + RemoveDuplicates *bool `json:"RemoveDuplicates,omitempty"` + UsesCollection *bool `json:"UsesCollection,omitempty"` + ReportParameter []kfc.ModelsReportParameters `json:"ReportParameter,omitempty"` + Schedules []kfc.ModelsReportSchedule `json:"Schedules,omitempty"` + AcceptedScheduleFormats []string `json:"AcceptedScheduleFormats,omitempty"` } type exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest struct { @@ -71,31 +58,36 @@ type exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest struct { } type outJson struct { - Collections []keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest `json:"Collections"` - MetadataFields []keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest `json:"MetadataFields"` - ExpirationAlerts []keyfactor.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest `json:"ExpirationAlerts"` - IssuedCertAlerts []keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest `json:"IssuedCertAlerts"` - DeniedCertAlerts []keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest `json:"DeniedCertAlerts"` - PendingCertAlerts []keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest `json:"PendingCertAlerts"` - Networks []keyfactor.KeyfactorApiModelsSslCreateNetworkRequest `json:"Networks"` - WorkflowDefinitions []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest `json:"WorkflowDefinitions"` - BuiltInReports []exportModelsReport `json:"BuiltInReports"` - CustomReports []keyfactor.ModelsCustomReportCreationRequest `json:"CustomReports"` - SecurityRoles []api.CreateSecurityRoleArg `json:"SecurityRoles"` + Collections []kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest `json:"Collections"` + MetadataFields []kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest `json:"MetadataFields"` + ExpirationAlerts []kfc.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest `json:"ExpirationAlerts"` + IssuedCertAlerts []kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest `json:"IssuedCertAlerts"` + DeniedCertAlerts []kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest `json:"DeniedCertAlerts"` + PendingCertAlerts []kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest `json:"PendingCertAlerts"` + Networks []kfc.KeyfactorApiModelsSslCreateNetworkRequest `json:"Networks"` + WorkflowDefinitions []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest `json:"WorkflowDefinitions"` + BuiltInReports []exportModelsReport `json:"BuiltInReports"` + CustomReports []kfc.ModelsCustomReportCreationRequest `json:"CustomReports"` + SecurityRoles []api.CreateSecurityRoleArg `json:"SecurityRoles"` } -func exportToJSON(out outJson, exportPath string) { +func exportToJSON(out outJson, filePath string) error { mOut, jErr := json.MarshalIndent(out, "", " ") if jErr != nil { fmt.Printf("Error processing JSON object. %s\n", jErr) - log.Fatalf("[ERROR]: %s", jErr) + //log.Fatalf("[ERROR]: %s", jErr) + log.Error().Err(jErr) + return jErr } - wErr := os.WriteFile(exportPath, mOut, 0666) + wErr := os.WriteFile(filePath, mOut, 0666) if wErr != nil { - fmt.Printf("Error writing files to %s: %s\n", exportPath, wErr) - log.Fatalf("[ERROR]: %s", wErr) + fmt.Printf("Error writing files to %s: %s\n", filePath, wErr) + //log.Fatalf("[ERROR]: %s", wErr) + log.Error().Err(wErr) + return wErr } else { - fmt.Printf("Content successfully written to %s", exportPath) + fmt.Printf("Content successfully written to %s", filePath) + return nil } } @@ -104,169 +96,266 @@ var exportCmd = &cobra.Command{ Use: "export", Short: "Keyfactor instance export utilities.", Long: `A collection of APIs and utilities for exporting Keyfactor instance data.`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { + log.Debug().Msgf("%s: exportCmd", DebugFuncEnter) + isExperimental := false + + informDebug(debugFlag) + debugErr := warnExperimentalFeature(expEnabled, isExperimental) + if debugErr != nil { + return debugErr + } + + exportPath, _ := cmd.Flags().GetString("file") + + log.Info().Msg("Exporting data from Keyfactor instance") + // initialize each entry as an empty list in the event it is not requested by the flags out := outJson{ - Collections: []keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest{}, - MetadataFields: []keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest{}, - ExpirationAlerts: []keyfactor.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest{}, - IssuedCertAlerts: []keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest{}, - DeniedCertAlerts: []keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest{}, - PendingCertAlerts: []keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest{}, - Networks: []keyfactor.KeyfactorApiModelsSslCreateNetworkRequest{}, + Collections: []kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest{}, + MetadataFields: []kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest{}, + ExpirationAlerts: []kfc.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest{}, + IssuedCertAlerts: []kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest{}, + DeniedCertAlerts: []kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest{}, + PendingCertAlerts: []kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest{}, + Networks: []kfc.KeyfactorApiModelsSslCreateNetworkRequest{}, WorkflowDefinitions: []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest{}, BuiltInReports: []exportModelsReport{}, - CustomReports: []keyfactor.ModelsCustomReportCreationRequest{}, + CustomReports: []kfc.ModelsCustomReportCreationRequest{}, SecurityRoles: []api.CreateSecurityRoleArg{}, } + log.Debug().Msgf("%s: createAuthConfigFromParams", DebugFuncCall) authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) - isExperimental := true - _, expErr := isExperimentalFeatureEnabled(expEnabled, isExperimental) - if expErr != nil { - fmt.Println(fmt.Sprintf("WARNING this is an expEnabled feature, %s", expErr)) - log.Fatalf("[ERROR]: %s", expErr) + if authConfig == nil { + log.Error().Msg("auth config is nil, invalid client configuration") + return fmt.Errorf(FailedAuthMsg) + } + log.Debug().Str("exportPath", exportPath).Msg("exportPath") + + log.Debug().Msgf("%s: initGenClient", DebugFuncCall) + kfClient, clientErr := initGenClient(configFile, profile, noPrompt, authConfig, false) + log.Debug().Msgf("%s: initClient", DebugFuncCall) + oldkfClient, oldClientErr := initClient(configFile, profile, "", "", noPrompt, authConfig, false) + + if clientErr != nil { + log.Error().Err(clientErr).Send() + return clientErr + } else if oldClientErr != nil { + log.Error().Err(oldClientErr).Send() + return oldClientErr } - debugModeEnabled := checkDebug(debugFlag) - log.Println("Debug mode enabled: ", debugModeEnabled) - - exportPath := cmd.Flag("file").Value.String() - - kfClient, _ := initGenClient(configFile, profile, noPrompt, authConfig, false) - oldkfClient, _ := initClient(configFile, profile, "", "", noPrompt, authConfig, false) if cmd.Flag("all").Value.String() == "true" { + log.Debug().Msgf("%s: getCollections", DebugFuncCall) out.Collections = getCollections(kfClient) + + log.Debug().Msgf("%s: getMetadata", DebugFuncCall) out.MetadataFields = getMetadata(kfClient) + + log.Debug().Msgf("%s: getExpirationAlerts", DebugFuncCall) out.ExpirationAlerts = getExpirationAlerts(kfClient) + + log.Debug().Msgf("%s: getIssuedAlerts", DebugFuncCall) out.IssuedCertAlerts = getIssuedAlerts(kfClient) + + log.Debug().Msgf("%s: getDeniedAlerts", DebugFuncCall) out.DeniedCertAlerts = getDeniedAlerts(kfClient) + + log.Debug().Msgf("%s: getPendingAlerts", DebugFuncCall) out.PendingCertAlerts = getPendingAlerts(kfClient) + + log.Debug().Msgf("%s: getSslNetworks", DebugFuncCall) out.Networks = getSslNetworks(kfClient) + + log.Debug().Msgf("%s: getWorkflowDefinitions", DebugFuncCall) out.WorkflowDefinitions = getWorkflowDefinitions(kfClient) + + log.Debug().Msgf("%s: getReports", DebugFuncCall) out.BuiltInReports, out.CustomReports = getReports(kfClient) + + log.Debug().Msgf("%s: getRoles", DebugFuncCall) out.SecurityRoles = getRoles(oldkfClient) } else { if cmd.Flag("collections").Value.String() == "true" { + log.Debug().Msgf("%s: getCollections", DebugFuncCall) out.Collections = getCollections(kfClient) } if cmd.Flag("metadata").Value.String() == "true" { + log.Debug().Msgf("%s: getMetadata", DebugFuncCall) out.MetadataFields = getMetadata(kfClient) } if cmd.Flag("expiration-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: getExpirationAlerts", DebugFuncCall) out.ExpirationAlerts = getExpirationAlerts(kfClient) } if cmd.Flag("issued-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: getIssuedAlerts", DebugFuncCall) out.IssuedCertAlerts = getIssuedAlerts(kfClient) } if cmd.Flag("denied-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: getDeniedAlerts", DebugFuncCall) out.DeniedCertAlerts = getDeniedAlerts(kfClient) } if cmd.Flag("pending-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: getPendingAlerts", DebugFuncCall) out.PendingCertAlerts = getPendingAlerts(kfClient) } if cmd.Flag("networks").Value.String() == "true" { + log.Debug().Msgf("%s: getSslNetworks", DebugFuncCall) out.Networks = getSslNetworks(kfClient) } if cmd.Flag("workflow-definitions").Value.String() == "true" { + log.Debug().Msgf("%s: getWorkflowDefinitions", DebugFuncCall) out.WorkflowDefinitions = getWorkflowDefinitions(kfClient) } if cmd.Flag("reports").Value.String() == "true" { + log.Debug().Msgf("%s: getReports", DebugFuncCall) out.BuiltInReports, out.CustomReports = getReports(kfClient) } if cmd.Flag("security-roles").Value.String() == "true" { + log.Debug().Msgf("%s: getRoles", DebugFuncCall) out.SecurityRoles = getRoles(oldkfClient) } } + log.Debug().Msgf("%s: exportToJSON", DebugFuncCall) exportToJSON(out, exportPath) + + log.Debug().Msgf("%s: exportCmd", DebugFuncExit) + log.Info().Msg("Export complete") + return nil }, } -func getCollections(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest { +func getCollections(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest { + log.Debug().Msgf("%s: getCollections", DebugFuncEnter) + + log.Debug().Msgf("%s: CertificateCollectionGetCollections", DebugFuncCall) collections, _, reqErr := kfClient.CertificateCollectionApi.CertificateCollectionGetCollections(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() + if reqErr != nil { + log.Error().Err(reqErr).Send() fmt.Printf("%s Error! Unable to get collections %s%s\n", ColorRed, reqErr, ColorWhite) } - var lCollectionReq []keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest + var lCollectionReq []kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest for _, collection := range collections { - cJson, _ := json.Marshal(collection) - var collectionReq keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest + log.Debug().Msgf("Marshalling collection %s", *collection.Name) + cJson, jmErr := json.Marshal(collection) + if jmErr != nil { + if collection.Name != nil && collection.Id != nil { + log.Error().Err(jmErr).Msgf("Error marshalling collection %s(%d)", *collection.Name, *collection.Id) + } + fmt.Printf("Error: %s\n", jmErr) + continue + } + + log.Debug().Msgf("Unmarshalling collection %s", *collection.Name) + var collectionReq kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest jErr := json.Unmarshal(cJson, &collectionReq) if jErr != nil { + log.Error().Err(jErr).Send() fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) } collectionReq.Query = collection.Content collectionReq.Id = nil + + log.Debug().Msgf("Appending collection %s", *collection.Name) lCollectionReq = append(lCollectionReq, collectionReq) } + log.Debug().Msgf("%s: getCollections", DebugFuncExit) return lCollectionReq } -func getMetadata(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest { +func getMetadata(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest { + log.Debug().Msgf("%s: getMetadata", DebugFuncEnter) + log.Debug().Msgf("%s: MetadataFieldGetAllMetadataFields", DebugFuncCall) metadata, _, reqErr := kfClient.MetadataFieldApi.MetadataFieldGetAllMetadataFields(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() if reqErr != nil { + log.Error().Err(reqErr).Send() fmt.Printf("%s Error! Unable to get metadata %s%s\n", ColorRed, reqErr, ColorWhite) + return nil } - var lMetadataReq []keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest + + var lMetadataReq []kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest for _, metadataItem := range metadata { - mJson, _ := json.Marshal(metadataItem) - var metadataReq keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest + mName := "" + if metadataItem.Name != nil { + mName = *metadataItem.Name + } else if metadataItem.Id != nil { + mName = fmt.Sprintf("%d", *metadataItem.Id) + } + log.Debug().Str("mName", mName).Msg("Marshalling metadata") + mJson, jmErr := json.Marshal(metadataItem) + if jmErr != nil { + log.Error().Err(jmErr).Send() + fmt.Printf("Error: %s\n", jmErr) + continue + } + + log.Debug().Msgf("Unmarshalling metadata '%s'", mName) + var metadataReq kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest jErr := json.Unmarshal(mJson, &metadataReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + continue } metadataItem.Id = nil + + log.Debug().Msgf("Appending metadata '%s'", mName) lMetadataReq = append(lMetadataReq, metadataReq) } return lMetadataReq } -func getExpirationAlerts(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest { +func getExpirationAlerts(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest { alerts, _, reqErr := kfClient.ExpirationAlertApi.ExpirationAlertGetExpirationAlerts(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() if reqErr != nil { fmt.Printf("%s Error! Unable to get expiration alerts %s%s\n", ColorRed, reqErr, ColorWhite) } - var lAlertReq []keyfactor.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest + var lAlertReq []kfc.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest for _, alert := range alerts { mJson, _ := json.Marshal(alert) - var alertReq keyfactor.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest + var alertReq kfc.KeyfactorApiModelsAlertsExpirationExpirationAlertCreationRequest jErr := json.Unmarshal(mJson, &alertReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + return nil // todo: maybe return the error instead? } lAlertReq = append(lAlertReq, alertReq) } return lAlertReq } -func getIssuedAlerts(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest { +func getIssuedAlerts(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest { alerts, _, reqErr := kfClient.IssuedAlertApi.IssuedAlertGetIssuedAlerts(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() if reqErr != nil { fmt.Printf("%s Error! Unable to get issued cert alerts %s%s\n", ColorRed, reqErr, ColorWhite) } - var lAlertReq []keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest + var lAlertReq []kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest for _, alert := range alerts { mJson, _ := json.Marshal(alert) - var alertReq keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest + var alertReq kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest jErr := json.Unmarshal(mJson, &alertReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + return nil // todo: maybe return the error instead? } - alertReq.TemplateId = nil + alertReq.TemplateId = kfc.NullableInt32{} lAlertReq = append(lAlertReq, alertReq) } return lAlertReq } -func getDeniedAlerts(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest { +func getDeniedAlerts(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest { alerts, _, reqErr := kfClient.DeniedAlertApi.DeniedAlertGetDeniedAlerts( context.Background()).XKeyfactorRequestedWith( @@ -274,82 +363,122 @@ func getDeniedAlerts(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiMode if reqErr != nil { fmt.Printf("%s Error! Unable to get denied cert alerts %s%s\n", ColorRed, reqErr, ColorWhite) } - var lAlertReq []keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest + var lAlertReq []kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest for _, alert := range alerts { mJson, _ := json.Marshal(alert) - var alertReq keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest + var alertReq kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest jErr := json.Unmarshal(mJson, &alertReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + return nil // todo: maybe return the error instead? } - alertReq.TemplateId = nil + alertReq.TemplateId = kfc.NullableInt32{} lAlertReq = append(lAlertReq, alertReq) } return lAlertReq } -func getPendingAlerts(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest { +func getPendingAlerts(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest { alerts, _, reqErr := kfClient.PendingAlertApi.PendingAlertGetPendingAlerts(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() if reqErr != nil { fmt.Printf("%s Error! Unable to get pending cert alerts %s%s\n", ColorRed, reqErr, ColorWhite) } - var lAlertReq []keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest + var lAlertReq []kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest for _, alert := range alerts { mJson, _ := json.Marshal(alert) - var alertReq keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest + var alertReq kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest jErr := json.Unmarshal(mJson, &alertReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() } - alertReq.TemplateId = nil + alertReq.TemplateId = kfc.NullableInt32{} lAlertReq = append(lAlertReq, alertReq) } return lAlertReq } -func getSslNetworks(kfClient *keyfactor.APIClient) []keyfactor.KeyfactorApiModelsSslCreateNetworkRequest { +func getSslNetworks(kfClient *kfc.APIClient) []kfc.KeyfactorApiModelsSslCreateNetworkRequest { - networks, _, reqErr := kfClient.SslApi.SslGetNetworks(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() + networks, _, reqErr := kfClient.SslApi. + SslGetNetworks(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() if reqErr != nil { fmt.Printf("%s Error! Unable to get SSL networks %s%s\n", ColorRed, reqErr, ColorWhite) } - var lNetworkReq []keyfactor.KeyfactorApiModelsSslCreateNetworkRequest + var lNetworkReq []kfc.KeyfactorApiModelsSslCreateNetworkRequest for _, network := range networks { mJson, _ := json.Marshal(network) - var networkReq keyfactor.KeyfactorApiModelsSslCreateNetworkRequest + var networkReq kfc.KeyfactorApiModelsSslCreateNetworkRequest jErr := json.Unmarshal(mJson, &networkReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + continue } lNetworkReq = append(lNetworkReq, networkReq) } return lNetworkReq } -func getWorkflowDefinitions(kfClient *keyfactor.APIClient) []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest { +func getWorkflowDefinitions(kfClient *kfc.APIClient) []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest { - workflowDefs, _, reqErr := kfClient.WorkflowDefinitionApi.WorkflowDefinitionQuery(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() + workflowDefs, _, reqErr := kfClient.WorkflowDefinitionApi. + WorkflowDefinitionQuery(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() if reqErr != nil { fmt.Printf("%s Error! Unable to get workflow definitions %s%s\n", ColorRed, reqErr, ColorWhite) } var lWorkflowReq []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest for _, workflowDef := range workflowDefs { - mJson, _ := json.Marshal(workflowDef) + mJson, mErr := json.Marshal(workflowDef) + if mErr != nil { + fmt.Printf("Error: %s\n", mErr) + //log.Fatalf("Error: %s", mErr) + log.Error().Err(mErr).Send() //todo: better error message? + continue + } var workflowReq exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest jErr := json.Unmarshal(mJson, &workflowReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() //todo: better error message? + continue } if workflowDef.Key != nil { - key, _ := strconv.ParseInt(*workflowDef.Key, 10, 64) + key, convErr := strconv.ParseInt(*workflowDef.Key, 10, 64) + if convErr != nil { + fmt.Printf("Error: %s\n", convErr) + //log.Fatalf("Error: %s", convErr) + log.Error().Err(convErr).Send() //todo: better error message? + continue + } key32 := int32(key) - template, _, _ := kfClient.TemplateApi.TemplateGetTemplate(context.Background(), key32).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() - workflowReq.KeyName = template.TemplateName + templatesResp, httpResp, httpRespErr := kfClient.TemplateApi.TemplateGetTemplates(context.Background()). + SqQueryString(query). + Execute() + template, _, tErr := kfClient.TemplateApi. + TemplateGetTemplate(context.Background(), key32). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() + if tErr != nil { + log.Error().Err(tErr).Send() //todo: better error message? + continue + } + if template != nil { + workflowReq.KeyName = template.TemplateName + } } workflowReq.Key = nil lWorkflowReq = append(lWorkflowReq, workflowReq) @@ -357,7 +486,7 @@ func getWorkflowDefinitions(kfClient *keyfactor.APIClient) []exportKeyfactorAPIM return lWorkflowReq } -func getReports(kfClient *keyfactor.APIClient) ([]exportModelsReport, []keyfactor.ModelsCustomReportCreationRequest) { +func getReports(kfClient *kfc.APIClient) ([]exportModelsReport, []kfc.ModelsCustomReportCreationRequest) { //Gets all built-in reports bReports, _, bErr := kfClient.ReportsApi.ReportsQueryReports(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() @@ -366,12 +495,20 @@ func getReports(kfClient *keyfactor.APIClient) ([]exportModelsReport, []keyfacto } var lbReportsReq []exportModelsReport for _, bReport := range bReports { - mJson, _ := json.Marshal(bReport) + mJson, mErr := json.Marshal(bReport) + if mErr != nil { + fmt.Printf("Error: %s\n", mErr) + //log.Fatalf("Error: %s", mErr) + log.Error().Err(mErr).Send() //todo: better error message? + continue + } var newbReport exportModelsReport jErr := json.Unmarshal(mJson, &newbReport) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() //todo: better error message? + continue } newbReport.ID = nil lbReportsReq = append(lbReportsReq, newbReport) @@ -381,14 +518,16 @@ func getReports(kfClient *keyfactor.APIClient) ([]exportModelsReport, []keyfacto if cErr != nil { fmt.Printf("%s Error! Unable to get custom reports %s%s\n", ColorRed, cErr, ColorWhite) } - var lcReportReq []keyfactor.ModelsCustomReportCreationRequest + var lcReportReq []kfc.ModelsCustomReportCreationRequest for _, cReport := range cReports { mJson, _ := json.Marshal(cReport) - var cReportReq keyfactor.ModelsCustomReportCreationRequest + var cReportReq kfc.ModelsCustomReportCreationRequest jErr := json.Unmarshal(mJson, &cReportReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() //todo: better error message? + continue } lcReportReq = append(lcReportReq, cReportReq) } @@ -407,7 +546,9 @@ func getRoles(kfClient *api.Client) []api.CreateSecurityRoleArg { jErr := json.Unmarshal(mJson, &cRoleReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() //todo: better error message? + continue } lRoleReq = append(lRoleReq, cRoleReq) } @@ -415,10 +556,23 @@ func getRoles(kfClient *api.Client) []api.CreateSecurityRoleArg { } func init() { + var exportPath string + var fCollections bool + var fMetadata bool + var fExpirationAlerts bool + var fIssuedAlerts bool + var fDeniedAlerts bool + var fPendingAlerts bool + var fNetworks bool + var fWorkflowDefinitions bool + var fReports bool + var fSecurityRoles bool + var fAll bool + RootCmd.AddCommand(exportCmd) - exportCmd.Flags().StringVarP(&exportPath, "file", "f", "", "path to JSON output file with exported data") - exportCmd.MarkFlagRequired("file") + exportCmd.Flags().StringVarP(&exportPath, "file", "f", fmt.Sprintf("keyfactor_command_export_%d.json", CLINow), "path to JSON output file with exported data") + //exportCmd.MarkFlagRequired("file") exportCmd.Flags().BoolVarP(&fAll, "all", "a", false, "export all exportable data to JSON file") exportCmd.Flags().Lookup("all").NoOptDefVal = "true" diff --git a/cmd/helm.go b/cmd/helm.go index 7c1f881f..436f9fb4 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/helm_test.go b/cmd/helm_test.go index 5d6c1586..4880b75f 100644 --- a/cmd/helm_test.go +++ b/cmd/helm_test.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/helm_uo.go b/cmd/helm_uo.go index 22ebbd9b..44107e55 100644 --- a/cmd/helm_uo.go +++ b/cmd/helm_uo.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/helm_uo_test.go b/cmd/helm_uo_test.go index b992678d..6454ca9b 100644 --- a/cmd/helm_uo_test.go +++ b/cmd/helm_uo_test.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/helpers.go b/cmd/helpers.go index a60e73d5..2c084477 100644 --- a/cmd/helpers.go +++ b/cmd/helpers.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -388,6 +388,10 @@ func writeJSONFile(filename string, data interface{}) error { } func returnHttpErr(resp *http.Response, err error) error { + if resp == nil { + log.Error().Err(err).Msg("unable to create PAM provider - no response") + return err + } if resp.Body != nil { body, _ := io.ReadAll(resp.Body) log.Error().Err(err).Str("httpResponseCode", resp.Status). diff --git a/cmd/import.go b/cmd/import.go index cd36d8b0..7d886739 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ import ( "context" "encoding/json" "fmt" - "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor" + kfc "github.com/Keyfactor/keyfactor-go-client-sdk/v10/api/command" "github.com/Keyfactor/keyfactor-go-client/v2/api" + "github.com/rs/zerolog/log" "github.com/spf13/cobra" "io" - "log" "os" ) @@ -32,9 +32,23 @@ type Body struct { } func parseError(error io.ReadCloser) string { - bytes, _ := io.ReadAll(error) + log.Debug().Msgf("%s: parseError", DebugFuncEnter) + + log.Debug().Msg("Reading error body") + bytes, ioErr := io.ReadAll(error) + if ioErr != nil { + fmt.Printf("Error: %s\n", ioErr) + log.Error().Err(ioErr).Send() + return ioErr.Error() + } var newError Body - json.Unmarshal(bytes, &newError) + jErr := json.Unmarshal(bytes, &newError) + if jErr != nil { + fmt.Printf("Error: %s\n", jErr) + log.Error().Err(jErr).Send() + return jErr.Error() + } + log.Debug().Msgf("%s: parseError", DebugFuncExit) return newError.Message } @@ -42,111 +56,197 @@ var importCmd = &cobra.Command{ Use: "import", Short: "Keyfactor instance import utilities.", Long: `A collection of APIs and utilities for importing Keyfactor instance data.`, - Run: func(cmd *cobra.Command, args []string) { - - authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) - isExperimental := true + RunE: func(cmd *cobra.Command, args []string) error { + log.Debug().Msgf("%s: importCmd", DebugFuncEnter) + isExperimental := false - _, expErr := isExperimentalFeatureEnabled(expEnabled, isExperimental) - if expErr != nil { - fmt.Println(fmt.Sprintf("WARNING this is an expEnabled feature, %s", expErr)) - log.Fatalf("[ERROR]: %s", expErr) + informDebug(debugFlag) + debugErr := warnExperimentalFeature(expEnabled, isExperimental) + if debugErr != nil { + return debugErr } - debugModeEnabled := checkDebug(debugFlag) - log.Println("Debug mode enabled: ", debugModeEnabled) + log.Info().Msg("Running import...") + + log.Debug().Msgf("%s: createAuthConfigFromParams", DebugFuncCall) + authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) + if authConfig == nil { + return fmt.Errorf("Error: %s", FailedAuthMsg) + } exportPath := cmd.Flag("file").Value.String() + log.Debug().Str("exportPath", exportPath).Msg("exportPath") + + log.Debug().Str("exportPath", exportPath). + Msg("Reading exported file") + jsonFile, oErr := os.Open(exportPath) if oErr != nil { fmt.Printf("Error opening exported file: %s\n", oErr) - log.Fatalf("Error: %s", oErr) + //log.Fatalf("Error: %s", oErr) + log.Error(). + Str("exportPath", exportPath). + Err(oErr). + Send() } defer jsonFile.Close() var out outJson - bJson, _ := io.ReadAll(jsonFile) + bJson, ioErr := io.ReadAll(jsonFile) + if ioErr != nil { + fmt.Printf("Error reading exported file: %s\n", ioErr) + //log.Fatalf("Error: %s", ioErr) + log.Error().Err(ioErr).Send() + return ioErr + } jErr := json.Unmarshal(bJson, &out) if jErr != nil { fmt.Printf("Error reading exported file: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() + return jErr } - kfClient, _ := initGenClient(configFile, profile, noPrompt, authConfig, false) - oldkfClient, _ := initClient(configFile, profile, "", "", noPrompt, authConfig, false) + log.Debug().Msgf("%s: initGenClient", DebugFuncCall) + kfClient, clientErr := initGenClient(configFile, profile, noPrompt, authConfig, false) + log.Debug().Msgf("%s: initClient", DebugFuncExit) + oldkfClient, oldClientErr := initClient(configFile, profile, "", "", noPrompt, authConfig, false) + + if clientErr != nil { + log.Error().Err(clientErr).Send() + return clientErr + } else if oldClientErr != nil { + log.Error().Err(oldClientErr).Send() + return oldClientErr + } + if cmd.Flag("all").Value.String() == "true" { + log.Debug().Msgf("%s: importCollections", DebugFuncCall) importCollections(out.Collections, kfClient) + log.Debug().Msgf("%s: importMetadataFields", DebugFuncCall) importMetadataFields(out.MetadataFields, kfClient) + + log.Debug().Msgf("%s: importIssuedCertAlerts", DebugFuncCall) importIssuedCertAlerts(out.IssuedCertAlerts, kfClient) + + log.Debug().Msgf("%s: importDeniedCertAlerts", DebugFuncCall) importDeniedCertAlerts(out.DeniedCertAlerts, kfClient) + + log.Debug().Msgf("%s: importPendingCertAlerts", DebugFuncCall) importPendingCertAlerts(out.PendingCertAlerts, kfClient) + + log.Debug().Msgf("%s: importNetworks", DebugFuncCall) importNetworks(out.Networks, kfClient) + + log.Debug().Msgf("%s: importWorkflowDefinitions", DebugFuncCall) importWorkflowDefinitions(out.WorkflowDefinitions, kfClient) + + log.Debug().Msgf("%s: importBuiltInReports", DebugFuncCall) importBuiltInReports(out.BuiltInReports, kfClient) + + log.Debug().Msgf("%s: importCustomReports", DebugFuncCall) importCustomReports(out.CustomReports, kfClient) + + log.Debug().Msgf("%s: importSecurityRoles", DebugFuncCall) importSecurityRoles(out.SecurityRoles, oldkfClient) } else { if len(out.Collections) != 0 && cmd.Flag("collections").Value.String() == "true" { + log.Debug().Msgf("%s: importCollections", DebugFuncCall) importCollections(out.Collections, kfClient) } if len(out.MetadataFields) != 0 && cmd.Flag("metadata").Value.String() == "true" { + log.Debug().Msgf("%s: importMetadataFields", DebugFuncCall) importMetadataFields(out.MetadataFields, kfClient) } if len(out.IssuedCertAlerts) != 0 && cmd.Flag("issued-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: importIssuedCertAlerts", DebugFuncCall) importIssuedCertAlerts(out.IssuedCertAlerts, kfClient) } if len(out.DeniedCertAlerts) != 0 && cmd.Flag("denied-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: importDeniedCertAlerts", DebugFuncCall) importDeniedCertAlerts(out.DeniedCertAlerts, kfClient) } if len(out.PendingCertAlerts) != 0 && cmd.Flag("pending-alerts").Value.String() == "true" { + log.Debug().Msgf("%s: importPendingCertAlerts", DebugFuncCall) importPendingCertAlerts(out.PendingCertAlerts, kfClient) } if len(out.Networks) != 0 && cmd.Flag("networks").Value.String() == "true" { + log.Debug().Msgf("%s: importNetworks", DebugFuncCall) importNetworks(out.Networks, kfClient) } if len(out.WorkflowDefinitions) != 0 && cmd.Flag("workflow-definitions").Value.String() == "true" { + log.Debug().Msgf("%s: importWorkflowDefinitions", DebugFuncCall) importWorkflowDefinitions(out.WorkflowDefinitions, kfClient) } if len(out.BuiltInReports) != 0 && cmd.Flag("reports").Value.String() == "true" { + log.Debug().Msgf("%s: importBuiltInReports", DebugFuncCall) importBuiltInReports(out.BuiltInReports, kfClient) } if len(out.CustomReports) != 0 && cmd.Flag("reports").Value.String() == "true" { + log.Debug().Msgf("%s: importCustomReports", DebugFuncCall) importCustomReports(out.CustomReports, kfClient) } if len(out.SecurityRoles) != 0 && cmd.Flag("security-roles").Value.String() == "true" { + log.Debug().Msgf("%s: importSecurityRoles", DebugFuncCall) importSecurityRoles(out.SecurityRoles, oldkfClient) } } + log.Debug().Msgf("%s: importCmd", DebugFuncExit) + return nil }, } -func importCollections(collections []keyfactor.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest, kfClient *keyfactor.APIClient) { +func importCollections(collections []kfc.KeyfactorApiModelsCertificateCollectionsCertificateCollectionCreateRequest, kfClient *kfc.APIClient) { for _, collection := range collections { - _, httpResp, reqErr := kfClient.CertificateCollectionApi.CertificateCollectionCreateCollection(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith). - Request(collection).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() - name, _ := json.Marshal(collection.Name) + _, httpResp, reqErr := kfClient.CertificateCollectionApi. + CertificateCollectionCreateCollection(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + Request(collection). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() + name, jmErr := json.Marshal(collection.Name) + if jmErr != nil { + fmt.Printf("Error: %s\n", jmErr) + //log.Fatalf("Error: %s", jmErr) + log.Error().Err(jmErr).Send() + } if reqErr != nil { fmt.Printf("%s Error! Unable to create collection %s - %s%s\n", ColorRed, string(name), parseError(httpResp.Body), ColorWhite) } else { - name, _ := json.Marshal(collection.Name) - fmt.Println("Added", string(name), "to collections") + n, jnErr := json.Marshal(collection.Name) + if jnErr != nil { + fmt.Printf("Error: %s\n", jnErr) + //log.Fatalf("Error: %s", jnErr) + log.Error().Err(jnErr).Send() + } + fmt.Println("Added", string(n), "to collections") } } } -func importMetadataFields(metadataFields []keyfactor.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest, kfClient *keyfactor.APIClient) { +func importMetadataFields(metadataFields []kfc.KeyfactorApiModelsMetadataFieldMetadataFieldCreateRequest, kfClient *kfc.APIClient) { for _, metadata := range metadataFields { _, httpResp, reqErr := kfClient.MetadataFieldApi.MetadataFieldCreateMetadataField(context.Background()). - XKeyfactorRequestedWith(XKeyfactorRequestedWith).MetadataFieldType(metadata). - XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() - name, _ := json.Marshal(metadata.Name) + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + MetadataFieldType(metadata). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() + n, jmErr := json.Marshal(metadata.Name) + if reqErr != nil { - fmt.Printf("%s Error! Unable to create metadata field type %s - %s%s\n", ColorRed, string(name), parseError(httpResp.Body), ColorWhite) + if jmErr != nil { + fmt.Printf("Error: %s\n", jmErr) + //log.Fatalf("Error: %s", jmErr) + log.Error().Err(jmErr).Send() + } + log.Error().Err(reqErr).Send() + fmt.Printf("%s Error! Unable to create metadata field type %s - %s%s\n", ColorRed, string(n), parseError(httpResp.Body), ColorWhite) } else { - fmt.Println("Added", string(name), "to metadata field types.") + log.Info().Msgf("Added %s to metadata field types.", string(n)) + fmt.Println("Added", string(n), "to metadata field types.") } } } -func importIssuedCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest, kfClient *keyfactor.APIClient) { +func importIssuedCertAlerts(alerts []kfc.KeyfactorApiModelsAlertsIssuedIssuedAlertCreationRequest, kfClient *kfc.APIClient) { for _, alert := range alerts { _, httpResp, reqErr := kfClient.IssuedAlertApi.IssuedAlertAddIssuedAlert(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Req(alert).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() name, _ := json.Marshal(alert.DisplayName) @@ -158,7 +258,7 @@ func importIssuedCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsIssuedIss } } -func importDeniedCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest, kfClient *keyfactor.APIClient) { +func importDeniedCertAlerts(alerts []kfc.KeyfactorApiModelsAlertsDeniedDeniedAlertCreationRequest, kfClient *kfc.APIClient) { for _, alert := range alerts { _, httpResp, reqErr := kfClient.DeniedAlertApi.DeniedAlertAddDeniedAlert(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Req(alert).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() name, _ := json.Marshal(alert.DisplayName) @@ -170,7 +270,7 @@ func importDeniedCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsDeniedDen } } -func importPendingCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest, kfClient *keyfactor.APIClient) { +func importPendingCertAlerts(alerts []kfc.KeyfactorApiModelsAlertsPendingPendingAlertCreationRequest, kfClient *kfc.APIClient) { for _, alert := range alerts { _, httpResp, reqErr := kfClient.PendingAlertApi.PendingAlertAddPendingAlert(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Req(alert).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() name, _ := json.Marshal(alert.DisplayName) @@ -182,7 +282,7 @@ func importPendingCertAlerts(alerts []keyfactor.KeyfactorApiModelsAlertsPendingP } } -func importNetworks(networks []keyfactor.KeyfactorApiModelsSslCreateNetworkRequest, kfClient *keyfactor.APIClient) { +func importNetworks(networks []kfc.KeyfactorApiModelsSslCreateNetworkRequest, kfClient *kfc.APIClient) { for _, network := range networks { _, httpResp, reqErr := kfClient.SslApi.SslCreateNetwork(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Network(network).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() name, _ := json.Marshal(network.Name) @@ -195,7 +295,7 @@ func importNetworks(networks []keyfactor.KeyfactorApiModelsSslCreateNetworkReque } // identify matching templates between instances by name, then return the template Id of the matching template in the import instance -func findMatchingTemplates(exportedWorkflowDef exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest, kfClient *keyfactor.APIClient) *string { +func findMatchingTemplates(exportedWorkflowDef exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest, kfClient *kfc.APIClient) *string { importInstanceTemplates, _, _ := kfClient.TemplateApi.TemplateGetTemplates(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() for _, template := range importInstanceTemplates { importInstTempNameJson, _ := json.Marshal(template.TemplateName) @@ -209,31 +309,46 @@ func findMatchingTemplates(exportedWorkflowDef exportKeyfactorAPIModelsWorkflows return nil } -func importWorkflowDefinitions(workflowDefs []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest, kfClient *keyfactor.APIClient) { +func importWorkflowDefinitions(workflowDefs []exportKeyfactorAPIModelsWorkflowsDefinitionCreateRequest, kfClient *kfc.APIClient) { for _, workflowDef := range workflowDefs { wJson, _ := json.Marshal(workflowDef) - var workflowDefReq keyfactor.KeyfactorApiModelsWorkflowsDefinitionCreateRequest + var workflowDefReq kfc.KeyfactorApiModelsWorkflowsDefinitionCreateRequest jErr := json.Unmarshal(wJson, &workflowDefReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() } newTemplateId := findMatchingTemplates(workflowDef, kfClient) if newTemplateId != nil { workflowDefReq.Key = newTemplateId } - _, httpResp, reqErr := kfClient.WorkflowDefinitionApi.WorkflowDefinitionCreateNewDefinition(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Request(workflowDefReq).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() - name, _ := json.Marshal(workflowDef.DisplayName) + _, httpResp, reqErr := kfClient.WorkflowDefinitionApi. // todo: Why is the object not being used? + WorkflowDefinitionCreateNewDefinition(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + Request(workflowDefReq). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() + name, jmErr := json.Marshal(workflowDef.DisplayName) + if jmErr != nil { + fmt.Printf("Error: %s\n", jmErr) + //log.Fatalf("Error: %s", jmErr) + log.Error().Err(jmErr).Send() + return + } + if reqErr != nil { fmt.Printf("%s Error! Unable to create workflow definition %s - %s%s\n", ColorRed, string(name), parseError(httpResp.Body), ColorWhite) + log.Error().Err(reqErr).Send() } else { fmt.Println("Added", string(name), "to workflow definitions.") + log.Info().Msgf("Added %s to workflow definitions.", string(name)) } } } // check for built-in report discrepancies between instances, return the report id of reports that need to be updated in import instance -func checkBuiltInReportDiffs(exportedReport exportModelsReport, kfClient *keyfactor.APIClient) *int32 { +func checkBuiltInReportDiffs(exportedReport exportModelsReport, kfClient *kfc.APIClient) *int32 { importInstanceReports, _, _ := kfClient.ReportsApi.ReportsQueryReports(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() //check if built in report was modified from default in exported instance; if modified, update built-in report in new instance for _, report := range importInstanceReports { @@ -259,30 +374,44 @@ func checkBuiltInReportDiffs(exportedReport exportModelsReport, kfClient *keyfac } // only imports built in reports where UsesCollections is false -func importBuiltInReports(reports []exportModelsReport, kfClient *keyfactor.APIClient) { +func importBuiltInReports(reports []exportModelsReport, kfClient *kfc.APIClient) { for _, report := range reports { newReportId := checkBuiltInReportDiffs(report, kfClient) if newReportId != nil { rJson, _ := json.Marshal(report) - var reportReq keyfactor.ModelsReportRequestModel + var reportReq kfc.ModelsReportRequestModel jErr := json.Unmarshal(rJson, &reportReq) if jErr != nil { fmt.Printf("Error: %s\n", jErr) - log.Fatalf("Error: %s", jErr) + //log.Fatalf("Error: %s", jErr) + log.Error().Err(jErr).Send() } reportReq.Id = newReportId - _, httpResp, reqErr := kfClient.ReportsApi.ReportsUpdateReport(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Request(reportReq).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() - name, _ := json.Marshal(report.DisplayName) + _, httpResp, reqErr := kfClient.ReportsApi. //todo: Why is the object not being used? + ReportsUpdateReport(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + Request(reportReq). + XKeyfactorApiVersion(XKeyfactorApiVersion). + Execute() + name, jmErr := json.Marshal(report.DisplayName) + if jmErr != nil { + fmt.Printf("Error: %s\n", jmErr) + //log.Fatalf("Error: %s", jmErr) + log.Error().Err(jmErr).Send() + return + } if reqErr != nil { fmt.Printf("%s Error! Unable to update built-in report %s - %s%s\n", ColorRed, string(name), parseError(httpResp.Body), ColorWhite) + log.Error().Err(reqErr).Send() } else { fmt.Println("Updated", string(name), "in built-in reports.") + log.Info().Msgf("Updated %s in built-in reports.", string(name)) } } } } -func importCustomReports(reports []keyfactor.ModelsCustomReportCreationRequest, kfClient *keyfactor.APIClient) { +func importCustomReports(reports []kfc.ModelsCustomReportCreationRequest, kfClient *kfc.APIClient) { for _, report := range reports { _, httpResp, reqErr := kfClient.ReportsApi.ReportsCreateCustomReport(context.Background()).XKeyfactorRequestedWith(XKeyfactorRequestedWith).Request(report).XKeyfactorApiVersion(XKeyfactorApiVersion).Execute() name, _ := json.Marshal(report.DisplayName) @@ -307,9 +436,22 @@ func importSecurityRoles(roles []api.CreateSecurityRoleArg, kfClient *api.Client } func init() { + var importFilePath string + var fCollections bool + var fMetadata bool + //var fExpirationAlerts bool + var fIssuedAlerts bool + var fDeniedAlerts bool + var fPendingAlerts bool + var fNetworks bool + var fWorkflowDefinitions bool + var fReports bool + var fSecurityRoles bool + var fAll bool + RootCmd.AddCommand(importCmd) - importCmd.Flags().StringVarP(&exportPath, "file", "f", "", "path to JSON file containing exported data") + importCmd.Flags().StringVarP(&importFilePath, "file", "f", "", "path to JSON file containing exported data") importCmd.MarkFlagRequired("file") importCmd.Flags().BoolVarP(&fAll, "all", "a", false, "import all importable data to JSON file") diff --git a/cmd/inventory.go b/cmd/inventory.go index 0e19300a..0b004ecf 100644 --- a/cmd/inventory.go +++ b/cmd/inventory.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/login.go b/cmd/login.go index 7e44de78..c0c4226b 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package cmd import ( "encoding/json" "fmt" - "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor" + kfc "github.com/Keyfactor/keyfactor-go-client-sdk/v11/api/command" "github.com/Keyfactor/keyfactor-go-client/v2/api" "github.com/google/go-cmp/cmp" "github.com/rs/zerolog/log" @@ -598,7 +598,7 @@ func authViaProvider() (*api.Client, error) { return nil, fmt.Errorf("unable to auth via provider, providerType is empty") } -func authViaProviderGenClient() (*keyfactor.APIClient, error) { +func authViaProviderGenClient() (*kfc.APIClient, error) { var commandConfig ConfigurationFile if providerType != "" { log.Info().Str("providerType", providerType).Msg("attempting to auth via auth provider") @@ -680,8 +680,13 @@ func authViaProviderGenClient() (*keyfactor.APIClient, error) { Msg("Client authentication params") log.Debug().Msg("call: api.NewKeyfactorClient()") - configuration := keyfactor.NewConfiguration(sdkClientConfig) - c := keyfactor.NewAPIClient(configuration) + configuration, authErr := kfc.NewConfiguration(sdkClientConfig) + if authErr != nil { + log.Error().Err(authErr).Send() + outputError(authErr, true, "text") + return nil, authErr + } + c := kfc.NewAPIClient(configuration) log.Debug().Msg("complete: api.NewKeyfactorClient()") log.Info().Msg("Keyfactor Command client created") log.Debug().Str("flagAuthProvider", providerType). diff --git a/cmd/login_test.go b/cmd/login_test.go index 28962b57..6fda933c 100644 --- a/cmd/login_test.go +++ b/cmd/login_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -164,7 +164,12 @@ func testConfigExists(t *testing.T, filePath string, allowExist bool) { } // Verify that the config file has the correct keys assert.Contains(t, fileConfigJSON, "servers") - kfcServers := fileConfigJSON["servers"].(map[string]interface{}) + kfcServers, ok := fileConfigJSON["servers"].(map[string]interface{}) + if !ok { + t.Errorf("Error decoding config file: %s", err) + assert.False(t, ok, "Error decoding config file") + return + } assert.Contains(t, kfcServers, "default") defaultServer := kfcServers["default"].(map[string]interface{}) assert.Contains(t, defaultServer, "host") diff --git a/cmd/logout.go b/cmd/logout.go index 4aafe1de..21c9ec37 100644 --- a/cmd/logout.go +++ b/cmd/logout.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/models.go b/cmd/models.go index 60de4973..0624d707 100644 --- a/cmd/models.go +++ b/cmd/models.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/orchs.go b/cmd/orchs.go index 3c5cdf7c..47d85ff1 100644 --- a/cmd/orchs.go +++ b/cmd/orchs.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/orchs_ext.go b/cmd/orchs_ext.go index c6444c18..e1521825 100644 --- a/cmd/orchs_ext.go +++ b/cmd/orchs_ext.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/orchs_ext_test.go b/cmd/orchs_ext_test.go index 7263a954..3e87710d 100644 --- a/cmd/orchs_ext_test.go +++ b/cmd/orchs_ext_test.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/pam.go b/cmd/pam.go index cd894670..c0aba031 100644 --- a/cmd/pam.go +++ b/cmd/pam.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import ( "context" "encoding/json" "fmt" - "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor" + kfc "github.com/Keyfactor/keyfactor-go-client-sdk/v11/api/command" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "io" @@ -27,10 +27,14 @@ import ( ) type JSONImportableObject interface { - keyfactor.KeyfactorApiPAMProviderTypeCreateRequest | - keyfactor.CSSCMSDataModelModelsProvider + kfc.KeyfactorApiPAMProviderTypeCreateRequest | + kfc.CSSCMSDataModelModelsProvider } +const ( + convertResponseMsg = "Converting PAM Provider response to JSON" +) + var pamCmd = &cobra.Command{ Use: "pam", Short: "Keyfactor PAM Provider APIs.", @@ -58,19 +62,30 @@ var pamTypesListCmd = &cobra.Command{ // Authenticate authConfig := createAuthConfigFromParams(kfcHostName, kfcUsername, kfcPassword, kfcDomain, kfcAPIPath) - sdkClient, _ := initGenClient(configFile, profile, noPrompt, authConfig, false) + sdkClient, clientErr := initGenClient(configFile, profile, noPrompt, authConfig, false) + if clientErr != nil { + return clientErr + } // CLI Logic log.Debug().Msg("call: PAMProviderGetPamProviderTypes()") - pamTypes, httpResponse, err := sdkClient.PAMProviderApi.PAMProviderGetPamProviderTypes(context.Background()). - XKeyfactorRequestedWith(XKeyfactorRequestedWith).XKeyfactorApiVersion(XKeyfactorApiVersion). + pamTypes, httpResponse, err := sdkClient.PAMProviderApi. + PAMProviderGetPamProviderTypes(context.Background()). + XKeyfactorRequestedWith(XKeyfactorRequestedWith). + XKeyfactorApiVersion(XKeyfactorApiVersion). Execute() log.Debug().Msg("returned: PAMProviderGetPamProviderTypes()") log.Trace().Interface("httpResponse", httpResponse). Msg("PAMProviderGetPamProviderTypes") if err != nil { + var status string + if httpResponse != nil { + status = httpResponse.Status + } else { + status = "No HTTP response received from Keyfactor Command." + } log.Error().Err(err). - Str("httpResponseCode", httpResponse.Status). + Str("httpResponseCode", status). Msg("error listing PAM provider types") return err } @@ -101,7 +116,7 @@ https://github.com/Keyfactor/hashicorp-vault-pam/blob/main/integration-manifest. isExperimental := false // Specific flags - pamConfigFile, _ := cmd.Flags().GetString("from-file") + pamConfigFile, _ := cmd.Flags().GetString(FlagFromFile) pamProviderName, _ := cmd.Flags().GetString("name") repoName, _ := cmd.Flags().GetString("repo") branchName, _ := cmd.Flags().GetString("branch") @@ -135,7 +150,7 @@ https://github.com/Keyfactor/hashicorp-vault-pam/blob/main/integration-manifest. // CLI Logic - var pamProviderType *keyfactor.KeyfactorApiPAMProviderTypeCreateRequest + var pamProviderType *kfc.KeyfactorApiPAMProviderTypeCreateRequest var err error if repoName != "" { // get JSON config from integration-manifest on GitHub @@ -152,9 +167,9 @@ https://github.com/Keyfactor/hashicorp-vault-pam/blob/main/integration-manifest. } } else { log.Debug().Str("pamConfigFile", pamConfigFile). - Msg("call: GetTypeFromConfigFile()") + Msg(fmt.Sprintf("call: %s", "GetTypeFromConfigFile()")) pamProviderType, err = GetTypeFromConfigFile(pamConfigFile, pamProviderType) - log.Debug().Msg("returned: GetTypeFromConfigFile()") + log.Debug().Msg(fmt.Sprintf("returned: %s", "GetTypeFromConfigFile()")) if err != nil { log.Error().Err(err).Send() return err @@ -283,7 +298,7 @@ var pamProvidersGetCmd = &cobra.Command{ return err } - log.Debug().Msg("Converting PAM Provider response to JSON") + log.Debug().Msg(convertResponseMsg) jsonString, mErr := json.Marshal(pamProvider) if mErr != nil { log.Error().Err(mErr).Send() @@ -305,7 +320,7 @@ var pamProvidersCreateCmd = &cobra.Command{ isExperimental := false // Specific flags - pamConfigFile, _ := cmd.Flags().GetString("from-file") + pamConfigFile, _ := cmd.Flags().GetString(FlagFromFile) // Debug + expEnabled checks informDebug(debugFlag) @@ -324,7 +339,7 @@ var pamProvidersCreateCmd = &cobra.Command{ sdkClient, _ := initGenClient(configFile, profile, noPrompt, authConfig, false) // CLI Logic - var pamProvider *keyfactor.CSSCMSDataModelModelsProvider + var pamProvider *kfc.CSSCMSDataModelModelsProvider log.Debug().Msg("call: GetTypeFromConfigFile()") pamProvider, err := GetTypeFromConfigFile(pamConfigFile, pamProvider) log.Debug().Msg("returned: GetTypeFromConfigFile()") @@ -348,7 +363,7 @@ var pamProvidersCreateCmd = &cobra.Command{ return returnHttpErr(httpResponse, cErr) } - log.Debug().Msg("Converting PAM Provider response to JSON") + log.Debug().Msg(convertResponseMsg) jsonString, mErr := json.Marshal(createdPamProvider) if mErr != nil { log.Error().Err(mErr).Msg("invalid API response from Keyfactor Command") @@ -369,7 +384,7 @@ var pamProvidersUpdateCmd = &cobra.Command{ isExperimental := false // Specific flags - pamConfigFile, _ := cmd.Flags().GetString("from-file") + pamConfigFile, _ := cmd.Flags().GetString(FlagFromFile) // Debug + expEnabled checks informDebug(debugFlag) @@ -388,7 +403,7 @@ var pamProvidersUpdateCmd = &cobra.Command{ sdkClient, _ := initGenClient(configFile, profile, noPrompt, authConfig, false) // CLI Logic - var pamProvider *keyfactor.CSSCMSDataModelModelsProvider + var pamProvider *kfc.CSSCMSDataModelModelsProvider log.Debug().Str("file", pamConfigFile). Msg("call: GetTypeFromConfigFile()") pamProvider, err := GetTypeFromConfigFile(pamConfigFile, pamProvider) @@ -410,7 +425,7 @@ var pamProvidersUpdateCmd = &cobra.Command{ returnHttpErr(httpResponse, err) } - log.Debug().Msg("Converting PAM Provider response to JSON") + log.Debug().Msg(convertResponseMsg) jsonString, mErr := json.Marshal(createdPamProvider) if mErr != nil { log.Error().Err(mErr).Msg("invalid API response from Keyfactor Command") @@ -614,7 +629,7 @@ func init() { // PAM Provider Types Create pamCmd.AddCommand(pamTypesCreateCmd) - pamTypesCreateCmd.Flags().StringVarP(&filePath, "from-file", "f", "", "Path to a JSON file containing the PAM Type Object Data.") + pamTypesCreateCmd.Flags().StringVarP(&filePath, FlagFromFile, "f", "", "Path to a JSON file containing the PAM Type Object Data.") pamTypesCreateCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the PAM Provider Type.") pamTypesCreateCmd.Flags().StringVarP(&repo, "repo", "r", "", "Keyfactor repository name of the PAM Provider Type.") pamTypesCreateCmd.Flags().StringVarP(&branch, "branch", "b", "", "Branch name for the repository. Defaults to 'main'.") @@ -626,12 +641,12 @@ func init() { pamProvidersGetCmd.MarkFlagRequired("id") pamCmd.AddCommand(pamProvidersCreateCmd) - pamProvidersCreateCmd.Flags().StringVarP(&filePath, "from-file", "f", "", "Path to a JSON file containing the PAM Provider Object Data.") - pamProvidersCreateCmd.MarkFlagRequired("from-file") + pamProvidersCreateCmd.Flags().StringVarP(&filePath, FlagFromFile, "f", "", "Path to a JSON file containing the PAM Provider Object Data.") + pamProvidersCreateCmd.MarkFlagRequired(FlagFromFile) pamCmd.AddCommand(pamProvidersUpdateCmd) - pamProvidersUpdateCmd.Flags().StringVarP(&filePath, "from-file", "f", "", "Path to a JSON file containing the PAM Provider Object Data.") - pamProvidersUpdateCmd.MarkFlagRequired("from-file") + pamProvidersUpdateCmd.Flags().StringVarP(&filePath, FlagFromFile, "f", "", "Path to a JSON file containing the PAM Provider Object Data.") + pamProvidersUpdateCmd.MarkFlagRequired(FlagFromFile) pamCmd.AddCommand(pamProvidersDeleteCmd) pamProvidersDeleteCmd.Flags().Int32VarP(&id, "id", "i", 0, "Integer ID of the PAM Provider.") diff --git a/cmd/pam_test.go b/cmd/pam_test.go index c07a44c7..c377376a 100644 --- a/cmd/pam_test.go +++ b/cmd/pam_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -55,22 +55,31 @@ func Test_PAMListCmd(t *testing.T) { pamProviders, err := testListPamProviders(t) assert.NoError(t, err) if err != nil { - t.Fatalf("failed to list PAM providers: %v", err) + //t.Fatalf("failed to list PAM providers: %v", err) + t.Errorf("failed to list PAM providers: %v", err) + return } if len(pamProviders) <= 0 { - t.Fatalf("0 PAM providers found, cannot test list") + t.Errorf("0 PAM providers found, cannot test list") } } func Test_PAMTypesListCmd(t *testing.T) { testCmd := RootCmd // test + var err error testCmd.SetArgs([]string{"pam", "types-list"}) output := captureOutput(func() { - err := testCmd.Execute() + err = testCmd.Execute() assert.NoError(t, err) }) + + if err != nil { + t.Errorf("failed to list PAM provider types: %v", err) + return + } + var pTypes []interface{} if err := json.Unmarshal([]byte(output), &pTypes); err != nil { t.Fatalf("Error unmarshalling JSON: %v", err) @@ -93,7 +102,11 @@ func Test_PAMTypesListCmd(t *testing.T) { //} // Check params is a list of maps - pTypeParams := providerConfig["ProviderTypeParams"].([]interface{}) + pTypeParams, ok := providerConfig["ProviderTypeParams"].([]interface{}) + if !ok { + t.Logf("ProviderTypeParams is not a list of maps for %s", providerConfig["Name"]) + return + } //assert.NotEmpty(t, pTypeParams) //assert.GreaterOrEqual(t, len(pTypeParams), 0) if len(pTypeParams) > 0 { @@ -160,7 +173,8 @@ func Test_PAMGetCmd(t *testing.T) { assert.NotEmpty(t, pamProvider.(map[string]interface{})["ProviderType"]) } } else { - t.Fatalf("0 PAM providers found, cannot test get") + t.Errorf("0 PAM providers found, cannot test get") + return } } @@ -198,21 +212,22 @@ func Test_PAMCreateCmd(t *testing.T) { t.Logf("inputFileName: %s", inputFileName) invalidInputFileName := path.Join(filepath.Dir(cwd), "artifacts/pam/pam-create-invalid.json") t.Logf("invalidInputFileName: %s", invalidInputFileName) - //cProviderTypeName := "Delinea-SecretServer" - // read input file into a map[string]interface{} updatedFileName, fErr := testFormatPamCreateConfig(t, inputFileName, "", false) + t.Logf("updatedFileName: %s", updatedFileName) assert.NoError(t, fErr) if fErr != nil { - t.Fatalf("failed to format PAM provider config file '%s': %v", inputFileName, fErr) + t.Errorf("failed to format PAM provider config file '%s': %v", inputFileName, fErr) return } - // Test invalid config file + // Test valid config file createResponse, err := testCreatePamProvider(t, updatedFileName, providerName, false) assert.NoError(t, err) + assert.NotNil(t, createResponse) if err != nil { - t.Fatalf("failed to create a PAM provider: %v", err) + t.Errorf("failed to create a PAM provider: %v", err) + return } createdObject := createResponse.(map[string]interface{}) @@ -285,6 +300,18 @@ func Test_PAMUpdateCmd(t *testing.T) { if err := json.Unmarshal([]byte(output), &updateResponse); err != nil { t.Fatalf("Error unmarshalling JSON: %v", err) } + assert.NotNil(t, updateResponse) + if updateResponse == nil { + t.Errorf("failed to update a PAM provider") + return + } + // check that updateResponse is a map[string]interface{} + + _, ok := updateResponse.(map[string]interface{}) + if !ok { + t.Errorf("updateResponse is not a map[string]interface{}") + return + } assert.NotEmpty(t, updateResponse.(map[string]interface{})["Id"]) assert.NotEmpty(t, updateResponse.(map[string]interface{})["Name"]) assert.Equal(t, updateResponse.(map[string]interface{})["Name"], providerName) @@ -368,6 +395,11 @@ func testListPamProviders(t *testing.T) ([]interface{}, error) { assert.NoError(t, err) }) + if err != nil { + t.Errorf("failed to list PAM providers: %v", err) + return + } + if err = json.Unmarshal([]byte(output), &pamProviders); err != nil { t.Fatalf("Error unmarshalling JSON: %v", err) } @@ -418,7 +450,11 @@ func testCreatePamProvider(t *testing.T, fileName string, providerName string, a t.Run(testName, func(t *testing.T) { testCmd := RootCmd - testCmd.SetArgs([]string{"pam", "create", "--from-file", fileName}) + args := []string{"pam", "create", "--from-file", fileName} + // log the args as a string + t.Logf("args: %s", args) + testCmd.SetArgs(args) + t.Logf("fileName: %s", fileName) output := captureOutput(func() { err = testCmd.Execute() if !allowFail { @@ -429,7 +465,7 @@ func testCreatePamProvider(t *testing.T, fileName string, providerName string, a if allowFail { t.Logf("Error unmarshalling JSON: %v", err) } else { - t.Fatalf("failed to create a PAM provider: %v", err) + t.Errorf("failed to create a PAM provider: %v", err) } return } @@ -485,7 +521,8 @@ func testListPamProviderTypes(t *testing.T, name string, allowFail bool, allowEm }) var pTypes []interface{} if err = json.Unmarshal([]byte(output), &pTypes); err != nil && !allowFail { - t.Fatalf("Error unmarshalling JSON: %v", err) + t.Errorf("Error unmarshalling JSON: %v", err) + return nil, err } // assert slice is len >= 0 @@ -509,7 +546,13 @@ func testListPamProviderTypes(t *testing.T, name string, allowFail bool, allowEm } // Check params is a list of maps - pTypeParams := providerConfig["ProviderTypeParams"].([]interface{}) + pTypeParams, ok := providerConfig["ProviderTypeParams"].([]interface{}) + if !ok { + // This will happen for KFC 11.0+ where this field is not returned + t.Logf("ProviderTypeParams is not a list of maps for %s", providerConfig["Name"]) + continue + } + //assert.NotEmpty(t, pTypeParams) //assert.GreaterOrEqual(t, len(pTypeParams), 0) if len(pTypeParams) > 0 { @@ -533,7 +576,7 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName assert.NoError(t, pErr) if pErr != nil { - t.Fatalf("failed to load PAM provider config file '%s': %v", inputFileName, pErr) + t.Errorf("failed to load PAM provider config file '%s': %v", inputFileName, pErr) return "", pErr } @@ -549,10 +592,16 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName // todo: for some reason calling this function mutates pConfig apiProviderType, pvtErr := testListPamProviderTypes(t, cProviderTypeName, false, false) + + if pvtErr != nil { + t.Errorf("failed to find PAM provider type '%s' unable to create PAM provider: %v", cProviderTypeName, pvtErr) + return "", pvtErr + } else if apiProviderType == nil { + t.Errorf("failed to find PAM provider type '%s' unable to create PAM provider: %v", cProviderTypeName, pvtErr) + return "", pvtErr + } + switch apiProviderType.(type) { - case nil: - t.Fatalf("failed to find PAM provider type '%s' unable to create PAM provider: %v", cProviderTypeName, pvtErr) - break case map[string]interface{}: aProviderType := apiProviderType.(map[string]interface{}) cProviderType["Id"] = aProviderType["Id"] @@ -560,11 +609,17 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName cProviderType["ProviderTypeParams"] = aProviderType["ProviderTypeParams"] // iterate over each param and set the ID value on cProviderTypeParamValues nameToIdMap := make(map[string]int) - for _, cParam := range cProviderType["ProviderTypeParams"].([]interface{}) { - paramId := cParam.(map[string]interface{})["Id"] - paramName := cParam.(map[string]interface{})["Name"] - nameToIdMap[paramName.(string)] = int(paramId.(float64)) + paramsFieldName := "ProviderTypeParams" + _, ok := cProviderType[paramsFieldName] + if ok && cProviderType[paramsFieldName] != nil { + t.Logf("PAM definition is v10 or earlier") + for _, cParam := range cProviderType[paramsFieldName].([]interface{}) { + paramId := cParam.(map[string]interface{})["Id"] + paramName := cParam.(map[string]interface{})["Name"] + nameToIdMap[paramName.(string)] = int(paramId.(float64)) + } } + for idx, pValue := range cProviderTypeParamValues { pValueMap := pValue.(map[string]interface{}) paramInfo := pValueMap["ProviderTypeParam"].(map[string]interface{}) @@ -572,16 +627,22 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName pValueMap["ProviderTypeParam"] = paramInfo cProviderTypeParamValues[idx] = pValueMap } - break default: - t.Fatalf("failed to find PAM provider type '%s' unable to create PAM provider: %v", cProviderTypeName, pvtErr) + oErr := pvtErr + if oErr == nil { + oErr = fmt.Errorf("failed to find PAM provider type '%s' unable to create PAM provider", cProviderTypeName) + } else { + oErr = fmt.Errorf("failed to find PAM provider type '%s' unable to create PAM provider: %v", cProviderTypeName, oErr) + } + t.Error(oErr) + return "", oErr } // reload the config file because it was mutated pConfig, pErr = loadJSONFile(inputFileName) assert.NoError(t, pErr) if pErr != nil { - t.Fatalf("failed to load PAM provider config file '%s': %v", inputFileName, pErr) + t.Errorf("failed to load PAM provider config file '%s': %v", inputFileName, pErr) return "", pErr } @@ -595,6 +656,7 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName if isUpdate { // list providers + t.Logf("listing PAM providers for update") providersList, err := testListPamProviders(t) assert.NoError(t, err) if err != nil { @@ -613,7 +675,9 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName } } } else { - t.Fatalf("0 PAM providers found, cannot test delete") + dErr := fmt.Errorf("0 PAM providers found, cannot test update") + t.Error(dErr) + return "", dErr } } @@ -622,7 +686,7 @@ func testFormatPamCreateConfig(t *testing.T, inputFileName string, providerName updatedFileName := strings.Replace(inputFileName, "-template.json", ".json", 1) wErr := writeJSONFile(updatedFileName, pConfig) if wErr != nil { - t.Fatalf("failed to write updated PAM provider config file '%s': %v", inputFileName, wErr) + t.Errorf("failed to write updated PAM provider config file '%s': %v", inputFileName, wErr) return "", wErr } return updatedFileName, nil diff --git a/cmd/root.go b/cmd/root.go index 68b0ea52..72d04dee 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package cmd import ( "fmt" - "github.com/Keyfactor/keyfactor-go-client-sdk/api/keyfactor" + kfc "github.com/Keyfactor/keyfactor-go-client-sdk/v11/api/command" "github.com/Keyfactor/keyfactor-go-client/v2/api" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -197,7 +197,7 @@ func initClient(flagConfigFile string, flagProfile string, flagAuthProviderType return c, nil } -func initGenClient(flagConfig string, flagProfile string, noPrompt bool, authConfig *api.AuthConfig, saveConfig bool) (*keyfactor.APIClient, error) { +func initGenClient(flagConfig string, flagProfile string, noPrompt bool, authConfig *api.AuthConfig, saveConfig bool) (*kfc.APIClient, error) { var commandConfig ConfigurationFile if providerType != "" { @@ -259,8 +259,12 @@ func initGenClient(flagConfig string, flagProfile string, noPrompt bool, authCon sdkClientConfig["password"] = commandConfig.Servers[flagProfile].Password sdkClientConfig["domain"] = commandConfig.Servers[flagProfile].Domain - configuration := keyfactor.NewConfiguration(sdkClientConfig) - c := keyfactor.NewAPIClient(configuration) + configuration, cfgErr := kfc.NewConfiguration(sdkClientConfig) + if cfgErr != nil { + log.Error().Err(cfgErr).Msg("unable to create Keyfactor Command client configuration") + return nil, cfgErr + } + c := kfc.NewAPIClient(configuration) return c, nil } diff --git a/cmd/root_test.go b/cmd/root_test.go index a7c2cf51..64a992ed 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/rot.go b/cmd/rot.go index 2d3c6254..15f97967 100644 --- a/cmd/rot.go +++ b/cmd/rot.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/rot_test.go b/cmd/rot_test.go index 8384d482..5c32ac08 100644 --- a/cmd/rot_test.go +++ b/cmd/rot_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/status.go b/cmd/status.go index 0bffd7ca..5e1a9b8d 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/storeTypes.go b/cmd/storeTypes.go index 70b9b500..3d8b56ba 100644 --- a/cmd/storeTypes.go +++ b/cmd/storeTypes.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/storeTypes_get.go b/cmd/storeTypes_get.go index 9608b1c5..74f8c859 100644 --- a/cmd/storeTypes_get.go +++ b/cmd/storeTypes_get.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/storeTypes_get_test.go b/cmd/storeTypes_get_test.go index 735a2be0..517aee97 100644 --- a/cmd/storeTypes_get_test.go +++ b/cmd/storeTypes_get_test.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Keyfactor Command Authors. +Copyright 2024 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. diff --git a/cmd/storeTypes_test.go b/cmd/storeTypes_test.go index cb46cb76..6cc3e201 100644 --- a/cmd/storeTypes_test.go +++ b/cmd/storeTypes_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -71,6 +71,12 @@ func Test_StoreTypesListCmd(t *testing.T) { // verify that the store type is an integer _, ok := storeType["StoreType"].(float64) + if !ok { + t.Log("StoreType is not a float64") + merr, ook := storeType["StoreType"].(int) + t.Log(merr) + t.Log(ook) + } assert.True(t, ok, "Expected store type to be an integer") // verify short name is a string _, ok = storeType["ShortName"].(string) diff --git a/cmd/stores.go b/cmd/stores.go index d106a173..327ad8ab 100644 --- a/cmd/stores.go +++ b/cmd/stores.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/storesBulkOperations.go b/cmd/storesBulkOperations.go index d61c5194..f30fa987 100644 --- a/cmd/storesBulkOperations.go +++ b/cmd/storesBulkOperations.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/stores_test.go b/cmd/stores_test.go index b9500c88..5848c740 100644 --- a/cmd/stores_test.go +++ b/cmd/stores_test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -154,7 +154,12 @@ func Test_Stores_ImportCmd(t *testing.T) { csvData, csvErr := csvToMap(f) assert.Nil(t, csvErr) assert.NotEmpty(t, csvData) + assert.Greater(t, len(csvData), 0) var modifiedCSVData []map[string]string + if len(csvData) == 0 { + t.Errorf("No data in file %s", f) + return + } for _, row := range csvData { // assert that each row has an ID assert.NotEmpty(t, row["Id"]) diff --git a/cmd/test.go b/cmd/test.go index 8d314147..941df876 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/cmd/version.go b/cmd/version.go index fa45f990..fe289184 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -1,4 +1,4 @@ -// Package cmd Copyright 2023 Keyfactor +// Copyright 2024 Keyfactor // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/docs/kfutil.md b/docs/kfutil.md index 17dc9ed9..ab848670 100644 --- a/docs/kfutil.md +++ b/docs/kfutil.md @@ -32,6 +32,7 @@ A CLI wrapper around the Keyfactor Platform API. * [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 login](kfutil_login.md) - User interactive login to Keyfactor. Stores the credentials in the config file '$HOME/.keyfactor/command_config.json'. * [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. * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. @@ -40,4 +41,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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_containers.md b/docs/kfutil_containers.md index 18ba1df9..428553a0 100644 --- a/docs/kfutil_containers.md +++ b/docs/kfutil_containers.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_containers_get.md b/docs/kfutil_containers_get.md index ee747164..4daf90a9 100644 --- a/docs/kfutil_containers_get.md +++ b/docs/kfutil_containers_get.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_containers_list.md b/docs/kfutil_containers_list.md index 49553aa7..e0b2c24b 100644 --- a/docs/kfutil_containers_list.md +++ b/docs/kfutil_containers_list.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_export.md b/docs/kfutil_export.md index 856a683b..0ce6878c 100644 --- a/docs/kfutil_export.md +++ b/docs/kfutil_export.md @@ -51,4 +51,4 @@ kfutil export [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_helm.md b/docs/kfutil_helm.md index 6f0c7c1d..3c2d68e8 100644 --- a/docs/kfutil_helm.md +++ b/docs/kfutil_helm.md @@ -42,4 +42,4 @@ kubectl helm uo | helm install -f - keyfactor-universal-orchestrator keyfactor/k * [kfutil](kfutil.md) - Keyfactor CLI utilities * [kfutil helm uo](kfutil_helm_uo.md) - Configure the Keyfactor Universal Orchestrator Helm Chart -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_helm_uo.md b/docs/kfutil_helm_uo.md index 37984b38..92c9c828 100644 --- a/docs/kfutil_helm_uo.md +++ b/docs/kfutil_helm_uo.md @@ -46,4 +46,4 @@ kfutil helm uo [-t ] [-o ] [-f ] [-e -e @,@ -o ./app/extension * [kfutil orchs](kfutil_orchs.md) - Keyfactor agents/orchestrators APIs and utilities. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_orchs_get.md b/docs/kfutil_orchs_get.md index df00c3dc..32065931 100644 --- a/docs/kfutil_orchs_get.md +++ b/docs/kfutil_orchs_get.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_orchs_list.md b/docs/kfutil_orchs_list.md index 82bc7bb8..24436cb4 100644 --- a/docs/kfutil_orchs_list.md +++ b/docs/kfutil_orchs_list.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_orchs_logs.md b/docs/kfutil_orchs_logs.md index 9f5d37ec..a2e1462b 100644 --- a/docs/kfutil_orchs_logs.md +++ b/docs/kfutil_orchs_logs.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_orchs_reset.md b/docs/kfutil_orchs_reset.md index adb3545f..612ba71c 100644 --- a/docs/kfutil_orchs_reset.md +++ b/docs/kfutil_orchs_reset.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam.md b/docs/kfutil_pam.md index c48fe7fd..14b54c98 100644 --- a/docs/kfutil_pam.md +++ b/docs/kfutil_pam.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_create.md b/docs/kfutil_pam_create.md index 0c385a48..ae797e62 100644 --- a/docs/kfutil_pam_create.md +++ b/docs/kfutil_pam_create.md @@ -40,4 +40,4 @@ kfutil pam create [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_delete.md b/docs/kfutil_pam_delete.md index d9336fe6..caa952ed 100644 --- a/docs/kfutil_pam_delete.md +++ b/docs/kfutil_pam_delete.md @@ -40,4 +40,4 @@ kfutil pam delete [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_get.md b/docs/kfutil_pam_get.md index f5c6f1ff..6f7d3feb 100644 --- a/docs/kfutil_pam_get.md +++ b/docs/kfutil_pam_get.md @@ -40,4 +40,4 @@ kfutil pam get [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_list.md b/docs/kfutil_pam_list.md index 4586851d..7b46c2f4 100644 --- a/docs/kfutil_pam_list.md +++ b/docs/kfutil_pam_list.md @@ -39,4 +39,4 @@ kfutil pam list [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_types-create.md b/docs/kfutil_pam_types-create.md index cbe1e168..8d1954d3 100644 --- a/docs/kfutil_pam_types-create.md +++ b/docs/kfutil_pam_types-create.md @@ -47,4 +47,4 @@ kfutil pam types-create [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_types-list.md b/docs/kfutil_pam_types-list.md index 16bc1caf..c0098223 100644 --- a/docs/kfutil_pam_types-list.md +++ b/docs/kfutil_pam_types-list.md @@ -39,4 +39,4 @@ kfutil pam types-list [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_pam_update.md b/docs/kfutil_pam_update.md index 71e2e327..afd320cd 100644 --- a/docs/kfutil_pam_update.md +++ b/docs/kfutil_pam_update.md @@ -40,4 +40,4 @@ kfutil pam update [flags] * [kfutil pam](kfutil_pam.md) - Keyfactor PAM Provider APIs. -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_status.md b/docs/kfutil_status.md index 6a343e99..82a659ac 100644 --- a/docs/kfutil_status.md +++ b/docs/kfutil_status.md @@ -39,4 +39,4 @@ kfutil status [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_store-types.md b/docs/kfutil_store-types.md index 573c6876..f5901a72 100644 --- a/docs/kfutil_store-types.md +++ b/docs/kfutil_store-types.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_store-types_create.md b/docs/kfutil_store-types_create.md index 27271162..b6c169c7 100644 --- a/docs/kfutil_store-types_create.md +++ b/docs/kfutil_store-types_create.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_store-types_delete.md b/docs/kfutil_store-types_delete.md index d22e7e99..30d7f4e8 100644 --- a/docs/kfutil_store-types_delete.md +++ b/docs/kfutil_store-types_delete.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_store-types_get.md b/docs/kfutil_store-types_get.md index 37158fe3..834a293b 100644 --- a/docs/kfutil_store-types_get.md +++ b/docs/kfutil_store-types_get.md @@ -7,7 +7,7 @@ Get a specific store type by either name or ID. Get a specific store type by either name or ID. ``` -kfutil store-types get [-i | -n ] [-g] [-b ] [-o] [flags] +kfutil store-types get [-i | -n ] [-b ] [-g | --output-to-integration-manifest] [flags] ``` ### Options @@ -44,4 +44,4 @@ kfutil store-types get [-i | -n ] [-g] [-b --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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_inventory.md b/docs/kfutil_stores_inventory.md index 7eba8517..ed3786a3 100644 --- a/docs/kfutil_stores_inventory.md +++ b/docs/kfutil_stores_inventory.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_inventory_add.md b/docs/kfutil_stores_inventory_add.md index 0bfe3003..a84111df 100644 --- a/docs/kfutil_stores_inventory_add.md +++ b/docs/kfutil_stores_inventory_add.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_inventory_remove.md b/docs/kfutil_stores_inventory_remove.md index 0bfffc3f..bf749ede 100644 --- a/docs/kfutil_stores_inventory_remove.md +++ b/docs/kfutil_stores_inventory_remove.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_inventory_show.md b/docs/kfutil_stores_inventory_show.md index 5888bfd1..f8089283 100644 --- a/docs/kfutil_stores_inventory_show.md +++ b/docs/kfutil_stores_inventory_show.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_list.md b/docs/kfutil_stores_list.md index e23c6d6f..d7b2745f 100644 --- a/docs/kfutil_stores_list.md +++ b/docs/kfutil_stores_list.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_rot.md b/docs/kfutil_stores_rot.md index d103ae8e..dd5c516d 100644 --- a/docs/kfutil_stores_rot.md +++ b/docs/kfutil_stores_rot.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_rot_audit.md b/docs/kfutil_stores_rot_audit.md index 278edb0f..2a41ecc6 100644 --- a/docs/kfutil_stores_rot_audit.md +++ b/docs/kfutil_stores_rot_audit.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_rot_generate-template.md b/docs/kfutil_stores_rot_generate-template.md index bc023773..82c86ca0 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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_stores_rot_reconcile.md b/docs/kfutil_stores_rot_reconcile.md index a5e17e1f..d44bf647 100644 --- a/docs/kfutil_stores_rot_reconcile.md +++ b/docs/kfutil_stores_rot_reconcile.md @@ -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 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/docs/kfutil_version.md b/docs/kfutil_version.md index d9da81ae..cc2bfae3 100644 --- a/docs/kfutil_version.md +++ b/docs/kfutil_version.md @@ -39,4 +39,4 @@ kfutil version [flags] * [kfutil](kfutil.md) - Keyfactor CLI utilities -###### Auto generated by spf13/cobra on 9-Nov-2023 +###### Auto generated by spf13/cobra on 21-Feb-2024 diff --git a/go.mod b/go.mod index de9760d2..336bd740 100644 --- a/go.mod +++ b/go.mod @@ -4,29 +4,32 @@ go 1.21 require ( github.com/AlecAivazis/survey/v2 v2.3.7 - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Jeffail/gabs v1.4.0 - github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2 - github.com/Keyfactor/keyfactor-go-client/v2 v2.1.4 + github.com/Keyfactor/keyfactor-go-client-sdk/v10 v10.0.0-rc4 + github.com/Keyfactor/keyfactor-go-client-sdk/v11 v11.0.0-rc4 + + github.com/Keyfactor/keyfactor-go-client/v2 v2.2.7 github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 github.com/creack/pty v1.1.21 github.com/google/go-cmp v0.6.0 - github.com/google/uuid v1.4.0 + github.com/google/uuid v1.6.0 github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 github.com/joho/godotenv v1.5.1 github.com/rs/zerolog v1.31.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.14.0 + golang.org/x/crypto v0.19.0 gopkg.in/yaml.v3 v3.0.1 //github.com/google/go-cmp/cmp v0.5.9 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.0.0 // indirect @@ -41,8 +44,8 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spbsoluble/go-pkcs12 v0.3.3 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/term v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index cd50a0ab..97cebf67 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo= @@ -14,8 +14,12 @@ github.com/Keyfactor/keyfactor-go-client v1.4.3 h1:CmGvWcuIbDRFM0PfYOQH6UdtAgplv github.com/Keyfactor/keyfactor-go-client v1.4.3/go.mod h1:3ZymLNCaSazglcuYeNfm9nrzn22wcwLjIWURrnUygBo= github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2 h1:caLlzFCz2L4Dth/9wh+VlypFATmOMmCSQkCPKOKMxw8= github.com/Keyfactor/keyfactor-go-client-sdk v1.0.2/go.mod h1:Z5pSk8YFGXHbKeQ1wTzVN8A4P/fZmtAwqu3NgBHbDOs= -github.com/Keyfactor/keyfactor-go-client/v2 v2.1.4 h1:PClA1rsT6YA3jsIcTeBROlaEBOqeYeFcXT3mx7FoWcQ= -github.com/Keyfactor/keyfactor-go-client/v2 v2.1.4/go.mod h1:3mfxdcwntB532QIATokBEkBCH0eXN2G/cdMZtu9NwNg= +github.com/Keyfactor/keyfactor-go-client-sdk/v10 v10.0.0-rc4 h1:yNn6CAPNgZB/VSfUQZmjiigcnZPxAxBW56Pr7npDf6Y= +github.com/Keyfactor/keyfactor-go-client-sdk/v10 v10.0.0-rc4/go.mod h1:++EY4+EqmwqsSdPEvFJgH7jzax8SOsS9w9AVBQg3vUw= +github.com/Keyfactor/keyfactor-go-client-sdk/v11 v11.0.0-rc4 h1:b87jZ8aqNvMcYXWa+gBSXKh+1tAqPgA6qysjVRgRd0s= +github.com/Keyfactor/keyfactor-go-client-sdk/v11 v11.0.0-rc4/go.mod h1:OJCXbBcEoXUBVh/EusfAaIldM4ljTe9AIVQv00C+9+s= +github.com/Keyfactor/keyfactor-go-client/v2 v2.2.7 h1:fHZF5lDEWKQEI8QOPeseG/y9Bd4h2DhOiUWkNx+rKJU= +github.com/Keyfactor/keyfactor-go-client/v2 v2.2.7/go.mod h1:3mfxdcwntB532QIATokBEkBCH0eXN2G/cdMZtu9NwNg= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -34,8 +38,8 @@ github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJ github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02 h1:AgcIVYPa6XJnU3phs104wLj8l5GEththEw6+F79YsIY= github.com/hinshun/vt10x v0.0.0-20220301184237-5011da428d02/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= @@ -81,14 +85,14 @@ go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 h1:CCriYyAfq1Br1aIYettdH go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -101,18 +105,18 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/pkg/version/version.go b/pkg/version/version.go index 9b544a14..3db32344 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -14,4 +14,4 @@ package version -const VERSION = "1.3.1" +const VERSION = "1.4.0-rc.7" \ No newline at end of file diff --git a/store_types.json b/store_types.json index 44345f4d..8b7cb27c 100644 --- a/store_types.json +++ b/store_types.json @@ -908,30 +908,6 @@ "DependsOn": "", "DefaultValue": "cert", "Required": true - }, - { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": false - }, - { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", - "Type": "Bool", - "DependsOn": "", - "DefaultValue": "true", - "Required": true } ], "EntryParameters": null, @@ -963,28 +939,18 @@ }, "Properties": [ { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, + "Name": "SeparateChain", + "DisplayName": "Separate Certificate Chain", + "Type": "Bool", + "DefaultValue": "false", "Required": false }, { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", + "Name": "IncludeCertChain", + "DisplayName": "Include Certificate Chain", "Type": "Bool", - "DependsOn": "", "DefaultValue": "true", - "Required": true + "Required": false } ], "EntryParameters": null, @@ -1044,8 +1010,8 @@ "DisplayName": "CertificateDataFieldName", "Type": "String", "DependsOn": "", - "DefaultValue": null, - "Required": false + "DefaultValue": ".jks", + "Required": true }, { "Name": "PasswordFieldName", @@ -1133,28 +1099,18 @@ "Required": false }, { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, + "Name": "SeparateChain", + "DisplayName": "Separate Certificate Chain", + "Type": "Bool", + "DefaultValue": "false", "Required": false }, { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", + "Name": "IncludeCertChain", + "DisplayName": "Include Certificate Chain", "Type": "Bool", - "DependsOn": "", "DefaultValue": "true", - "Required": true + "Required": false } ], "EntryParameters": null, @@ -1185,6 +1141,14 @@ "Remove": true }, "Properties": [ + { + "Name": "KubeSecretType", + "DisplayName": "Kube Secret Type", + "Type": "String", + "DependsOn": "", + "DefaultValue": "pkcs12", + "Required": true + }, { "Name": "KubeSecretKey", "DisplayName": "Kube Secret Key", @@ -1193,6 +1157,14 @@ "DefaultValue": "pfx", "Required": false }, + { + "Name": "CertificateDataFieldName", + "DisplayName": "CertificateDataFieldName", + "Type": "String", + "DependsOn": "", + "DefaultValue": ".p12", + "Required": true + }, { "Name": "PasswordFieldName", "DisplayName": "Password Field Name", @@ -1225,38 +1197,6 @@ "DefaultValue": null, "Required": false }, - { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": false - }, - { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", - "Type": "Bool", - "DependsOn": "", - "DefaultValue": "true", - "Required": true - }, - { - "Name": "KubeSecretType", - "DisplayName": "Kube Secret Type", - "Type": "String", - "DependsOn": "", - "DefaultValue": "pkcs12", - "Required": true - }, { "Name": "StorePasswordPath", "DisplayName": "StorePasswordPath", @@ -1319,28 +1259,18 @@ "Required": true }, { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, + "Name": "SeparateChain", + "DisplayName": "Separate Certificate Chain", + "Type": "Bool", + "DefaultValue": "false", "Required": false }, { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", + "Name": "IncludeCertChain", + "DisplayName": "Include Certificate Chain", "Type": "Bool", - "DependsOn": "", "DefaultValue": "true", - "Required": true + "Required": false } ], "EntryParameters": null, @@ -1396,28 +1326,18 @@ "Required": true }, { - "Name": "ServerUsername", - "DisplayName": "Server Username", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, + "Name": "SeparateChain", + "DisplayName": "Separate Certificate Chain", + "Type": "Bool", + "DefaultValue": "false", "Required": false }, { - "Name": "ServerPassword", - "DisplayName": "Server Password", - "Type": "Secret", - "DependsOn": "", - "DefaultValue": null, - "Required": true - }, - { - "Name": "ServerUseSsl", - "DisplayName": "Use SSL", + "Name": "IncludeCertChain", + "DisplayName": "Include Certificate Chain", "Type": "Bool", - "DependsOn": "", "DefaultValue": "true", - "Required": true + "Required": false } ], "EntryParameters": null,