Skip to content

Commit

Permalink
govc: Rewrite kms.export URL to use the host we connected to vCenter …
Browse files Browse the repository at this point in the history
…with

Signed-off-by: Doug MacEachern <[email protected]>
  • Loading branch information
dougm committed Feb 11, 2025
1 parent 93efaa5 commit 8df8254
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions cli/kms/export.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
/*
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: Apache-2.0

package kms

import (
"context"
"flag"
"fmt"
"net/url"

"github.com/vmware/govmomi/cli"
"github.com/vmware/govmomi/cli/flags"
Expand Down Expand Up @@ -80,6 +69,15 @@ func (cmd *export) Run(ctx context.Context, f *flag.FlagSet) error {
return fmt.Errorf("unsupported export type: %s", export.Type)
}

// Rewrite URL to use the host we connected to vCenter with
u, err := url.Parse(export.Location.URL)
if err != nil {
return err
}

u.Host = rc.URL().Host
export.Location.URL = u.String()

req, err := m.KmsProviderExportRequest(ctx, export.Location)
if err != nil {
return err
Expand Down

0 comments on commit 8df8254

Please sign in to comment.