Skip to content

Commit

Permalink
replaced JoinPath with path.Join
Browse files Browse the repository at this point in the history
Signed-off-by: Noam Gal <[email protected]>
  • Loading branch information
ATGardner committed Jan 26, 2023
1 parent 1fa5758 commit 4133b88
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
9 changes: 3 additions & 6 deletions cmd/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"encoding/json"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
"path"
"strings"
"text/tabwriter"

Expand Down Expand Up @@ -285,8 +284,6 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
return
}

kustConfigPath, _ := url.JoinPath(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config.json")
dirConfigPath, _ := url.JoinPath(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config_dir.json")
appSetYAML, err = createAppSet(&createAppSetOptions{
name: o.Name,
namespace: o.Namespace,
Expand All @@ -309,7 +306,7 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
Revision: o.Revision,
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: kustConfigPath,
Path: path.Join(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config.json"),
},
},
RequeueAfterSeconds: &DefaultApplicationSetGeneratorInterval,
Expand All @@ -321,7 +318,7 @@ func generateProjectManifests(o *GenerateProjectOptions) (projectYAML, appSetYAM
Revision: o.Revision,
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: dirConfigPath,
Path: path.Join(o.InstallationPath, store.Default.AppsDir, "**", o.Name, "config_dir.json"),
},
},
RequeueAfterSeconds: &DefaultApplicationSetGeneratorInterval,
Expand Down
16 changes: 6 additions & 10 deletions cmd/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net/url"
"os"
"path"
"strings"
"time"

Expand Down Expand Up @@ -546,48 +547,43 @@ func buildBootstrapManifests(namespace, appSpecifier string, cloneOpts *git.Clon
var err error
manifests := &bootstrapManifests{}

srcPath, _ := url.JoinPath(cloneOpts.Path(), store.Default.BootsrtrapDir)
manifests.bootstrapApp, err = createApp(&createAppOptions{
name: store.Default.BootsrtrapAppName,
namespace: namespace,
repoURL: cloneOpts.URL(),
revision: cloneOpts.Revision(),
srcPath: srcPath,
srcPath: path.Join(cloneOpts.Path(), store.Default.BootsrtrapDir),
labels: bootstrapAppsLabels,
})
if err != nil {
return nil, err
}

srcPath, _ = url.JoinPath(cloneOpts.Path(), store.Default.ProjectsDir)
manifests.rootApp, err = createApp(&createAppOptions{
name: store.Default.RootAppName,
namespace: namespace,
repoURL: cloneOpts.URL(),
revision: cloneOpts.Revision(),
srcPath: srcPath,
srcPath: path.Join(cloneOpts.Path(), store.Default.ProjectsDir),
labels: bootstrapAppsLabels,
})
if err != nil {
return nil, err
}

srcPath, _ = url.JoinPath(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ArgoCDName)
manifests.argocdApp, err = createApp(&createAppOptions{
name: store.Default.ArgoCDName,
namespace: namespace,
repoURL: cloneOpts.URL(),
revision: cloneOpts.Revision(),
srcPath: srcPath,
srcPath: path.Join(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ArgoCDName),
noFinalizer: true,
labels: argocdLabels,
})
if err != nil {
return nil, err
}

srcPath, _ = url.JoinPath(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ClusterResourcesDir, "{{name}}")
path, _ := url.JoinPath(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ClusterResourcesDir, "*.json")
manifests.clusterResAppSet, err = createAppSet(&createAppSetOptions{
name: store.Default.ClusterResourcesDir,
namespace: namespace,
Expand All @@ -599,15 +595,15 @@ func buildBootstrapManifests(namespace, appSpecifier string, cloneOpts *git.Clon
destServer: "{{server}}",
prune: false,
preserveResourcesOnDeletion: true,
srcPath: srcPath,
srcPath: path.Join(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ClusterResourcesDir, "{{name}}"),
generators: []argocdv1alpha1.ApplicationSetGenerator{
{
Git: &argocdv1alpha1.GitGenerator{
RepoURL: cloneOpts.URL(),
Revision: cloneOpts.Revision(),
Files: []argocdv1alpha1.GitFileGeneratorItem{
{
Path: path,
Path: path.Join(cloneOpts.Path(), store.Default.BootsrtrapDir, store.Default.ClusterResourcesDir, "*.json"),
},
},
RequeueAfterSeconds: &DefaultApplicationSetGeneratorInterval,
Expand Down
5 changes: 2 additions & 3 deletions pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package application
import (
"errors"
"fmt"
"net/url"
"os"
"path"
"path/filepath"
"reflect"

Expand Down Expand Up @@ -289,14 +289,13 @@ func newKustApp(o *CreateOptions, projectName, repoURL, targetRevision, repoRoot
app.namespace = kube.GenerateNamespace(o.DestNamespace, nil)
}

srcPath, _ := url.JoinPath(repoRoot, store.Default.AppsDir, o.AppName, store.Default.OverlaysDir, projectName)
app.config = &Config{
AppName: o.AppName,
UserGivenName: o.AppName,
DestNamespace: o.DestNamespace,
DestServer: o.DestServer,
SrcRepoURL: repoURL,
SrcPath: srcPath,
SrcPath: path.Join(repoRoot, store.Default.AppsDir, o.AppName, store.Default.OverlaysDir, projectName),
SrcTargetRevision: targetRevision,
Labels: o.Labels,
Annotations: o.Annotations,
Expand Down

0 comments on commit 4133b88

Please sign in to comment.