Skip to content

Commit

Permalink
pin kustomize to v5.0.3; incorporate git/gogit API changes
Browse files Browse the repository at this point in the history
Signed-off-by: Sanskar Jaiswal <[email protected]>
  • Loading branch information
aryan9600 committed May 29, 2023
1 parent 2e9cea8 commit d7291a7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module github.com/fluxcd/terraform-provider-flux

go 1.18

// Pin kustomize to v4.5.7
// Pin kustomize to v5.0.3
replace (
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.12.1
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.9
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.13.4
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.14.2
)

// Fix CVE-2022-28948
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.17.0 h1:CScmGz/wX66puA06Gj8OZb76Wmk7JIjgWf5JDvY7msM=
sigs.k8s.io/kind v0.17.0/go.mod h1:Qqp8AiwOlMZmJWs37Hgs31xcbiYXjtXlRBSftcnZXQk=
sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM=
sigs.k8s.io/kustomize/api v0.12.1/go.mod h1:y3JUhimkZkR6sbLNwfJHxvo1TCLwuwm14sCYnkH6S1s=
sigs.k8s.io/kustomize/kyaml v0.13.9 h1:Qz53EAaFFANyNgyOEJbT/yoIHygK40/ZcvU3rgry2Tk=
sigs.k8s.io/kustomize/kyaml v0.13.9/go.mod h1:QsRbD0/KcU+wdk0/L0fIp2KLnohkVzs6fQ85/nOXac4=
sigs.k8s.io/kustomize/api v0.13.4 h1:E38Hfx0G9R9v7vRgKshviPotJQETG0S2gD3JdHLCAsI=
sigs.k8s.io/kustomize/api v0.13.4/go.mod h1:Bkaavz5RKK6ZzP0zgPrB7QbpbBJKiHuD3BB0KujY7Ls=
sigs.k8s.io/kustomize/kyaml v0.14.2 h1:9WSwztbzwGszG1bZTziQUmVMrJccnyrLb5ZMKpJGvXw=
sigs.k8s.io/kustomize/kyaml v0.14.2/go.mod h1:AN1/IpawKilWD7V+YvQwRGUvuUOOWpjsHu6uHwonSF4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
Expand Down
6 changes: 5 additions & 1 deletion internal/provider/provider_resource_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ func (prd *providerResourceData) GetGitClient(ctx context.Context) (*gogit.Clien
return nil, fmt.Errorf("could not create git client: %w", err)
}
// TODO: Need to conditionally clone here. If repository is empty this will fail.
_, err = client.Clone(ctx, prd.GetRepositoryURL().String(), repository.CloneOptions{CheckoutStrategy: repository.CheckoutStrategy{Branch: prd.git.Branch.ValueString()}})
_, err = client.Clone(ctx, prd.GetRepositoryURL().String(), repository.CloneConfig{
CheckoutStrategy: repository.CheckoutStrategy{
Branch: prd.git.Branch.ValueString(),
},
})
if err != nil {
return nil, fmt.Errorf("could not clone git repository: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/resource_bootstrap_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func (r bootstrapGitResource) Update(ctx context.Context, req resource.UpdateReq
if err != nil {
return nil
}
err = gitClient.Push(ctx)
err = gitClient.Push(ctx, repository.PushConfig{})
if err != nil {
return retry.RetryableError(fmt.Errorf("Unable to push file update: %w", err))
}
Expand Down Expand Up @@ -651,7 +651,7 @@ func (r bootstrapGitResource) Delete(ctx context.Context, req resource.DeleteReq
if err != nil {
return retry.NonRetryableError(fmt.Errorf("Unable to commit removed file(s): %w", err))
}
err = gitClient.Push(ctx)
err = gitClient.Push(ctx, repository.PushConfig{})
if err != nil {
return retry.RetryableError(fmt.Errorf("Unable to psuh removed file(s): %w", err))
}
Expand Down
8 changes: 6 additions & 2 deletions internal/provider/resource_bootstrap_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,16 @@ func TestAccBootstrapGit_Drift(t *testing.T) {
{
PreConfig: func() {
gitClient := getTestGitClient(t, env.username, env.password)
_, err := gitClient.Clone(context.TODO(), env.httpClone, repository.CloneOptions{CheckoutStrategy: repository.CheckoutStrategy{Branch: defaultBranch}})
_, err := gitClient.Clone(context.TODO(), env.httpClone, repository.CloneConfig{
CheckoutStrategy: repository.CheckoutStrategy{
Branch: defaultBranch,
},
})
require.NoError(t, err)
os.Remove(filepath.Join(gitClient.Path(), "flux-system/kustomization.yaml"))
_, err = gitClient.Commit(git.Commit{})
require.NoError(t, err)
err = gitClient.Push(context.TODO())
err = gitClient.Push(context.TODO(), repository.PushConfig{})
require.NoError(t, err)
},
Config: bootstrapGitHTTP(env),
Expand Down

0 comments on commit d7291a7

Please sign in to comment.