Skip to content

Commit 35b5564

Browse files
committed
govc: Rewrite kms.export URL to use the host we connected to vCenter with
Signed-off-by: Doug MacEachern <[email protected]>
1 parent 7542587 commit 35b5564

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

cli/kms/export.go

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
/*
2-
Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// © Broadcom. All Rights Reserved.
2+
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
3+
// SPDX-License-Identifier: Apache-2.0
164

175
package kms
186

197
import (
208
"context"
219
"flag"
2210
"fmt"
11+
"net/url"
2312

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

72+
// Rewrite URL to use the host we connected to vCenter with
73+
u, err := url.Parse(export.Location.URL)
74+
if err != nil {
75+
return err
76+
}
77+
78+
u.Host = rc.URL().Host
79+
export.Location.URL = u.String()
80+
8381
req, err := m.KmsProviderExportRequest(ctx, export.Location)
8482
if err != nil {
8583
return err

0 commit comments

Comments
 (0)