Skip to content

Commit

Permalink
Merge branch 'master' into chore/add-textnow
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-momot authored Oct 31, 2024
2 parents f36c930 + 83b1b6c commit abf2f8a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 29 deletions.
38 changes: 24 additions & 14 deletions cmd/argocd/commands/app_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"text/tabwriter"

"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/utils"
"github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"

Expand Down Expand Up @@ -130,23 +131,32 @@ func NewApplicationDeleteResourceCommand(clientOpts *argocdclient.ClientOptions)
errors.CheckError(err)
objectsToDelete, err := util.FilterResources(command.Flags().Changed("group"), resources.Items, group, kind, namespace, resourceName, all)
errors.CheckError(err)

promptUtil := utils.NewPrompt(clientOpts.PromptsEnabled)

for i := range objectsToDelete {
obj := objectsToDelete[i]
gvk := obj.GroupVersionKind()
_, err = appIf.DeleteResource(ctx, &applicationpkg.ApplicationResourceDeleteRequest{
Name: &appName,
AppNamespace: &appNs,
Namespace: ptr.To(obj.GetNamespace()),
ResourceName: ptr.To(obj.GetName()),
Version: ptr.To(gvk.Version),
Group: ptr.To(gvk.Group),
Kind: ptr.To(gvk.Kind),
Force: &force,
Orphan: &orphan,
Project: ptr.To(project),
})
errors.CheckError(err)
log.Infof("Resource '%s' deleted", obj.GetName())

canDelete := promptUtil.Confirm(fmt.Sprintf("Are you sure you want to delete %s/%s %s/%s ? [y/n]", gvk.Group, gvk.Kind, obj.GetNamespace(), obj.GetName()))
if canDelete {
_, err = appIf.DeleteResource(ctx, &applicationpkg.ApplicationResourceDeleteRequest{
Name: &appName,
AppNamespace: &appNs,
Namespace: ptr.To(obj.GetNamespace()),
ResourceName: ptr.To(obj.GetName()),
Version: ptr.To(gvk.Version),
Group: ptr.To(gvk.Group),
Kind: ptr.To(gvk.Kind),
Force: &force,
Orphan: &orphan,
Project: ptr.To(project),
})
errors.CheckError(err)
log.Infof("Resource '%s' deleted", obj.GetName())
} else {
fmt.Printf("The command to delete %s/%s %s/%s was cancelled.\n", gvk.Group, gvk.Kind, obj.GetNamespace(), obj.GetName())
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions cmd/argocd/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"sigs.k8s.io/yaml"

"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/headless"
"github.com/argoproj/argo-cd/v2/cmd/argocd/commands/utils"
cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
projectpkg "github.com/argoproj/argo-cd/v2/pkg/apiclient/project"
Expand Down Expand Up @@ -781,11 +782,19 @@ func NewProjectDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comm
c.HelpFunc()(c, args)
os.Exit(1)
}

promptUtil := utils.NewPrompt(clientOpts.PromptsEnabled)

conn, projIf := headless.NewClientOrDie(clientOpts, c).NewProjectClientOrDie()
defer argoio.Close(conn)
for _, name := range args {
_, err := projIf.Delete(ctx, &projectpkg.ProjectQuery{Name: name})
errors.CheckError(err)
canDelete := promptUtil.Confirm(fmt.Sprintf("Are you sure you want to delete %s? [y/n]", name))
if canDelete {
_, err := projIf.Delete(ctx, &projectpkg.ProjectQuery{Name: name})
errors.CheckError(err)
} else {
fmt.Printf("The command to delete %s was cancelled.\n", name)
}
}
},
}
Expand Down
4 changes: 4 additions & 0 deletions controller/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ func specEqualsCompareTo(spec v1alpha1.ApplicationSpec, comparedTo v1alpha1.Comp
currentSpec.Destination.Name = ""
}

// Set IsServerInferred to false on both, because that field is not important for comparison.
comparedTo.Destination.SetIsServerInferred(false)
currentSpec.Destination.SetIsServerInferred(false)

return reflect.DeepEqual(comparedTo, currentSpec)
}

