Skip to content

Commit

Permalink
Update source-watcher.md with minor changes
Browse files Browse the repository at this point in the history
- Remove deprecated io/outil function calls
- Update documented Reconcile function with minor changes

Signed-off-by: Sven Nebel <nebel.sven@gmail.com>
  • Loading branch information
snebel29 committed Sep 5, 2022
1 parent d390792 commit ec6cbe6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions content/en/flux/gitops-toolkit/source-watcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ type GitRepositoryWatcher struct {

// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=gitrepositories,verbs=get;list;watch
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=gitrepositories/status,verbs=get

func (r *GitRepositoryWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := logr.FromContext(ctx)
log := ctrl.LoggerFrom(ctx)

// get source object
var repository sourcev1.GitRepository
Expand All @@ -150,7 +151,7 @@ func (r *GitRepositoryWatcher) Reconcile(ctx context.Context, req ctrl.Request)
log.Info("New revision detected", "revision", repository.Status.Artifact.Revision)

// create tmp dir
tmpDir, err := ioutil.TempDir("", repository.Name)
tmpDir, err := os.MkdirTemp("", repository.Name)
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to create temp dir, error: %w", err)
}
Expand All @@ -165,7 +166,7 @@ func (r *GitRepositoryWatcher) Reconcile(ctx context.Context, req ctrl.Request)
log.Info(summary)

// list artifact content
files, err := ioutil.ReadDir(tmpDir)
files, err := os.ReadDir(tmpDir)
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to list files, error: %w", err)
}
Expand Down

0 comments on commit ec6cbe6

Please sign in to comment.