Skip to content

Commit 78f5722

Browse files
authored
Merge pull request #3512 from dougm/library-sync-force
govc: add library.sync '-f' flag to force sync file content
2 parents a06833d + db6e962 commit 78f5722

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

govc/USAGE.md

+1
Original file line numberDiff line numberDiff line change
@@ -3880,6 +3880,7 @@ Examples:
38803880
govc library.sync -vmtx local-library subscribed-library # convert subscribed OVFs to local VMTX
38813881
38823882
Options:
3883+
-f=false Forcefully synchronize file content
38833884
-folder= Inventory folder [GOVC_FOLDER]
38843885
-pool= Resource pool [GOVC_RESOURCE_POOL]
38853886
-vmtx= Sync subscribed library to local library as VM Templates

govc/library/sync.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2019 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2019-2024 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -31,7 +31,8 @@ type sync struct {
3131
*flags.FolderFlag
3232
*flags.ResourcePoolFlag
3333

34-
vmtx string
34+
force bool
35+
vmtx string
3536
}
3637

3738
func init() {
@@ -45,6 +46,7 @@ func (cmd *sync) Register(ctx context.Context, f *flag.FlagSet) {
4546
cmd.ResourcePoolFlag, ctx = flags.NewResourcePoolFlag(ctx)
4647
cmd.ResourcePoolFlag.Register(ctx, f)
4748

49+
f.BoolVar(&cmd.force, "f", false, "Forcefully synchronize file content")
4850
f.StringVar(&cmd.vmtx, "vmtx", "", "Sync subscribed library to local library as VM Templates")
4951
}
5052

@@ -153,7 +155,7 @@ func (cmd *sync) Run(ctx context.Context, f *flag.FlagSet) error {
153155
case library.Item:
154156
lib := res.GetParent().GetResult().(library.Library)
155157
if cmd.shouldSync(lib) {
156-
if err = m.SyncLibraryItem(ctx, &t, false); err != nil {
158+
if err = m.SyncLibraryItem(ctx, &t, cmd.force); err != nil {
157159
return err
158160
}
159161
}

0 commit comments

Comments
 (0)