Expand Down
4 changes: 4 additions & 0 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,10 @@ func TestUseDiffCache(t *testing.T) {
t.Fatalf("error merging app: %s", err)
}
}
if app.Spec.Destination.Name != "" && app.Spec.Destination.Server != "" {
// Simulate the controller's process for populating both of these fields.
app.Spec.Destination.SetInferredServer(app.Spec.Destination.Server)
}
return app
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,12 @@ type ApplicationDestination struct {
isServerInferred bool `json:"-"`
}

// SetIsServerInferred sets the isServerInferred flag. This is used to allow comparison between two destinations where
// one server is inferred and the other is not.
func (d *ApplicationDestination) SetIsServerInferred(inferred bool) {
d.isServerInferred = inferred
}

type ResourceHealthLocation string

var (
Expand Down
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ func (a *ArgoCDServer) Run(ctx context.Context, listeners *Listeners) {

// If not matched, we assume that its TLS.
tlsl := tcpm.Match(cmux.Any())
tlsConfig := tls.Config{}
tlsConfig := tls.Config{
NextProtos: []string{"h2"},
}
tlsConfig.GetCertificate = func(info *tls.ClientHelloInfo) (*tls.Certificate, error) {
return a.settings.Certificate, nil
}
Expand Down
4 changes: 2 additions & 2 deletions ui-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"author": "Keith Chong",
"license": "Apache-2.0",
"dependencies": {
"@types/selenium-webdriver": "^4.1.26",
"@types/selenium-webdriver": "^4.1.27",
"assert": "^2.1.0",
"chromedriver": "^130.0.1",
"selenium-webdriver": "^4.25.0"
},
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "^22.7.9",
"@types/node": "^22.8.4",
"dotenv": "^16.4.5",
"mocha": "^10.7.3",
"prettier": "^2.8.8",
Expand Down
20 changes: 10 additions & 10 deletions ui-test/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.9.tgz#101e9da88d2c02e5ac8952982c23b224524d662a"
integrity sha512-sicdRoWtYevwxjOHNMPTl3vSfJM6oyW8o1wXeI7uww6b6xHg8eBznQDNSGBCDJmsE8UMxP05JgZRtsKbTqt//Q==

"@types/node@*", "@types/node@^22.7.9":
version "22.7.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.9.tgz#2bf2797b5e84702d8262ea2cf843c3c3c880d0e9"
integrity sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==
"@types/node@*", "@types/node@^22.8.4":
version "22.8.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.4.tgz#ab754f7ac52e1fe74174f761c5b03acaf06da0dc"
integrity sha512-SpNNxkftTJOPk0oN+y2bIqurEXHTA2AOZ3EJDDKeJ5VzkvvORSvmQXGQarcOzWV1ac7DCaPBEdMDxBsM+d8jWw==
dependencies:
undici-types "~6.19.2"
undici-types "~6.19.8"

"@types/selenium-webdriver@^4.1.26":
version "4.1.26"
resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-4.1.26.tgz#09c696a341cf8cfc1641cded11d14813350b6ca9"
integrity sha512-PUgqsyNffal0eAU0bzGlh37MJo558aporAPZoKqBeB/pF7zhKl1S3zqza0GpwFqgoigNxWhEIJzru75eeYco/w==
"@types/selenium-webdriver@^4.1.27":
version "4.1.27"
resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-4.1.27.tgz#e08000d649df6f099b4099432bd2fece9f50ea7b"
integrity sha512-ALqsj8D7Swb6MnBQuAQ58J3KC3yh6fLGtAmpBmnZX8j+0kmP7NaLt56CuzBw2W2bXPrvHFTgn8iekOQFUKXEQA==
dependencies:
"@types/node" "*"
"@types/ws" "*"
Expand Down Expand Up @@ -1488,7 +1488,7 @@ typescript@^5.6.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.6.3.tgz#5f3449e31c9d94febb17de03cc081dd56d81db5b"
integrity sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==

undici-types@~6.19.2:
undici-types@~6.19.8:
version "6.19.8"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
Expand Down

0 comments on commit abf2f8a

Please sign in to comment.