Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
7a470252
Unverified
Commit
7a470252
authored
May 07, 2019
by
Patrick Decat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use github.com/gofrs/flock for cross platform file locking
Signed-off-by:
Patrick Decat
<
pdecat@gmail.com
>
parent
e07dfcbc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
repo_add.go
cmd/helm/repo_add.go
+12
-16
glide.lock
glide.lock
+2
-0
glide.yaml
glide.yaml
+2
-0
No files found.
cmd/helm/repo_add.go
View file @
7a470252
...
@@ -17,14 +17,17 @@ limitations under the License.
...
@@ -17,14 +17,17 @@ limitations under the License.
package
main
package
main
import
(
import
(
"context"
"fmt"
"fmt"
"io"
"io"
"github.com/spf13/cobra"
"syscall"
"syscall"
"time"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/crypto/ssh/terminal"
"github.com/gofrs/flock"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/getter"
"k8s.io/helm/pkg/getter"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/repo"
...
@@ -133,20 +136,13 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer
...
@@ -133,20 +136,13 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer
}
}
// Lock the repository file for concurrent processes synchronization and re-read its content before updating it
// Lock the repository file for concurrent processes synchronization and re-read its content before updating it
fd
,
err
:=
syscall
.
Open
(
home
.
RepositoryFile
(),
syscall
.
O_CREAT
|
syscall
.
O_RDWR
|
syscall
.
O_CLOEXEC
,
0
)
fileLock
:=
flock
.
New
(
home
.
RepositoryFile
())
if
err
!=
nil
{
lockCtx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Minute
)
return
err
defer
cancel
()
locked
,
err
:=
fileLock
.
TryLockContext
(
lockCtx
,
time
.
Second
)
if
err
==
nil
&&
locked
{
defer
fileLock
.
Unlock
()
}
}
defer
syscall
.
Close
(
fd
)
flock
:=
syscall
.
Flock_t
{
Type
:
syscall
.
F_WRLCK
,
Start
:
0
,
Len
:
0
,
Whence
:
io
.
SeekStart
,
}
syscall
.
FcntlFlock
(
uintptr
(
fd
),
syscall
.
F_SETLK
,
&
flock
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
glide.lock
View file @
7a470252
...
@@ -114,6 +114,8 @@ imports:
...
@@ -114,6 +114,8 @@ imports:
- syntax/lexer
- syntax/lexer
- util/runes
- util/runes
- util/strings
- util/strings
- name: github.com/gofrs/flock
version: 392e7fae8f1b0bdbd67dad7237d23f618feb6dbb
- name: github.com/gogo/protobuf
- name: github.com/gogo/protobuf
version: 342cbe0a04158f6dcb03ca0079991a51a4248c02
version: 342cbe0a04158f6dcb03ca0079991a51a4248c02
subpackages:
subpackages:
...
...
glide.yaml
View file @
7a470252
...
@@ -67,6 +67,8 @@ import:
...
@@ -67,6 +67,8 @@ import:
-
package
:
github.com/jmoiron/sqlx
-
package
:
github.com/jmoiron/sqlx
version
:
^1.2.0
version
:
^1.2.0
-
package
:
github.com/rubenv/sql-migrate
-
package
:
github.com/rubenv/sql-migrate
-
package
:
github.com/gofrs/flock
version
:
v0.7.1
testImports
:
testImports
:
-
package
:
github.com/stretchr/testify
-
package
:
github.com/stretchr/testify
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment