id
int32 0
167k
| repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
161,800 | argoproj/argo-cd | pkg/apiclient/apiclient.go | redeemRefreshToken | func (c *client) redeemRefreshToken() (string, string, error) {
setConn, setIf, err := c.NewSettingsClient()
if err != nil {
return "", "", err
}
defer func() { _ = setConn.Close() }()
httpClient, err := c.HTTPClient()
if err != nil {
return "", "", err
}
ctx := oidc.ClientContext(context.Background(), httpClient)
acdSet, err := setIf.Get(ctx, &settings.SettingsQuery{})
if err != nil {
return "", "", err
}
oauth2conf, _, err := c.OIDCConfig(ctx, acdSet)
if err != nil {
return "", "", err
}
t := &oauth2.Token{
RefreshToken: c.RefreshToken,
}
token, err := oauth2conf.TokenSource(ctx, t).Token()
if err != nil {
return "", "", err
}
rawIDToken, ok := token.Extra("id_token").(string)
if !ok {
return "", "", errors.New("no id_token in token response")
}
refreshToken, _ := token.Extra("refresh_token").(string)
return rawIDToken, refreshToken, nil
} | go | func (c *client) redeemRefreshToken() (string, string, error) {
setConn, setIf, err := c.NewSettingsClient()
if err != nil {
return "", "", err
}
defer func() { _ = setConn.Close() }()
httpClient, err := c.HTTPClient()
if err != nil {
return "", "", err
}
ctx := oidc.ClientContext(context.Background(), httpClient)
acdSet, err := setIf.Get(ctx, &settings.SettingsQuery{})
if err != nil {
return "", "", err
}
oauth2conf, _, err := c.OIDCConfig(ctx, acdSet)
if err != nil {
return "", "", err
}
t := &oauth2.Token{
RefreshToken: c.RefreshToken,
}
token, err := oauth2conf.TokenSource(ctx, t).Token()
if err != nil {
return "", "", err
}
rawIDToken, ok := token.Extra("id_token").(string)
if !ok {
return "", "", errors.New("no id_token in token response")
}
refreshToken, _ := token.Extra("refresh_token").(string)
return rawIDToken, refreshToken, nil
} | [
"func",
"(",
"c",
"*",
"client",
")",
"redeemRefreshToken",
"(",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"setConn",
",",
"setIf",
",",
"err",
":=",
"c",
".",
"NewSettingsClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"_",
"=",
"setConn",
".",
"Close",
"(",
")",
"}",
"(",
")",
"\n",
"httpClient",
",",
"err",
":=",
"c",
".",
"HTTPClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"ctx",
":=",
"oidc",
".",
"ClientContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"httpClient",
")",
"\n",
"acdSet",
",",
"err",
":=",
"setIf",
".",
"Get",
"(",
"ctx",
",",
"&",
"settings",
".",
"SettingsQuery",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"oauth2conf",
",",
"_",
",",
"err",
":=",
"c",
".",
"OIDCConfig",
"(",
"ctx",
",",
"acdSet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"t",
":=",
"&",
"oauth2",
".",
"Token",
"{",
"RefreshToken",
":",
"c",
".",
"RefreshToken",
",",
"}",
"\n",
"token",
",",
"err",
":=",
"oauth2conf",
".",
"TokenSource",
"(",
"ctx",
",",
"t",
")",
".",
"Token",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"rawIDToken",
",",
"ok",
":=",
"token",
".",
"Extra",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"refreshToken",
",",
"_",
":=",
"token",
".",
"Extra",
"(",
"\"",
"\"",
")",
".",
"(",
"string",
")",
"\n",
"return",
"rawIDToken",
",",
"refreshToken",
",",
"nil",
"\n",
"}"
] | // redeemRefreshToken performs the exchange of a refresh_token for a new id_token and refresh_token | [
"redeemRefreshToken",
"performs",
"the",
"exchange",
"of",
"a",
"refresh_token",
"for",
"a",
"new",
"id_token",
"and",
"refresh_token"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apiclient/apiclient.go#L288-L320 |
161,801 | argoproj/argo-cd | pkg/apiclient/apiclient.go | NewClientOrDie | func NewClientOrDie(opts *ClientOptions) Client {
client, err := NewClient(opts)
if err != nil {
log.Fatal(err)
}
return client
} | go | func NewClientOrDie(opts *ClientOptions) Client {
client, err := NewClient(opts)
if err != nil {
log.Fatal(err)
}
return client
} | [
"func",
"NewClientOrDie",
"(",
"opts",
"*",
"ClientOptions",
")",
"Client",
"{",
"client",
",",
"err",
":=",
"NewClient",
"(",
"opts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"client",
"\n",
"}"
] | // NewClientOrDie creates a new API client from a set of config options, or fails fatally if the new client creation fails. | [
"NewClientOrDie",
"creates",
"a",
"new",
"API",
"client",
"from",
"a",
"set",
"of",
"config",
"options",
"or",
"fails",
"fatally",
"if",
"the",
"new",
"client",
"creation",
"fails",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apiclient/apiclient.go#L323-L329 |
161,802 | argoproj/argo-cd | pkg/apiclient/apiclient.go | WatchApplicationWithRetry | func (c *client) WatchApplicationWithRetry(ctx context.Context, appName string) chan *argoappv1.ApplicationWatchEvent {
appEventsCh := make(chan *argoappv1.ApplicationWatchEvent)
cancelled := false
go func() {
defer close(appEventsCh)
for !cancelled {
conn, appIf, err := c.NewApplicationClient()
if err == nil {
var wc application.ApplicationService_WatchClient
wc, err = appIf.Watch(ctx, &application.ApplicationQuery{Name: &appName})
if err == nil {
for {
var appEvent *v1alpha1.ApplicationWatchEvent
appEvent, err = wc.Recv()
if err != nil {
break
}
appEventsCh <- appEvent
}
}
}
if err != nil {
if isCanceledContextErr(err) {
cancelled = true
} else {
if err != io.EOF {
log.Warnf("watch err: %v", err)
}
time.Sleep(1 * time.Second)
}
}
if conn != nil {
_ = conn.Close()
}
}
}()
return appEventsCh
} | go | func (c *client) WatchApplicationWithRetry(ctx context.Context, appName string) chan *argoappv1.ApplicationWatchEvent {
appEventsCh := make(chan *argoappv1.ApplicationWatchEvent)
cancelled := false
go func() {
defer close(appEventsCh)
for !cancelled {
conn, appIf, err := c.NewApplicationClient()
if err == nil {
var wc application.ApplicationService_WatchClient
wc, err = appIf.Watch(ctx, &application.ApplicationQuery{Name: &appName})
if err == nil {
for {
var appEvent *v1alpha1.ApplicationWatchEvent
appEvent, err = wc.Recv()
if err != nil {
break
}
appEventsCh <- appEvent
}
}
}
if err != nil {
if isCanceledContextErr(err) {
cancelled = true
} else {
if err != io.EOF {
log.Warnf("watch err: %v", err)
}
time.Sleep(1 * time.Second)
}
}
if conn != nil {
_ = conn.Close()
}
}
}()
return appEventsCh
} | [
"func",
"(",
"c",
"*",
"client",
")",
"WatchApplicationWithRetry",
"(",
"ctx",
"context",
".",
"Context",
",",
"appName",
"string",
")",
"chan",
"*",
"argoappv1",
".",
"ApplicationWatchEvent",
"{",
"appEventsCh",
":=",
"make",
"(",
"chan",
"*",
"argoappv1",
".",
"ApplicationWatchEvent",
")",
"\n",
"cancelled",
":=",
"false",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"appEventsCh",
")",
"\n",
"for",
"!",
"cancelled",
"{",
"conn",
",",
"appIf",
",",
"err",
":=",
"c",
".",
"NewApplicationClient",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"var",
"wc",
"application",
".",
"ApplicationService_WatchClient",
"\n",
"wc",
",",
"err",
"=",
"appIf",
".",
"Watch",
"(",
"ctx",
",",
"&",
"application",
".",
"ApplicationQuery",
"{",
"Name",
":",
"&",
"appName",
"}",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"for",
"{",
"var",
"appEvent",
"*",
"v1alpha1",
".",
"ApplicationWatchEvent",
"\n",
"appEvent",
",",
"err",
"=",
"wc",
".",
"Recv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"appEventsCh",
"<-",
"appEvent",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"isCanceledContextErr",
"(",
"err",
")",
"{",
"cancelled",
"=",
"true",
"\n",
"}",
"else",
"{",
"if",
"err",
"!=",
"io",
".",
"EOF",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"1",
"*",
"time",
".",
"Second",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"conn",
"!=",
"nil",
"{",
"_",
"=",
"conn",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"return",
"appEventsCh",
"\n",
"}"
] | // WatchApplicationWithRetry returns a channel of watch events for an application, retrying the
// watch upon errors. Closes the returned channel when the context is cancelled. | [
"WatchApplicationWithRetry",
"returns",
"a",
"channel",
"of",
"watch",
"events",
"for",
"an",
"application",
"retrying",
"the",
"watch",
"upon",
"errors",
".",
"Closes",
"the",
"returned",
"channel",
"when",
"the",
"context",
"is",
"cancelled",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apiclient/apiclient.go#L555-L592 |
161,803 | argoproj/argo-cd | controller/metrics/transportwrapper.go | AddMetricsTransportWrapper | func AddMetricsTransportWrapper(server *MetricsServer, app *v1alpha1.Application, config *rest.Config) *rest.Config {
wrap := config.WrapTransport
config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
if wrap != nil {
rt = wrap(rt)
}
return &metricsRoundTripper{roundTripper: rt, metricsServer: server, app: app}
}
return config
} | go | func AddMetricsTransportWrapper(server *MetricsServer, app *v1alpha1.Application, config *rest.Config) *rest.Config {
wrap := config.WrapTransport
config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
if wrap != nil {
rt = wrap(rt)
}
return &metricsRoundTripper{roundTripper: rt, metricsServer: server, app: app}
}
return config
} | [
"func",
"AddMetricsTransportWrapper",
"(",
"server",
"*",
"MetricsServer",
",",
"app",
"*",
"v1alpha1",
".",
"Application",
",",
"config",
"*",
"rest",
".",
"Config",
")",
"*",
"rest",
".",
"Config",
"{",
"wrap",
":=",
"config",
".",
"WrapTransport",
"\n",
"config",
".",
"WrapTransport",
"=",
"func",
"(",
"rt",
"http",
".",
"RoundTripper",
")",
"http",
".",
"RoundTripper",
"{",
"if",
"wrap",
"!=",
"nil",
"{",
"rt",
"=",
"wrap",
"(",
"rt",
")",
"\n",
"}",
"\n",
"return",
"&",
"metricsRoundTripper",
"{",
"roundTripper",
":",
"rt",
",",
"metricsServer",
":",
"server",
",",
"app",
":",
"app",
"}",
"\n",
"}",
"\n",
"return",
"config",
"\n",
"}"
] | // AddMetricsTransportWrapper adds a transport wrapper which increments 'argocd_app_k8s_request_total' counter on each kubernetes request | [
"AddMetricsTransportWrapper",
"adds",
"a",
"transport",
"wrapper",
"which",
"increments",
"argocd_app_k8s_request_total",
"counter",
"on",
"each",
"kubernetes",
"request"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/controller/metrics/transportwrapper.go#L28-L37 |
161,804 | argoproj/argo-cd | util/kube/kube.go | ToUnstructured | func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error) {
uObj, err := runtime.NewTestUnstructuredConverter(equality.Semantic).ToUnstructured(obj)
if err != nil {
return nil, err
}
return &unstructured.Unstructured{Object: uObj}, nil
} | go | func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error) {
uObj, err := runtime.NewTestUnstructuredConverter(equality.Semantic).ToUnstructured(obj)
if err != nil {
return nil, err
}
return &unstructured.Unstructured{Object: uObj}, nil
} | [
"func",
"ToUnstructured",
"(",
"obj",
"interface",
"{",
"}",
")",
"(",
"*",
"unstructured",
".",
"Unstructured",
",",
"error",
")",
"{",
"uObj",
",",
"err",
":=",
"runtime",
".",
"NewTestUnstructuredConverter",
"(",
"equality",
".",
"Semantic",
")",
".",
"ToUnstructured",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"unstructured",
".",
"Unstructured",
"{",
"Object",
":",
"uObj",
"}",
",",
"nil",
"\n",
"}"
] | // ToUnstructured converts a concrete K8s API type to a un unstructured object | [
"ToUnstructured",
"converts",
"a",
"concrete",
"K8s",
"API",
"type",
"to",
"a",
"un",
"unstructured",
"object"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L118-L124 |
161,805 | argoproj/argo-cd | util/kube/kube.go | MustToUnstructured | func MustToUnstructured(obj interface{}) *unstructured.Unstructured {
uObj, err := ToUnstructured(obj)
if err != nil {
panic(err)
}
return uObj
} | go | func MustToUnstructured(obj interface{}) *unstructured.Unstructured {
uObj, err := ToUnstructured(obj)
if err != nil {
panic(err)
}
return uObj
} | [
"func",
"MustToUnstructured",
"(",
"obj",
"interface",
"{",
"}",
")",
"*",
"unstructured",
".",
"Unstructured",
"{",
"uObj",
",",
"err",
":=",
"ToUnstructured",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"uObj",
"\n",
"}"
] | // MustToUnstructured converts a concrete K8s API type to a un unstructured object and panics if not successful | [
"MustToUnstructured",
"converts",
"a",
"concrete",
"K8s",
"API",
"type",
"to",
"a",
"un",
"unstructured",
"object",
"and",
"panics",
"if",
"not",
"successful"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L127-L133 |
161,806 | argoproj/argo-cd | util/kube/kube.go | GetAppInstanceLabel | func GetAppInstanceLabel(un *unstructured.Unstructured, key string) string {
if labels := un.GetLabels(); labels != nil {
return labels[key]
}
return ""
} | go | func GetAppInstanceLabel(un *unstructured.Unstructured, key string) string {
if labels := un.GetLabels(); labels != nil {
return labels[key]
}
return ""
} | [
"func",
"GetAppInstanceLabel",
"(",
"un",
"*",
"unstructured",
".",
"Unstructured",
",",
"key",
"string",
")",
"string",
"{",
"if",
"labels",
":=",
"un",
".",
"GetLabels",
"(",
")",
";",
"labels",
"!=",
"nil",
"{",
"return",
"labels",
"[",
"key",
"]",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] | // GetAppInstanceLabel returns the application instance name from labels | [
"GetAppInstanceLabel",
"returns",
"the",
"application",
"instance",
"name",
"from",
"labels"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L136-L141 |
161,807 | argoproj/argo-cd | util/kube/kube.go | UnsetLabel | func UnsetLabel(target *unstructured.Unstructured, key string) {
if labels := target.GetLabels(); labels != nil {
if _, ok := labels[key]; ok {
delete(labels, key)
if len(labels) == 0 {
unstructured.RemoveNestedField(target.Object, "metadata", "labels")
} else {
target.SetLabels(labels)
}
}
}
} | go | func UnsetLabel(target *unstructured.Unstructured, key string) {
if labels := target.GetLabels(); labels != nil {
if _, ok := labels[key]; ok {
delete(labels, key)
if len(labels) == 0 {
unstructured.RemoveNestedField(target.Object, "metadata", "labels")
} else {
target.SetLabels(labels)
}
}
}
} | [
"func",
"UnsetLabel",
"(",
"target",
"*",
"unstructured",
".",
"Unstructured",
",",
"key",
"string",
")",
"{",
"if",
"labels",
":=",
"target",
".",
"GetLabels",
"(",
")",
";",
"labels",
"!=",
"nil",
"{",
"if",
"_",
",",
"ok",
":=",
"labels",
"[",
"key",
"]",
";",
"ok",
"{",
"delete",
"(",
"labels",
",",
"key",
")",
"\n",
"if",
"len",
"(",
"labels",
")",
"==",
"0",
"{",
"unstructured",
".",
"RemoveNestedField",
"(",
"target",
".",
"Object",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"target",
".",
"SetLabels",
"(",
"labels",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // UnsetLabel removes our app labels from an unstructured object | [
"UnsetLabel",
"removes",
"our",
"app",
"labels",
"from",
"an",
"unstructured",
"object"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L144-L155 |
161,808 | argoproj/argo-cd | util/kube/kube.go | cleanKubectlOutput | func cleanKubectlOutput(s string) string {
s = strings.TrimSpace(s)
s = strings.Replace(s, ": error validating \"STDIN\"", "", -1)
s = strings.Replace(s, ": unable to recognize \"STDIN\"", "", -1)
s = strings.Replace(s, ": error when creating \"STDIN\"", "", -1)
s = strings.Replace(s, "; if you choose to ignore these errors, turn validation off with --validate=false", "", -1)
s = strings.Replace(s, "error: error", "error", -1)
return s
} | go | func cleanKubectlOutput(s string) string {
s = strings.TrimSpace(s)
s = strings.Replace(s, ": error validating \"STDIN\"", "", -1)
s = strings.Replace(s, ": unable to recognize \"STDIN\"", "", -1)
s = strings.Replace(s, ": error when creating \"STDIN\"", "", -1)
s = strings.Replace(s, "; if you choose to ignore these errors, turn validation off with --validate=false", "", -1)
s = strings.Replace(s, "error: error", "error", -1)
return s
} | [
"func",
"cleanKubectlOutput",
"(",
"s",
"string",
")",
"string",
"{",
"s",
"=",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"s",
"=",
"strings",
".",
"Replace",
"(",
"s",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // cleanKubectlOutput makes the error output of kubectl a little better to read | [
"cleanKubectlOutput",
"makes",
"the",
"error",
"output",
"of",
"kubectl",
"a",
"little",
"better",
"to",
"read"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L270-L278 |
161,809 | argoproj/argo-cd | util/kube/kube.go | WriteKubeConfig | func WriteKubeConfig(restConfig *rest.Config, namespace, filename string) error {
kubeConfig := NewKubeConfig(restConfig, namespace)
return clientcmd.WriteToFile(*kubeConfig, filename)
} | go | func WriteKubeConfig(restConfig *rest.Config, namespace, filename string) error {
kubeConfig := NewKubeConfig(restConfig, namespace)
return clientcmd.WriteToFile(*kubeConfig, filename)
} | [
"func",
"WriteKubeConfig",
"(",
"restConfig",
"*",
"rest",
".",
"Config",
",",
"namespace",
",",
"filename",
"string",
")",
"error",
"{",
"kubeConfig",
":=",
"NewKubeConfig",
"(",
"restConfig",
",",
"namespace",
")",
"\n",
"return",
"clientcmd",
".",
"WriteToFile",
"(",
"*",
"kubeConfig",
",",
"filename",
")",
"\n",
"}"
] | // WriteKubeConfig takes a rest.Config and writes it as a kubeconfig at the specified path | [
"WriteKubeConfig",
"takes",
"a",
"rest",
".",
"Config",
"and",
"writes",
"it",
"as",
"a",
"kubeconfig",
"at",
"the",
"specified",
"path"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L281-L284 |
161,810 | argoproj/argo-cd | util/kube/kube.go | newAuthInfo | func newAuthInfo(restConfig *rest.Config) *clientcmdapi.AuthInfo {
authInfo := clientcmdapi.AuthInfo{}
haveCredentials := false
if restConfig.TLSClientConfig.CertFile != "" {
authInfo.ClientCertificate = restConfig.TLSClientConfig.CertFile
haveCredentials = true
}
if len(restConfig.TLSClientConfig.CertData) > 0 {
authInfo.ClientCertificateData = restConfig.TLSClientConfig.CertData
haveCredentials = true
}
if restConfig.TLSClientConfig.KeyFile != "" {
authInfo.ClientKey = restConfig.TLSClientConfig.KeyFile
haveCredentials = true
}
if len(restConfig.TLSClientConfig.KeyData) > 0 {
authInfo.ClientKeyData = restConfig.TLSClientConfig.KeyData
haveCredentials = true
}
if restConfig.Username != "" {
authInfo.Username = restConfig.Username
haveCredentials = true
}
if restConfig.Password != "" {
authInfo.Password = restConfig.Password
haveCredentials = true
}
if restConfig.BearerToken != "" {
authInfo.Token = restConfig.BearerToken
haveCredentials = true
}
if restConfig.ExecProvider != nil {
authInfo.Exec = restConfig.ExecProvider
haveCredentials = true
}
if restConfig.ExecProvider == nil && !haveCredentials {
// If no credentials were set (or there was no exec provider), we assume in-cluster config.
// In-cluster configs from the go-client will no longer set bearer tokens, so we set the
// well known token path. See issue #774
authInfo.TokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
}
return &authInfo
} | go | func newAuthInfo(restConfig *rest.Config) *clientcmdapi.AuthInfo {
authInfo := clientcmdapi.AuthInfo{}
haveCredentials := false
if restConfig.TLSClientConfig.CertFile != "" {
authInfo.ClientCertificate = restConfig.TLSClientConfig.CertFile
haveCredentials = true
}
if len(restConfig.TLSClientConfig.CertData) > 0 {
authInfo.ClientCertificateData = restConfig.TLSClientConfig.CertData
haveCredentials = true
}
if restConfig.TLSClientConfig.KeyFile != "" {
authInfo.ClientKey = restConfig.TLSClientConfig.KeyFile
haveCredentials = true
}
if len(restConfig.TLSClientConfig.KeyData) > 0 {
authInfo.ClientKeyData = restConfig.TLSClientConfig.KeyData
haveCredentials = true
}
if restConfig.Username != "" {
authInfo.Username = restConfig.Username
haveCredentials = true
}
if restConfig.Password != "" {
authInfo.Password = restConfig.Password
haveCredentials = true
}
if restConfig.BearerToken != "" {
authInfo.Token = restConfig.BearerToken
haveCredentials = true
}
if restConfig.ExecProvider != nil {
authInfo.Exec = restConfig.ExecProvider
haveCredentials = true
}
if restConfig.ExecProvider == nil && !haveCredentials {
// If no credentials were set (or there was no exec provider), we assume in-cluster config.
// In-cluster configs from the go-client will no longer set bearer tokens, so we set the
// well known token path. See issue #774
authInfo.TokenFile = "/var/run/secrets/kubernetes.io/serviceaccount/token"
}
return &authInfo
} | [
"func",
"newAuthInfo",
"(",
"restConfig",
"*",
"rest",
".",
"Config",
")",
"*",
"clientcmdapi",
".",
"AuthInfo",
"{",
"authInfo",
":=",
"clientcmdapi",
".",
"AuthInfo",
"{",
"}",
"\n",
"haveCredentials",
":=",
"false",
"\n",
"if",
"restConfig",
".",
"TLSClientConfig",
".",
"CertFile",
"!=",
"\"",
"\"",
"{",
"authInfo",
".",
"ClientCertificate",
"=",
"restConfig",
".",
"TLSClientConfig",
".",
"CertFile",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"len",
"(",
"restConfig",
".",
"TLSClientConfig",
".",
"CertData",
")",
">",
"0",
"{",
"authInfo",
".",
"ClientCertificateData",
"=",
"restConfig",
".",
"TLSClientConfig",
".",
"CertData",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"TLSClientConfig",
".",
"KeyFile",
"!=",
"\"",
"\"",
"{",
"authInfo",
".",
"ClientKey",
"=",
"restConfig",
".",
"TLSClientConfig",
".",
"KeyFile",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"len",
"(",
"restConfig",
".",
"TLSClientConfig",
".",
"KeyData",
")",
">",
"0",
"{",
"authInfo",
".",
"ClientKeyData",
"=",
"restConfig",
".",
"TLSClientConfig",
".",
"KeyData",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"Username",
"!=",
"\"",
"\"",
"{",
"authInfo",
".",
"Username",
"=",
"restConfig",
".",
"Username",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"Password",
"!=",
"\"",
"\"",
"{",
"authInfo",
".",
"Password",
"=",
"restConfig",
".",
"Password",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"BearerToken",
"!=",
"\"",
"\"",
"{",
"authInfo",
".",
"Token",
"=",
"restConfig",
".",
"BearerToken",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"ExecProvider",
"!=",
"nil",
"{",
"authInfo",
".",
"Exec",
"=",
"restConfig",
".",
"ExecProvider",
"\n",
"haveCredentials",
"=",
"true",
"\n",
"}",
"\n",
"if",
"restConfig",
".",
"ExecProvider",
"==",
"nil",
"&&",
"!",
"haveCredentials",
"{",
"// If no credentials were set (or there was no exec provider), we assume in-cluster config.",
"// In-cluster configs from the go-client will no longer set bearer tokens, so we set the",
"// well known token path. See issue #774",
"authInfo",
".",
"TokenFile",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"&",
"authInfo",
"\n",
"}"
] | // newAuthInfo returns an AuthInfo from a rest config, detecting if the rest.Config is an
// in-cluster config and automatically setting the token path appropriately. | [
"newAuthInfo",
"returns",
"an",
"AuthInfo",
"from",
"a",
"rest",
"config",
"detecting",
"if",
"the",
"rest",
".",
"Config",
"is",
"an",
"in",
"-",
"cluster",
"config",
"and",
"automatically",
"setting",
"the",
"token",
"path",
"appropriately",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L313-L355 |
161,811 | argoproj/argo-cd | util/kube/kube.go | SplitYAML | func SplitYAML(out string) ([]*unstructured.Unstructured, error) {
parts := diffSeparator.Split(out, -1)
var objs []*unstructured.Unstructured
var firstErr error
for _, part := range parts {
var objMap map[string]interface{}
err := yaml.Unmarshal([]byte(part), &objMap)
if err != nil {
if firstErr == nil {
firstErr = fmt.Errorf("Failed to unmarshal manifest: %v", err)
}
continue
}
if len(objMap) == 0 {
// handles case where theres no content between `---`
continue
}
var obj unstructured.Unstructured
err = yaml.Unmarshal([]byte(part), &obj)
if err != nil {
if firstErr == nil {
firstErr = fmt.Errorf("Failed to unmarshal manifest: %v", err)
}
continue
}
remObj, err := Remarshal(&obj)
if err != nil {
log.Debugf("Failed to remarshal oject: %v", err)
} else {
obj = *remObj
}
objs = append(objs, &obj)
}
return objs, firstErr
} | go | func SplitYAML(out string) ([]*unstructured.Unstructured, error) {
parts := diffSeparator.Split(out, -1)
var objs []*unstructured.Unstructured
var firstErr error
for _, part := range parts {
var objMap map[string]interface{}
err := yaml.Unmarshal([]byte(part), &objMap)
if err != nil {
if firstErr == nil {
firstErr = fmt.Errorf("Failed to unmarshal manifest: %v", err)
}
continue
}
if len(objMap) == 0 {
// handles case where theres no content between `---`
continue
}
var obj unstructured.Unstructured
err = yaml.Unmarshal([]byte(part), &obj)
if err != nil {
if firstErr == nil {
firstErr = fmt.Errorf("Failed to unmarshal manifest: %v", err)
}
continue
}
remObj, err := Remarshal(&obj)
if err != nil {
log.Debugf("Failed to remarshal oject: %v", err)
} else {
obj = *remObj
}
objs = append(objs, &obj)
}
return objs, firstErr
} | [
"func",
"SplitYAML",
"(",
"out",
"string",
")",
"(",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
",",
"error",
")",
"{",
"parts",
":=",
"diffSeparator",
".",
"Split",
"(",
"out",
",",
"-",
"1",
")",
"\n",
"var",
"objs",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
"\n",
"var",
"firstErr",
"error",
"\n",
"for",
"_",
",",
"part",
":=",
"range",
"parts",
"{",
"var",
"objMap",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"\n",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"part",
")",
",",
"&",
"objMap",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"firstErr",
"==",
"nil",
"{",
"firstErr",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"if",
"len",
"(",
"objMap",
")",
"==",
"0",
"{",
"// handles case where theres no content between `---`",
"continue",
"\n",
"}",
"\n",
"var",
"obj",
"unstructured",
".",
"Unstructured",
"\n",
"err",
"=",
"yaml",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"part",
")",
",",
"&",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"firstErr",
"==",
"nil",
"{",
"firstErr",
"=",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n",
"remObj",
",",
"err",
":=",
"Remarshal",
"(",
"&",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"else",
"{",
"obj",
"=",
"*",
"remObj",
"\n",
"}",
"\n",
"objs",
"=",
"append",
"(",
"objs",
",",
"&",
"obj",
")",
"\n",
"}",
"\n",
"return",
"objs",
",",
"firstErr",
"\n",
"}"
] | // SplitYAML splits a YAML file into unstructured objects. Returns list of all unstructured objects
// found in the yaml. If any errors occurred, returns the first one | [
"SplitYAML",
"splits",
"a",
"YAML",
"file",
"into",
"unstructured",
"objects",
".",
"Returns",
"list",
"of",
"all",
"unstructured",
"objects",
"found",
"in",
"the",
"yaml",
".",
"If",
"any",
"errors",
"occurred",
"returns",
"the",
"first",
"one"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L361-L395 |
161,812 | argoproj/argo-cd | util/kube/kube.go | Remarshal | func Remarshal(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
data, err := json.Marshal(obj)
if err != nil {
return nil, err
}
item, err := scheme.Scheme.New(obj.GroupVersionKind())
if err != nil {
return nil, err
}
// This will drop any omitempty fields, perform resource conversion etc...
unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
err = json.Unmarshal(data, &unmarshalledObj)
if err != nil {
return nil, err
}
unstrBody, err := runtime.DefaultUnstructuredConverter.ToUnstructured(unmarshalledObj)
if err != nil {
return nil, err
}
// remove all default values specified by custom formatter (e.g. creationTimestamp)
unstrBody = jsonutil.RemoveMapFields(obj.Object, unstrBody)
return &unstructured.Unstructured{Object: unstrBody}, nil
} | go | func Remarshal(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
data, err := json.Marshal(obj)
if err != nil {
return nil, err
}
item, err := scheme.Scheme.New(obj.GroupVersionKind())
if err != nil {
return nil, err
}
// This will drop any omitempty fields, perform resource conversion etc...
unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface()
err = json.Unmarshal(data, &unmarshalledObj)
if err != nil {
return nil, err
}
unstrBody, err := runtime.DefaultUnstructuredConverter.ToUnstructured(unmarshalledObj)
if err != nil {
return nil, err
}
// remove all default values specified by custom formatter (e.g. creationTimestamp)
unstrBody = jsonutil.RemoveMapFields(obj.Object, unstrBody)
return &unstructured.Unstructured{Object: unstrBody}, nil
} | [
"func",
"Remarshal",
"(",
"obj",
"*",
"unstructured",
".",
"Unstructured",
")",
"(",
"*",
"unstructured",
".",
"Unstructured",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"obj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"item",
",",
"err",
":=",
"scheme",
".",
"Scheme",
".",
"New",
"(",
"obj",
".",
"GroupVersionKind",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// This will drop any omitempty fields, perform resource conversion etc...",
"unmarshalledObj",
":=",
"reflect",
".",
"New",
"(",
"reflect",
".",
"TypeOf",
"(",
"item",
")",
".",
"Elem",
"(",
")",
")",
".",
"Interface",
"(",
")",
"\n",
"err",
"=",
"json",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"unmarshalledObj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"unstrBody",
",",
"err",
":=",
"runtime",
".",
"DefaultUnstructuredConverter",
".",
"ToUnstructured",
"(",
"unmarshalledObj",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// remove all default values specified by custom formatter (e.g. creationTimestamp)",
"unstrBody",
"=",
"jsonutil",
".",
"RemoveMapFields",
"(",
"obj",
".",
"Object",
",",
"unstrBody",
")",
"\n",
"return",
"&",
"unstructured",
".",
"Unstructured",
"{",
"Object",
":",
"unstrBody",
"}",
",",
"nil",
"\n",
"}"
] | // Remarshal checks resource kind and version and re-marshal using corresponding struct custom marshaller.
// This ensures that expected resource state is formatter same as actual resource state in kubernetes
// and allows to find differences between actual and target states more accurately. | [
"Remarshal",
"checks",
"resource",
"kind",
"and",
"version",
"and",
"re",
"-",
"marshal",
"using",
"corresponding",
"struct",
"custom",
"marshaller",
".",
"This",
"ensures",
"that",
"expected",
"resource",
"state",
"is",
"formatter",
"same",
"as",
"actual",
"resource",
"state",
"in",
"kubernetes",
"and",
"allows",
"to",
"find",
"differences",
"between",
"actual",
"and",
"target",
"states",
"more",
"accurately",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L400-L422 |
161,813 | argoproj/argo-cd | util/kube/kube.go | WatchWithRetry | func WatchWithRetry(ctx context.Context, getWatch func() (watch.Interface, error)) chan struct {
*watch.Event
Error error
} {
ch := make(chan struct {
*watch.Event
Error error
})
execute := func() (bool, error) {
w, err := getWatch()
if err != nil {
return false, err
}
defer w.Stop()
for {
select {
case event, ok := <-w.ResultChan():
if ok {
ch <- struct {
*watch.Event
Error error
}{Event: &event, Error: nil}
} else {
return true, nil
}
case <-ctx.Done():
return false, nil
}
}
}
go func() {
defer close(ch)
for {
retry, err := execute()
if err != nil {
ch <- struct {
*watch.Event
Error error
}{Error: err}
}
if !retry {
return
}
time.Sleep(time.Second)
}
}()
return ch
} | go | func WatchWithRetry(ctx context.Context, getWatch func() (watch.Interface, error)) chan struct {
*watch.Event
Error error
} {
ch := make(chan struct {
*watch.Event
Error error
})
execute := func() (bool, error) {
w, err := getWatch()
if err != nil {
return false, err
}
defer w.Stop()
for {
select {
case event, ok := <-w.ResultChan():
if ok {
ch <- struct {
*watch.Event
Error error
}{Event: &event, Error: nil}
} else {
return true, nil
}
case <-ctx.Done():
return false, nil
}
}
}
go func() {
defer close(ch)
for {
retry, err := execute()
if err != nil {
ch <- struct {
*watch.Event
Error error
}{Error: err}
}
if !retry {
return
}
time.Sleep(time.Second)
}
}()
return ch
} | [
"func",
"WatchWithRetry",
"(",
"ctx",
"context",
".",
"Context",
",",
"getWatch",
"func",
"(",
")",
"(",
"watch",
".",
"Interface",
",",
"error",
")",
")",
"chan",
"struct",
"{",
"*",
"watch",
".",
"Event",
"\n",
"Error",
"error",
"\n",
"}",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
"{",
"*",
"watch",
".",
"Event",
"\n",
"Error",
"error",
"\n",
"}",
")",
"\n",
"execute",
":=",
"func",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"w",
",",
"err",
":=",
"getWatch",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"defer",
"w",
".",
"Stop",
"(",
")",
"\n\n",
"for",
"{",
"select",
"{",
"case",
"event",
",",
"ok",
":=",
"<-",
"w",
".",
"ResultChan",
"(",
")",
":",
"if",
"ok",
"{",
"ch",
"<-",
"struct",
"{",
"*",
"watch",
".",
"Event",
"\n",
"Error",
"error",
"\n",
"}",
"{",
"Event",
":",
"&",
"event",
",",
"Error",
":",
"nil",
"}",
"\n",
"}",
"else",
"{",
"return",
"true",
",",
"nil",
"\n",
"}",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"false",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"go",
"func",
"(",
")",
"{",
"defer",
"close",
"(",
"ch",
")",
"\n",
"for",
"{",
"retry",
",",
"err",
":=",
"execute",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ch",
"<-",
"struct",
"{",
"*",
"watch",
".",
"Event",
"\n",
"Error",
"error",
"\n",
"}",
"{",
"Error",
":",
"err",
"}",
"\n",
"}",
"\n",
"if",
"!",
"retry",
"{",
"return",
"\n",
"}",
"\n",
"time",
".",
"Sleep",
"(",
"time",
".",
"Second",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"return",
"ch",
"\n",
"}"
] | // WatchWithRetry returns channel of watch events or errors of failed to call watch API. | [
"WatchWithRetry",
"returns",
"channel",
"of",
"watch",
"events",
"or",
"errors",
"of",
"failed",
"to",
"call",
"watch",
"API",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/kube/kube.go#L425-L473 |
161,814 | argoproj/argo-cd | util/db/cluster.go | ListClusters | func (db *db) ListClusters(ctx context.Context) (*appv1.ClusterList, error) {
clusterSecrets, err := db.listClusterSecrets()
if err != nil {
return nil, err
}
clusterList := appv1.ClusterList{
Items: make([]appv1.Cluster, len(clusterSecrets)),
}
hasInClusterCredentials := false
for i, clusterSecret := range clusterSecrets {
cluster := *secretToCluster(clusterSecret)
clusterList.Items[i] = cluster
if cluster.Server == common.KubernetesInternalAPIServerAddr {
hasInClusterCredentials = true
}
}
if !hasInClusterCredentials {
clusterList.Items = append(clusterList.Items, localCluster)
}
return &clusterList, nil
} | go | func (db *db) ListClusters(ctx context.Context) (*appv1.ClusterList, error) {
clusterSecrets, err := db.listClusterSecrets()
if err != nil {
return nil, err
}
clusterList := appv1.ClusterList{
Items: make([]appv1.Cluster, len(clusterSecrets)),
}
hasInClusterCredentials := false
for i, clusterSecret := range clusterSecrets {
cluster := *secretToCluster(clusterSecret)
clusterList.Items[i] = cluster
if cluster.Server == common.KubernetesInternalAPIServerAddr {
hasInClusterCredentials = true
}
}
if !hasInClusterCredentials {
clusterList.Items = append(clusterList.Items, localCluster)
}
return &clusterList, nil
} | [
"func",
"(",
"db",
"*",
"db",
")",
"ListClusters",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"appv1",
".",
"ClusterList",
",",
"error",
")",
"{",
"clusterSecrets",
",",
"err",
":=",
"db",
".",
"listClusterSecrets",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"clusterList",
":=",
"appv1",
".",
"ClusterList",
"{",
"Items",
":",
"make",
"(",
"[",
"]",
"appv1",
".",
"Cluster",
",",
"len",
"(",
"clusterSecrets",
")",
")",
",",
"}",
"\n",
"hasInClusterCredentials",
":=",
"false",
"\n",
"for",
"i",
",",
"clusterSecret",
":=",
"range",
"clusterSecrets",
"{",
"cluster",
":=",
"*",
"secretToCluster",
"(",
"clusterSecret",
")",
"\n",
"clusterList",
".",
"Items",
"[",
"i",
"]",
"=",
"cluster",
"\n",
"if",
"cluster",
".",
"Server",
"==",
"common",
".",
"KubernetesInternalAPIServerAddr",
"{",
"hasInClusterCredentials",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"hasInClusterCredentials",
"{",
"clusterList",
".",
"Items",
"=",
"append",
"(",
"clusterList",
".",
"Items",
",",
"localCluster",
")",
"\n",
"}",
"\n",
"return",
"&",
"clusterList",
",",
"nil",
"\n",
"}"
] | // ListClusters returns list of clusters | [
"ListClusters",
"returns",
"list",
"of",
"clusters"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L51-L71 |
161,815 | argoproj/argo-cd | util/db/cluster.go | CreateCluster | func (db *db) CreateCluster(ctx context.Context, c *appv1.Cluster) (*appv1.Cluster, error) {
secName, err := serverToSecretName(c.Server)
if err != nil {
return nil, err
}
clusterSecret := &apiv1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secName,
Labels: map[string]string{
common.LabelKeySecretType: common.LabelValueSecretTypeCluster,
},
Annotations: map[string]string{
common.AnnotationKeyManagedBy: common.AnnotationValueManagedByArgoCD,
},
},
}
clusterSecret.Data = clusterToData(c)
clusterSecret, err = db.kubeclientset.CoreV1().Secrets(db.ns).Create(clusterSecret)
if err != nil {
if apierr.IsAlreadyExists(err) {
return nil, status.Errorf(codes.AlreadyExists, "cluster %q already exists", c.Server)
}
return nil, err
}
return secretToCluster(clusterSecret), db.settingsMgr.ResyncInformers()
} | go | func (db *db) CreateCluster(ctx context.Context, c *appv1.Cluster) (*appv1.Cluster, error) {
secName, err := serverToSecretName(c.Server)
if err != nil {
return nil, err
}
clusterSecret := &apiv1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secName,
Labels: map[string]string{
common.LabelKeySecretType: common.LabelValueSecretTypeCluster,
},
Annotations: map[string]string{
common.AnnotationKeyManagedBy: common.AnnotationValueManagedByArgoCD,
},
},
}
clusterSecret.Data = clusterToData(c)
clusterSecret, err = db.kubeclientset.CoreV1().Secrets(db.ns).Create(clusterSecret)
if err != nil {
if apierr.IsAlreadyExists(err) {
return nil, status.Errorf(codes.AlreadyExists, "cluster %q already exists", c.Server)
}
return nil, err
}
return secretToCluster(clusterSecret), db.settingsMgr.ResyncInformers()
} | [
"func",
"(",
"db",
"*",
"db",
")",
"CreateCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"appv1",
".",
"Cluster",
")",
"(",
"*",
"appv1",
".",
"Cluster",
",",
"error",
")",
"{",
"secName",
",",
"err",
":=",
"serverToSecretName",
"(",
"c",
".",
"Server",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"clusterSecret",
":=",
"&",
"apiv1",
".",
"Secret",
"{",
"ObjectMeta",
":",
"metav1",
".",
"ObjectMeta",
"{",
"Name",
":",
"secName",
",",
"Labels",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"common",
".",
"LabelKeySecretType",
":",
"common",
".",
"LabelValueSecretTypeCluster",
",",
"}",
",",
"Annotations",
":",
"map",
"[",
"string",
"]",
"string",
"{",
"common",
".",
"AnnotationKeyManagedBy",
":",
"common",
".",
"AnnotationValueManagedByArgoCD",
",",
"}",
",",
"}",
",",
"}",
"\n",
"clusterSecret",
".",
"Data",
"=",
"clusterToData",
"(",
"c",
")",
"\n",
"clusterSecret",
",",
"err",
"=",
"db",
".",
"kubeclientset",
".",
"CoreV1",
"(",
")",
".",
"Secrets",
"(",
"db",
".",
"ns",
")",
".",
"Create",
"(",
"clusterSecret",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"apierr",
".",
"IsAlreadyExists",
"(",
"err",
")",
"{",
"return",
"nil",
",",
"status",
".",
"Errorf",
"(",
"codes",
".",
"AlreadyExists",
",",
"\"",
"\"",
",",
"c",
".",
"Server",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"secretToCluster",
"(",
"clusterSecret",
")",
",",
"db",
".",
"settingsMgr",
".",
"ResyncInformers",
"(",
")",
"\n",
"}"
] | // CreateCluster creates a cluster | [
"CreateCluster",
"creates",
"a",
"cluster"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L74-L99 |
161,816 | argoproj/argo-cd | util/db/cluster.go | WatchClusters | func (db *db) WatchClusters(ctx context.Context, callback func(*ClusterEvent)) error {
listOpts := metav1.ListOptions{}
labelSelector := labels.NewSelector()
req, err := labels.NewRequirement(common.LabelKeySecretType, selection.Equals, []string{common.LabelValueSecretTypeCluster})
if err != nil {
return err
}
labelSelector = labelSelector.Add(*req)
listOpts.LabelSelector = labelSelector.String()
w, err := db.kubeclientset.CoreV1().Secrets(db.ns).Watch(listOpts)
if err != nil {
return err
}
localCls, err := db.GetCluster(ctx, common.KubernetesInternalAPIServerAddr)
if err != nil {
return err
}
defer w.Stop()
done := make(chan bool)
// trigger callback with event for local cluster since it always considered added
callback(&ClusterEvent{Type: watch.Added, Cluster: localCls})
go func() {
for next := range w.ResultChan() {
secret := next.Object.(*apiv1.Secret)
cluster := secretToCluster(secret)
// change local cluster event to modified or deleted, since it cannot be re-added or deleted
if cluster.Server == common.KubernetesInternalAPIServerAddr {
if next.Type == watch.Deleted {
next.Type = watch.Modified
cluster = &localCluster
} else if next.Type == watch.Added {
localCls = cluster
next.Type = watch.Modified
} else {
localCls = cluster
}
}
callback(&ClusterEvent{
Type: next.Type,
Cluster: cluster,
})
}
done <- true
}()
select {
case <-done:
case <-ctx.Done():
}
return nil
} | go | func (db *db) WatchClusters(ctx context.Context, callback func(*ClusterEvent)) error {
listOpts := metav1.ListOptions{}
labelSelector := labels.NewSelector()
req, err := labels.NewRequirement(common.LabelKeySecretType, selection.Equals, []string{common.LabelValueSecretTypeCluster})
if err != nil {
return err
}
labelSelector = labelSelector.Add(*req)
listOpts.LabelSelector = labelSelector.String()
w, err := db.kubeclientset.CoreV1().Secrets(db.ns).Watch(listOpts)
if err != nil {
return err
}
localCls, err := db.GetCluster(ctx, common.KubernetesInternalAPIServerAddr)
if err != nil {
return err
}
defer w.Stop()
done := make(chan bool)
// trigger callback with event for local cluster since it always considered added
callback(&ClusterEvent{Type: watch.Added, Cluster: localCls})
go func() {
for next := range w.ResultChan() {
secret := next.Object.(*apiv1.Secret)
cluster := secretToCluster(secret)
// change local cluster event to modified or deleted, since it cannot be re-added or deleted
if cluster.Server == common.KubernetesInternalAPIServerAddr {
if next.Type == watch.Deleted {
next.Type = watch.Modified
cluster = &localCluster
} else if next.Type == watch.Added {
localCls = cluster
next.Type = watch.Modified
} else {
localCls = cluster
}
}
callback(&ClusterEvent{
Type: next.Type,
Cluster: cluster,
})
}
done <- true
}()
select {
case <-done:
case <-ctx.Done():
}
return nil
} | [
"func",
"(",
"db",
"*",
"db",
")",
"WatchClusters",
"(",
"ctx",
"context",
".",
"Context",
",",
"callback",
"func",
"(",
"*",
"ClusterEvent",
")",
")",
"error",
"{",
"listOpts",
":=",
"metav1",
".",
"ListOptions",
"{",
"}",
"\n",
"labelSelector",
":=",
"labels",
".",
"NewSelector",
"(",
")",
"\n",
"req",
",",
"err",
":=",
"labels",
".",
"NewRequirement",
"(",
"common",
".",
"LabelKeySecretType",
",",
"selection",
".",
"Equals",
",",
"[",
"]",
"string",
"{",
"common",
".",
"LabelValueSecretTypeCluster",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"labelSelector",
"=",
"labelSelector",
".",
"Add",
"(",
"*",
"req",
")",
"\n",
"listOpts",
".",
"LabelSelector",
"=",
"labelSelector",
".",
"String",
"(",
")",
"\n",
"w",
",",
"err",
":=",
"db",
".",
"kubeclientset",
".",
"CoreV1",
"(",
")",
".",
"Secrets",
"(",
"db",
".",
"ns",
")",
".",
"Watch",
"(",
"listOpts",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"localCls",
",",
"err",
":=",
"db",
".",
"GetCluster",
"(",
"ctx",
",",
"common",
".",
"KubernetesInternalAPIServerAddr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"w",
".",
"Stop",
"(",
")",
"\n",
"done",
":=",
"make",
"(",
"chan",
"bool",
")",
"\n\n",
"// trigger callback with event for local cluster since it always considered added",
"callback",
"(",
"&",
"ClusterEvent",
"{",
"Type",
":",
"watch",
".",
"Added",
",",
"Cluster",
":",
"localCls",
"}",
")",
"\n\n",
"go",
"func",
"(",
")",
"{",
"for",
"next",
":=",
"range",
"w",
".",
"ResultChan",
"(",
")",
"{",
"secret",
":=",
"next",
".",
"Object",
".",
"(",
"*",
"apiv1",
".",
"Secret",
")",
"\n",
"cluster",
":=",
"secretToCluster",
"(",
"secret",
")",
"\n\n",
"// change local cluster event to modified or deleted, since it cannot be re-added or deleted",
"if",
"cluster",
".",
"Server",
"==",
"common",
".",
"KubernetesInternalAPIServerAddr",
"{",
"if",
"next",
".",
"Type",
"==",
"watch",
".",
"Deleted",
"{",
"next",
".",
"Type",
"=",
"watch",
".",
"Modified",
"\n",
"cluster",
"=",
"&",
"localCluster",
"\n",
"}",
"else",
"if",
"next",
".",
"Type",
"==",
"watch",
".",
"Added",
"{",
"localCls",
"=",
"cluster",
"\n",
"next",
".",
"Type",
"=",
"watch",
".",
"Modified",
"\n",
"}",
"else",
"{",
"localCls",
"=",
"cluster",
"\n",
"}",
"\n",
"}",
"\n\n",
"callback",
"(",
"&",
"ClusterEvent",
"{",
"Type",
":",
"next",
".",
"Type",
",",
"Cluster",
":",
"cluster",
",",
"}",
")",
"\n",
"}",
"\n",
"done",
"<-",
"true",
"\n",
"}",
"(",
")",
"\n\n",
"select",
"{",
"case",
"<-",
"done",
":",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // WatchClusters allow watching for cluster events | [
"WatchClusters",
"allow",
"watching",
"for",
"cluster",
"events"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L108-L164 |
161,817 | argoproj/argo-cd | util/db/cluster.go | GetCluster | func (db *db) GetCluster(ctx context.Context, server string) (*appv1.Cluster, error) {
clusterSecret, err := db.getClusterSecret(server)
if err != nil {
if errorStatus, ok := status.FromError(err); ok && errorStatus.Code() == codes.NotFound && server == common.KubernetesInternalAPIServerAddr {
return &localCluster, nil
} else {
return nil, err
}
}
return secretToCluster(clusterSecret), nil
} | go | func (db *db) GetCluster(ctx context.Context, server string) (*appv1.Cluster, error) {
clusterSecret, err := db.getClusterSecret(server)
if err != nil {
if errorStatus, ok := status.FromError(err); ok && errorStatus.Code() == codes.NotFound && server == common.KubernetesInternalAPIServerAddr {
return &localCluster, nil
} else {
return nil, err
}
}
return secretToCluster(clusterSecret), nil
} | [
"func",
"(",
"db",
"*",
"db",
")",
"GetCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"server",
"string",
")",
"(",
"*",
"appv1",
".",
"Cluster",
",",
"error",
")",
"{",
"clusterSecret",
",",
"err",
":=",
"db",
".",
"getClusterSecret",
"(",
"server",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"errorStatus",
",",
"ok",
":=",
"status",
".",
"FromError",
"(",
"err",
")",
";",
"ok",
"&&",
"errorStatus",
".",
"Code",
"(",
")",
"==",
"codes",
".",
"NotFound",
"&&",
"server",
"==",
"common",
".",
"KubernetesInternalAPIServerAddr",
"{",
"return",
"&",
"localCluster",
",",
"nil",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"secretToCluster",
"(",
"clusterSecret",
")",
",",
"nil",
"\n",
"}"
] | // GetCluster returns a cluster from a query | [
"GetCluster",
"returns",
"a",
"cluster",
"from",
"a",
"query"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L181-L191 |
161,818 | argoproj/argo-cd | util/db/cluster.go | UpdateCluster | func (db *db) UpdateCluster(ctx context.Context, c *appv1.Cluster) (*appv1.Cluster, error) {
clusterSecret, err := db.getClusterSecret(c.Server)
if err != nil {
return nil, err
}
clusterSecret.Data = clusterToData(c)
clusterSecret, err = db.kubeclientset.CoreV1().Secrets(db.ns).Update(clusterSecret)
if err != nil {
return nil, err
}
return secretToCluster(clusterSecret), db.settingsMgr.ResyncInformers()
} | go | func (db *db) UpdateCluster(ctx context.Context, c *appv1.Cluster) (*appv1.Cluster, error) {
clusterSecret, err := db.getClusterSecret(c.Server)
if err != nil {
return nil, err
}
clusterSecret.Data = clusterToData(c)
clusterSecret, err = db.kubeclientset.CoreV1().Secrets(db.ns).Update(clusterSecret)
if err != nil {
return nil, err
}
return secretToCluster(clusterSecret), db.settingsMgr.ResyncInformers()
} | [
"func",
"(",
"db",
"*",
"db",
")",
"UpdateCluster",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"appv1",
".",
"Cluster",
")",
"(",
"*",
"appv1",
".",
"Cluster",
",",
"error",
")",
"{",
"clusterSecret",
",",
"err",
":=",
"db",
".",
"getClusterSecret",
"(",
"c",
".",
"Server",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"clusterSecret",
".",
"Data",
"=",
"clusterToData",
"(",
"c",
")",
"\n",
"clusterSecret",
",",
"err",
"=",
"db",
".",
"kubeclientset",
".",
"CoreV1",
"(",
")",
".",
"Secrets",
"(",
"db",
".",
"ns",
")",
".",
"Update",
"(",
"clusterSecret",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"secretToCluster",
"(",
"clusterSecret",
")",
",",
"db",
".",
"settingsMgr",
".",
"ResyncInformers",
"(",
")",
"\n",
"}"
] | // UpdateCluster updates a cluster | [
"UpdateCluster",
"updates",
"a",
"cluster"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L194-L205 |
161,819 | argoproj/argo-cd | util/db/cluster.go | serverToSecretName | func serverToSecretName(server string) (string, error) {
serverURL, err := url.ParseRequestURI(server)
if err != nil {
return "", err
}
h := fnv.New32a()
_, _ = h.Write([]byte(server))
host := strings.ToLower(strings.Split(serverURL.Host, ":")[0])
return fmt.Sprintf("cluster-%s-%v", host, h.Sum32()), nil
} | go | func serverToSecretName(server string) (string, error) {
serverURL, err := url.ParseRequestURI(server)
if err != nil {
return "", err
}
h := fnv.New32a()
_, _ = h.Write([]byte(server))
host := strings.ToLower(strings.Split(serverURL.Host, ":")[0])
return fmt.Sprintf("cluster-%s-%v", host, h.Sum32()), nil
} | [
"func",
"serverToSecretName",
"(",
"server",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"serverURL",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"server",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"h",
":=",
"fnv",
".",
"New32a",
"(",
")",
"\n",
"_",
",",
"_",
"=",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"server",
")",
")",
"\n",
"host",
":=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"Split",
"(",
"serverURL",
".",
"Host",
",",
"\"",
"\"",
")",
"[",
"0",
"]",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"host",
",",
"h",
".",
"Sum32",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] | // serverToSecretName hashes server address to the secret name using a formula.
// Part of the server address is incorporated for debugging purposes | [
"serverToSecretName",
"hashes",
"server",
"address",
"to",
"the",
"secret",
"name",
"using",
"a",
"formula",
".",
"Part",
"of",
"the",
"server",
"address",
"is",
"incorporated",
"for",
"debugging",
"purposes"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L234-L243 |
161,820 | argoproj/argo-cd | util/db/cluster.go | clusterToData | func clusterToData(c *appv1.Cluster) map[string][]byte {
data := make(map[string][]byte)
data["server"] = []byte(c.Server)
if c.Name == "" {
data["name"] = []byte(c.Server)
} else {
data["name"] = []byte(c.Name)
}
configBytes, err := json.Marshal(c.Config)
if err != nil {
panic(err)
}
data["config"] = configBytes
return data
} | go | func clusterToData(c *appv1.Cluster) map[string][]byte {
data := make(map[string][]byte)
data["server"] = []byte(c.Server)
if c.Name == "" {
data["name"] = []byte(c.Server)
} else {
data["name"] = []byte(c.Name)
}
configBytes, err := json.Marshal(c.Config)
if err != nil {
panic(err)
}
data["config"] = configBytes
return data
} | [
"func",
"clusterToData",
"(",
"c",
"*",
"appv1",
".",
"Cluster",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
"{",
"data",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
")",
"\n",
"data",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"byte",
"(",
"c",
".",
"Server",
")",
"\n",
"if",
"c",
".",
"Name",
"==",
"\"",
"\"",
"{",
"data",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"byte",
"(",
"c",
".",
"Server",
")",
"\n",
"}",
"else",
"{",
"data",
"[",
"\"",
"\"",
"]",
"=",
"[",
"]",
"byte",
"(",
"c",
".",
"Name",
")",
"\n",
"}",
"\n",
"configBytes",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"c",
".",
"Config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"data",
"[",
"\"",
"\"",
"]",
"=",
"configBytes",
"\n",
"return",
"data",
"\n",
"}"
] | // clusterToData converts a cluster object to string data for serialization to a secret | [
"clusterToData",
"converts",
"a",
"cluster",
"object",
"to",
"string",
"data",
"for",
"serialization",
"to",
"a",
"secret"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L246-L260 |
161,821 | argoproj/argo-cd | util/db/cluster.go | secretToCluster | func secretToCluster(s *apiv1.Secret) *appv1.Cluster {
var config appv1.ClusterConfig
err := json.Unmarshal(s.Data["config"], &config)
if err != nil {
panic(err)
}
cluster := appv1.Cluster{
Server: string(s.Data["server"]),
Name: string(s.Data["name"]),
Config: config,
}
return &cluster
} | go | func secretToCluster(s *apiv1.Secret) *appv1.Cluster {
var config appv1.ClusterConfig
err := json.Unmarshal(s.Data["config"], &config)
if err != nil {
panic(err)
}
cluster := appv1.Cluster{
Server: string(s.Data["server"]),
Name: string(s.Data["name"]),
Config: config,
}
return &cluster
} | [
"func",
"secretToCluster",
"(",
"s",
"*",
"apiv1",
".",
"Secret",
")",
"*",
"appv1",
".",
"Cluster",
"{",
"var",
"config",
"appv1",
".",
"ClusterConfig",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"s",
".",
"Data",
"[",
"\"",
"\"",
"]",
",",
"&",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"cluster",
":=",
"appv1",
".",
"Cluster",
"{",
"Server",
":",
"string",
"(",
"s",
".",
"Data",
"[",
"\"",
"\"",
"]",
")",
",",
"Name",
":",
"string",
"(",
"s",
".",
"Data",
"[",
"\"",
"\"",
"]",
")",
",",
"Config",
":",
"config",
",",
"}",
"\n",
"return",
"&",
"cluster",
"\n",
"}"
] | // secretToCluster converts a secret into a repository object | [
"secretToCluster",
"converts",
"a",
"secret",
"into",
"a",
"repository",
"object"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/db/cluster.go#L263-L275 |
161,822 | argoproj/argo-cd | util/password/password.go | hashPasswordWithHashers | func hashPasswordWithHashers(password string, hashers []PasswordHasher) (string, error) {
// Even though good hashers will disallow blank passwords, let's be explicit that ALL BLANK PASSWORDS ARE INVALID. Full stop.
if password == "" {
return "", fmt.Errorf("blank passwords are not allowed")
}
return hashers[0].HashPassword(password)
} | go | func hashPasswordWithHashers(password string, hashers []PasswordHasher) (string, error) {
// Even though good hashers will disallow blank passwords, let's be explicit that ALL BLANK PASSWORDS ARE INVALID. Full stop.
if password == "" {
return "", fmt.Errorf("blank passwords are not allowed")
}
return hashers[0].HashPassword(password)
} | [
"func",
"hashPasswordWithHashers",
"(",
"password",
"string",
",",
"hashers",
"[",
"]",
"PasswordHasher",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Even though good hashers will disallow blank passwords, let's be explicit that ALL BLANK PASSWORDS ARE INVALID. Full stop.",
"if",
"password",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"hashers",
"[",
"0",
"]",
".",
"HashPassword",
"(",
"password",
")",
"\n",
"}"
] | // HashPasswordWithHashers hashes an entered password using the first hasher in the provided list of hashers. | [
"HashPasswordWithHashers",
"hashes",
"an",
"entered",
"password",
"using",
"the",
"first",
"hasher",
"in",
"the",
"provided",
"list",
"of",
"hashers",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/password/password.go#L33-L39 |
161,823 | argoproj/argo-cd | server/repository/repository.go | NewServer | func NewServer(
repoClientset reposerver.Clientset,
db db.ArgoDB,
enf *rbac.Enforcer,
cache *cache.Cache,
) *Server {
return &Server{
db: db,
repoClientset: repoClientset,
enf: enf,
cache: cache,
}
} | go | func NewServer(
repoClientset reposerver.Clientset,
db db.ArgoDB,
enf *rbac.Enforcer,
cache *cache.Cache,
) *Server {
return &Server{
db: db,
repoClientset: repoClientset,
enf: enf,
cache: cache,
}
} | [
"func",
"NewServer",
"(",
"repoClientset",
"reposerver",
".",
"Clientset",
",",
"db",
"db",
".",
"ArgoDB",
",",
"enf",
"*",
"rbac",
".",
"Enforcer",
",",
"cache",
"*",
"cache",
".",
"Cache",
",",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"db",
":",
"db",
",",
"repoClientset",
":",
"repoClientset",
",",
"enf",
":",
"enf",
",",
"cache",
":",
"cache",
",",
"}",
"\n",
"}"
] | // NewServer returns a new instance of the Repository service | [
"NewServer",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Repository",
"service"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/repository/repository.go#L37-L49 |
161,824 | argoproj/argo-cd | server/repository/repository.go | List | func (s *Server) List(ctx context.Context, q *RepoQuery) (*appsv1.RepositoryList, error) {
urls, err := s.db.ListRepoURLs(ctx)
if err != nil {
return nil, err
}
items := make([]appsv1.Repository, 0)
for _, url := range urls {
if s.enf.Enforce(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionGet, url) {
items = append(items, appsv1.Repository{Repo: url})
}
}
err = util.RunAllAsync(len(items), func(i int) error {
items[i].ConnectionState = s.getConnectionState(ctx, items[i].Repo)
return nil
})
if err != nil {
return nil, err
}
return &appsv1.RepositoryList{Items: items}, nil
} | go | func (s *Server) List(ctx context.Context, q *RepoQuery) (*appsv1.RepositoryList, error) {
urls, err := s.db.ListRepoURLs(ctx)
if err != nil {
return nil, err
}
items := make([]appsv1.Repository, 0)
for _, url := range urls {
if s.enf.Enforce(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionGet, url) {
items = append(items, appsv1.Repository{Repo: url})
}
}
err = util.RunAllAsync(len(items), func(i int) error {
items[i].ConnectionState = s.getConnectionState(ctx, items[i].Repo)
return nil
})
if err != nil {
return nil, err
}
return &appsv1.RepositoryList{Items: items}, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"*",
"RepoQuery",
")",
"(",
"*",
"appsv1",
".",
"RepositoryList",
",",
"error",
")",
"{",
"urls",
",",
"err",
":=",
"s",
".",
"db",
".",
"ListRepoURLs",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"items",
":=",
"make",
"(",
"[",
"]",
"appsv1",
".",
"Repository",
",",
"0",
")",
"\n",
"for",
"_",
",",
"url",
":=",
"range",
"urls",
"{",
"if",
"s",
".",
"enf",
".",
"Enforce",
"(",
"ctx",
".",
"Value",
"(",
"\"",
"\"",
")",
",",
"rbacpolicy",
".",
"ResourceRepositories",
",",
"rbacpolicy",
".",
"ActionGet",
",",
"url",
")",
"{",
"items",
"=",
"append",
"(",
"items",
",",
"appsv1",
".",
"Repository",
"{",
"Repo",
":",
"url",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"err",
"=",
"util",
".",
"RunAllAsync",
"(",
"len",
"(",
"items",
")",
",",
"func",
"(",
"i",
"int",
")",
"error",
"{",
"items",
"[",
"i",
"]",
".",
"ConnectionState",
"=",
"s",
".",
"getConnectionState",
"(",
"ctx",
",",
"items",
"[",
"i",
"]",
".",
"Repo",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"appsv1",
".",
"RepositoryList",
"{",
"Items",
":",
"items",
"}",
",",
"nil",
"\n",
"}"
] | // List returns list of repositories | [
"List",
"returns",
"list",
"of",
"repositories"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/repository/repository.go#L76-L95 |
161,825 | argoproj/argo-cd | server/repository/repository.go | ListApps | func (s *Server) ListApps(ctx context.Context, q *RepoAppsQuery) (*RepoAppsResponse, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionGet, q.Repo); err != nil {
return nil, err
}
repo, err := s.db.GetRepository(ctx, q.Repo)
if err != nil {
if errStatus, ok := status.FromError(err); ok && errStatus.Code() == codes.NotFound {
repo = &appsv1.Repository{
Repo: q.Repo,
}
} else {
return nil, err
}
}
// Test the repo
conn, repoClient, err := s.repoClientset.NewRepoServerClient()
if err != nil {
return nil, err
}
defer util.Close(conn)
revision := q.Revision
if revision == "" {
revision = "HEAD"
}
paths, err := s.listAppsPaths(ctx, repoClient, repo, revision, "")
if err != nil {
return nil, err
}
items := make([]*AppInfo, 0)
for appFilePath, appType := range paths {
items = append(items, &AppInfo{Path: path.Dir(appFilePath), Type: string(appType)})
}
return &RepoAppsResponse{Items: items}, nil
} | go | func (s *Server) ListApps(ctx context.Context, q *RepoAppsQuery) (*RepoAppsResponse, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionGet, q.Repo); err != nil {
return nil, err
}
repo, err := s.db.GetRepository(ctx, q.Repo)
if err != nil {
if errStatus, ok := status.FromError(err); ok && errStatus.Code() == codes.NotFound {
repo = &appsv1.Repository{
Repo: q.Repo,
}
} else {
return nil, err
}
}
// Test the repo
conn, repoClient, err := s.repoClientset.NewRepoServerClient()
if err != nil {
return nil, err
}
defer util.Close(conn)
revision := q.Revision
if revision == "" {
revision = "HEAD"
}
paths, err := s.listAppsPaths(ctx, repoClient, repo, revision, "")
if err != nil {
return nil, err
}
items := make([]*AppInfo, 0)
for appFilePath, appType := range paths {
items = append(items, &AppInfo{Path: path.Dir(appFilePath), Type: string(appType)})
}
return &RepoAppsResponse{Items: items}, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ListApps",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"*",
"RepoAppsQuery",
")",
"(",
"*",
"RepoAppsResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".",
"enf",
".",
"EnforceErr",
"(",
"ctx",
".",
"Value",
"(",
"\"",
"\"",
")",
",",
"rbacpolicy",
".",
"ResourceRepositories",
",",
"rbacpolicy",
".",
"ActionGet",
",",
"q",
".",
"Repo",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"repo",
",",
"err",
":=",
"s",
".",
"db",
".",
"GetRepository",
"(",
"ctx",
",",
"q",
".",
"Repo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"errStatus",
",",
"ok",
":=",
"status",
".",
"FromError",
"(",
"err",
")",
";",
"ok",
"&&",
"errStatus",
".",
"Code",
"(",
")",
"==",
"codes",
".",
"NotFound",
"{",
"repo",
"=",
"&",
"appsv1",
".",
"Repository",
"{",
"Repo",
":",
"q",
".",
"Repo",
",",
"}",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"// Test the repo",
"conn",
",",
"repoClient",
",",
"err",
":=",
"s",
".",
"repoClientset",
".",
"NewRepoServerClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"revision",
":=",
"q",
".",
"Revision",
"\n",
"if",
"revision",
"==",
"\"",
"\"",
"{",
"revision",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"paths",
",",
"err",
":=",
"s",
".",
"listAppsPaths",
"(",
"ctx",
",",
"repoClient",
",",
"repo",
",",
"revision",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"items",
":=",
"make",
"(",
"[",
"]",
"*",
"AppInfo",
",",
"0",
")",
"\n",
"for",
"appFilePath",
",",
"appType",
":=",
"range",
"paths",
"{",
"items",
"=",
"append",
"(",
"items",
",",
"&",
"AppInfo",
"{",
"Path",
":",
"path",
".",
"Dir",
"(",
"appFilePath",
")",
",",
"Type",
":",
"string",
"(",
"appType",
")",
"}",
")",
"\n",
"}",
"\n",
"return",
"&",
"RepoAppsResponse",
"{",
"Items",
":",
"items",
"}",
",",
"nil",
"\n",
"}"
] | // ListApps returns list of apps in the repo | [
"ListApps",
"returns",
"list",
"of",
"apps",
"in",
"the",
"repo"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/repository/repository.go#L161-L197 |
161,826 | argoproj/argo-cd | server/repository/repository.go | Create | func (s *Server) Create(ctx context.Context, q *RepoCreateRequest) (*appsv1.Repository, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionCreate, q.Repo.Repo); err != nil {
return nil, err
}
r := q.Repo
err := git.TestRepo(r.Repo, r.Username, r.Password, r.SSHPrivateKey, r.InsecureIgnoreHostKey)
if err != nil {
return nil, err
}
r.ConnectionState = appsv1.ConnectionState{Status: appsv1.ConnectionStatusSuccessful}
repo, err := s.db.CreateRepository(ctx, r)
if status.Convert(err).Code() == codes.AlreadyExists {
// act idempotent if existing spec matches new spec
existing, getErr := s.db.GetRepository(ctx, r.Repo)
if getErr != nil {
return nil, status.Errorf(codes.Internal, "unable to check existing repository details: %v", getErr)
}
// repository ConnectionState may differ, so make consistent before testing
existing.ConnectionState = r.ConnectionState
if reflect.DeepEqual(existing, r) {
repo, err = existing, nil
} else if q.Upsert {
return s.Update(ctx, &RepoUpdateRequest{Repo: r})
} else {
return nil, status.Errorf(codes.InvalidArgument, "existing repository spec is different; use upsert flag to force update")
}
}
return &appsv1.Repository{Repo: repo.Repo}, err
} | go | func (s *Server) Create(ctx context.Context, q *RepoCreateRequest) (*appsv1.Repository, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionCreate, q.Repo.Repo); err != nil {
return nil, err
}
r := q.Repo
err := git.TestRepo(r.Repo, r.Username, r.Password, r.SSHPrivateKey, r.InsecureIgnoreHostKey)
if err != nil {
return nil, err
}
r.ConnectionState = appsv1.ConnectionState{Status: appsv1.ConnectionStatusSuccessful}
repo, err := s.db.CreateRepository(ctx, r)
if status.Convert(err).Code() == codes.AlreadyExists {
// act idempotent if existing spec matches new spec
existing, getErr := s.db.GetRepository(ctx, r.Repo)
if getErr != nil {
return nil, status.Errorf(codes.Internal, "unable to check existing repository details: %v", getErr)
}
// repository ConnectionState may differ, so make consistent before testing
existing.ConnectionState = r.ConnectionState
if reflect.DeepEqual(existing, r) {
repo, err = existing, nil
} else if q.Upsert {
return s.Update(ctx, &RepoUpdateRequest{Repo: r})
} else {
return nil, status.Errorf(codes.InvalidArgument, "existing repository spec is different; use upsert flag to force update")
}
}
return &appsv1.Repository{Repo: repo.Repo}, err
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"*",
"RepoCreateRequest",
")",
"(",
"*",
"appsv1",
".",
"Repository",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".",
"enf",
".",
"EnforceErr",
"(",
"ctx",
".",
"Value",
"(",
"\"",
"\"",
")",
",",
"rbacpolicy",
".",
"ResourceRepositories",
",",
"rbacpolicy",
".",
"ActionCreate",
",",
"q",
".",
"Repo",
".",
"Repo",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"r",
":=",
"q",
".",
"Repo",
"\n",
"err",
":=",
"git",
".",
"TestRepo",
"(",
"r",
".",
"Repo",
",",
"r",
".",
"Username",
",",
"r",
".",
"Password",
",",
"r",
".",
"SSHPrivateKey",
",",
"r",
".",
"InsecureIgnoreHostKey",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"r",
".",
"ConnectionState",
"=",
"appsv1",
".",
"ConnectionState",
"{",
"Status",
":",
"appsv1",
".",
"ConnectionStatusSuccessful",
"}",
"\n",
"repo",
",",
"err",
":=",
"s",
".",
"db",
".",
"CreateRepository",
"(",
"ctx",
",",
"r",
")",
"\n",
"if",
"status",
".",
"Convert",
"(",
"err",
")",
".",
"Code",
"(",
")",
"==",
"codes",
".",
"AlreadyExists",
"{",
"// act idempotent if existing spec matches new spec",
"existing",
",",
"getErr",
":=",
"s",
".",
"db",
".",
"GetRepository",
"(",
"ctx",
",",
"r",
".",
"Repo",
")",
"\n",
"if",
"getErr",
"!=",
"nil",
"{",
"return",
"nil",
",",
"status",
".",
"Errorf",
"(",
"codes",
".",
"Internal",
",",
"\"",
"\"",
",",
"getErr",
")",
"\n",
"}",
"\n\n",
"// repository ConnectionState may differ, so make consistent before testing",
"existing",
".",
"ConnectionState",
"=",
"r",
".",
"ConnectionState",
"\n",
"if",
"reflect",
".",
"DeepEqual",
"(",
"existing",
",",
"r",
")",
"{",
"repo",
",",
"err",
"=",
"existing",
",",
"nil",
"\n",
"}",
"else",
"if",
"q",
".",
"Upsert",
"{",
"return",
"s",
".",
"Update",
"(",
"ctx",
",",
"&",
"RepoUpdateRequest",
"{",
"Repo",
":",
"r",
"}",
")",
"\n",
"}",
"else",
"{",
"return",
"nil",
",",
"status",
".",
"Errorf",
"(",
"codes",
".",
"InvalidArgument",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"&",
"appsv1",
".",
"Repository",
"{",
"Repo",
":",
"repo",
".",
"Repo",
"}",
",",
"err",
"\n",
"}"
] | // Create creates a repository | [
"Create",
"creates",
"a",
"repository"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/repository/repository.go#L233-L263 |
161,827 | argoproj/argo-cd | server/repository/repository.go | Update | func (s *Server) Update(ctx context.Context, q *RepoUpdateRequest) (*appsv1.Repository, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionUpdate, q.Repo.Repo); err != nil {
return nil, err
}
_, err := s.db.UpdateRepository(ctx, q.Repo)
return &appsv1.Repository{Repo: q.Repo.Repo}, err
} | go | func (s *Server) Update(ctx context.Context, q *RepoUpdateRequest) (*appsv1.Repository, error) {
if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceRepositories, rbacpolicy.ActionUpdate, q.Repo.Repo); err != nil {
return nil, err
}
_, err := s.db.UpdateRepository(ctx, q.Repo)
return &appsv1.Repository{Repo: q.Repo.Repo}, err
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"*",
"RepoUpdateRequest",
")",
"(",
"*",
"appsv1",
".",
"Repository",
",",
"error",
")",
"{",
"if",
"err",
":=",
"s",
".",
"enf",
".",
"EnforceErr",
"(",
"ctx",
".",
"Value",
"(",
"\"",
"\"",
")",
",",
"rbacpolicy",
".",
"ResourceRepositories",
",",
"rbacpolicy",
".",
"ActionUpdate",
",",
"q",
".",
"Repo",
".",
"Repo",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"s",
".",
"db",
".",
"UpdateRepository",
"(",
"ctx",
",",
"q",
".",
"Repo",
")",
"\n",
"return",
"&",
"appsv1",
".",
"Repository",
"{",
"Repo",
":",
"q",
".",
"Repo",
".",
"Repo",
"}",
",",
"err",
"\n",
"}"
] | // Update updates a repository | [
"Update",
"updates",
"a",
"repository"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/repository/repository.go#L266-L272 |
161,828 | argoproj/argo-cd | util/stats/stats.go | StartStatsTicker | func StartStatsTicker(d time.Duration) {
ticker := time.NewTicker(d)
go func() {
for {
<-ticker.C
LogStats()
}
}()
} | go | func StartStatsTicker(d time.Duration) {
ticker := time.NewTicker(d)
go func() {
for {
<-ticker.C
LogStats()
}
}()
} | [
"func",
"StartStatsTicker",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"d",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"<-",
"ticker",
".",
"C",
"\n",
"LogStats",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // StartStatsTicker starts a goroutine which dumps stats at a specified interval | [
"StartStatsTicker",
"starts",
"a",
"goroutine",
"which",
"dumps",
"stats",
"at",
"a",
"specified",
"interval"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/stats/stats.go#L15-L23 |
161,829 | argoproj/argo-cd | util/stats/stats.go | RegisterStackDumper | func RegisterStackDumper() {
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGUSR1)
for {
<-sigs
LogStack()
}
}()
} | go | func RegisterStackDumper() {
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGUSR1)
for {
<-sigs
LogStack()
}
}()
} | [
"func",
"RegisterStackDumper",
"(",
")",
"{",
"go",
"func",
"(",
")",
"{",
"sigs",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"sigs",
",",
"syscall",
".",
"SIGUSR1",
")",
"\n",
"for",
"{",
"<-",
"sigs",
"\n",
"LogStack",
"(",
")",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // RegisterStackDumper spawns a goroutine which dumps stack trace upon a SIGUSR1 | [
"RegisterStackDumper",
"spawns",
"a",
"goroutine",
"which",
"dumps",
"stack",
"trace",
"upon",
"a",
"SIGUSR1"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/stats/stats.go#L26-L35 |
161,830 | argoproj/argo-cd | util/stats/stats.go | RegisterHeapDumper | func RegisterHeapDumper(filePath string) {
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGUSR2)
for {
<-sigs
runtime.GC()
if _, err := os.Stat(filePath); err == nil {
err = os.Remove(filePath)
if err != nil {
log.Warnf("could not delete heap profile file: %v", err)
return
}
}
f, err := os.Create(filePath)
if err != nil {
log.Warnf("could not create heap profile file: %v", err)
return
}
if err := pprof.WriteHeapProfile(f); err != nil {
log.Warnf("could not write heap profile: %v", err)
return
} else {
log.Infof("dumped heap profile to %s", filePath)
}
}
}()
} | go | func RegisterHeapDumper(filePath string) {
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGUSR2)
for {
<-sigs
runtime.GC()
if _, err := os.Stat(filePath); err == nil {
err = os.Remove(filePath)
if err != nil {
log.Warnf("could not delete heap profile file: %v", err)
return
}
}
f, err := os.Create(filePath)
if err != nil {
log.Warnf("could not create heap profile file: %v", err)
return
}
if err := pprof.WriteHeapProfile(f); err != nil {
log.Warnf("could not write heap profile: %v", err)
return
} else {
log.Infof("dumped heap profile to %s", filePath)
}
}
}()
} | [
"func",
"RegisterHeapDumper",
"(",
"filePath",
"string",
")",
"{",
"go",
"func",
"(",
")",
"{",
"sigs",
":=",
"make",
"(",
"chan",
"os",
".",
"Signal",
",",
"1",
")",
"\n",
"signal",
".",
"Notify",
"(",
"sigs",
",",
"syscall",
".",
"SIGUSR2",
")",
"\n",
"for",
"{",
"<-",
"sigs",
"\n",
"runtime",
".",
"GC",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filePath",
")",
";",
"err",
"==",
"nil",
"{",
"err",
"=",
"os",
".",
"Remove",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"f",
",",
"err",
":=",
"os",
".",
"Create",
"(",
"filePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"pprof",
".",
"WriteHeapProfile",
"(",
"f",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"Warnf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"else",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"filePath",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"(",
")",
"\n",
"}"
] | // RegisterHeapDumper spawns a goroutine which dumps heap profile upon a SIGUSR2 | [
"RegisterHeapDumper",
"spawns",
"a",
"goroutine",
"which",
"dumps",
"heap",
"profile",
"upon",
"a",
"SIGUSR2"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/stats/stats.go#L38-L66 |
161,831 | argoproj/argo-cd | util/stats/stats.go | LogStats | func LogStats() {
var m runtime.MemStats
runtime.ReadMemStats(&m)
log.Infof("Alloc=%v TotalAlloc=%v Sys=%v NumGC=%v Goroutines=%d",
m.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine())
} | go | func LogStats() {
var m runtime.MemStats
runtime.ReadMemStats(&m)
log.Infof("Alloc=%v TotalAlloc=%v Sys=%v NumGC=%v Goroutines=%d",
m.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine())
} | [
"func",
"LogStats",
"(",
")",
"{",
"var",
"m",
"runtime",
".",
"MemStats",
"\n",
"runtime",
".",
"ReadMemStats",
"(",
"&",
"m",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"m",
".",
"Alloc",
"/",
"1024",
",",
"m",
".",
"TotalAlloc",
"/",
"1024",
",",
"m",
".",
"Sys",
"/",
"1024",
",",
"m",
".",
"NumGC",
",",
"runtime",
".",
"NumGoroutine",
"(",
")",
")",
"\n\n",
"}"
] | // LogStats logs runtime statistics | [
"LogStats",
"logs",
"runtime",
"statistics"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/stats/stats.go#L69-L75 |
161,832 | argoproj/argo-cd | util/stats/stats.go | LogStack | func LogStack() {
buf := make([]byte, 1<<20)
stacklen := runtime.Stack(buf, true)
log.Infof("*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
} | go | func LogStack() {
buf := make([]byte, 1<<20)
stacklen := runtime.Stack(buf, true)
log.Infof("*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
} | [
"func",
"LogStack",
"(",
")",
"{",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
"<<",
"20",
")",
"\n",
"stacklen",
":=",
"runtime",
".",
"Stack",
"(",
"buf",
",",
"true",
")",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\\n",
"\\n",
"\\n",
"\"",
",",
"buf",
"[",
":",
"stacklen",
"]",
")",
"\n",
"}"
] | // LogStack will log the current stack | [
"LogStack",
"will",
"log",
"the",
"current",
"stack"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/stats/stats.go#L78-L82 |
161,833 | argoproj/argo-cd | controller/state.go | NewAppStateManager | func NewAppStateManager(
db db.ArgoDB,
appclientset appclientset.Interface,
repoClientset reposerver.Clientset,
namespace string,
kubectl kubeutil.Kubectl,
settings *settings.ArgoCDSettings,
liveStateCache statecache.LiveStateCache,
projInformer cache.SharedIndexInformer,
metricsServer *metrics.MetricsServer,
) AppStateManager {
return &appStateManager{
liveStateCache: liveStateCache,
db: db,
appclientset: appclientset,
kubectl: kubectl,
repoClientset: repoClientset,
namespace: namespace,
settings: settings,
projInformer: projInformer,
metricsServer: metricsServer,
}
} | go | func NewAppStateManager(
db db.ArgoDB,
appclientset appclientset.Interface,
repoClientset reposerver.Clientset,
namespace string,
kubectl kubeutil.Kubectl,
settings *settings.ArgoCDSettings,
liveStateCache statecache.LiveStateCache,
projInformer cache.SharedIndexInformer,
metricsServer *metrics.MetricsServer,
) AppStateManager {
return &appStateManager{
liveStateCache: liveStateCache,
db: db,
appclientset: appclientset,
kubectl: kubectl,
repoClientset: repoClientset,
namespace: namespace,
settings: settings,
projInformer: projInformer,
metricsServer: metricsServer,
}
} | [
"func",
"NewAppStateManager",
"(",
"db",
"db",
".",
"ArgoDB",
",",
"appclientset",
"appclientset",
".",
"Interface",
",",
"repoClientset",
"reposerver",
".",
"Clientset",
",",
"namespace",
"string",
",",
"kubectl",
"kubeutil",
".",
"Kubectl",
",",
"settings",
"*",
"settings",
".",
"ArgoCDSettings",
",",
"liveStateCache",
"statecache",
".",
"LiveStateCache",
",",
"projInformer",
"cache",
".",
"SharedIndexInformer",
",",
"metricsServer",
"*",
"metrics",
".",
"MetricsServer",
",",
")",
"AppStateManager",
"{",
"return",
"&",
"appStateManager",
"{",
"liveStateCache",
":",
"liveStateCache",
",",
"db",
":",
"db",
",",
"appclientset",
":",
"appclientset",
",",
"kubectl",
":",
"kubectl",
",",
"repoClientset",
":",
"repoClientset",
",",
"namespace",
":",
"namespace",
",",
"settings",
":",
"settings",
",",
"projInformer",
":",
"projInformer",
",",
"metricsServer",
":",
"metricsServer",
",",
"}",
"\n",
"}"
] | // NewAppStateManager creates new instance of Ksonnet app comparator | [
"NewAppStateManager",
"creates",
"new",
"instance",
"of",
"Ksonnet",
"app",
"comparator"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/controller/state.go#L378-L400 |
161,834 | argoproj/argo-cd | server/application/application.pb.gw.go | RegisterApplicationServiceHandler | func RegisterApplicationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterApplicationServiceHandlerClient(ctx, mux, NewApplicationServiceClient(conn))
} | go | func RegisterApplicationServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterApplicationServiceHandlerClient(ctx, mux, NewApplicationServiceClient(conn))
} | [
"func",
"RegisterApplicationServiceHandler",
"(",
"ctx",
"context",
".",
"Context",
",",
"mux",
"*",
"runtime",
".",
"ServeMux",
",",
"conn",
"*",
"grpc",
".",
"ClientConn",
")",
"error",
"{",
"return",
"RegisterApplicationServiceHandlerClient",
"(",
"ctx",
",",
"mux",
",",
"NewApplicationServiceClient",
"(",
"conn",
")",
")",
"\n",
"}"
] | // RegisterApplicationServiceHandler registers the http handlers for service ApplicationService to "mux".
// The handlers forward requests to the grpc endpoint over "conn". | [
"RegisterApplicationServiceHandler",
"registers",
"the",
"http",
"handlers",
"for",
"service",
"ApplicationService",
"to",
"mux",
".",
"The",
"handlers",
"forward",
"requests",
"to",
"the",
"grpc",
"endpoint",
"over",
"conn",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/application/application.pb.gw.go#L734-L736 |
161,835 | argoproj/argo-cd | util/git/client.go | Init | func (m *nativeGitClient) Init() error {
_, err := git.PlainOpen(m.root)
if err == nil {
return nil
}
if err != git.ErrRepositoryNotExists {
return err
}
log.Infof("Initializing %s to %s", m.repoURL, m.root)
_, err = exec.Command("rm", "-rf", m.root).Output()
if err != nil {
return fmt.Errorf("unable to clean repo at %s: %v", m.root, err)
}
err = os.MkdirAll(m.root, 0755)
if err != nil {
return err
}
repo, err := git.PlainInit(m.root, false)
if err != nil {
return err
}
_, err = repo.CreateRemote(&config.RemoteConfig{
Name: git.DefaultRemoteName,
URLs: []string{m.repoURL},
})
return err
} | go | func (m *nativeGitClient) Init() error {
_, err := git.PlainOpen(m.root)
if err == nil {
return nil
}
if err != git.ErrRepositoryNotExists {
return err
}
log.Infof("Initializing %s to %s", m.repoURL, m.root)
_, err = exec.Command("rm", "-rf", m.root).Output()
if err != nil {
return fmt.Errorf("unable to clean repo at %s: %v", m.root, err)
}
err = os.MkdirAll(m.root, 0755)
if err != nil {
return err
}
repo, err := git.PlainInit(m.root, false)
if err != nil {
return err
}
_, err = repo.CreateRemote(&config.RemoteConfig{
Name: git.DefaultRemoteName,
URLs: []string{m.repoURL},
})
return err
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"Init",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"git",
".",
"PlainOpen",
"(",
"m",
".",
"root",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"git",
".",
"ErrRepositoryNotExists",
"{",
"return",
"err",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"m",
".",
"repoURL",
",",
"m",
".",
"root",
")",
"\n",
"_",
",",
"err",
"=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"m",
".",
"root",
")",
".",
"Output",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"m",
".",
"root",
",",
"err",
")",
"\n",
"}",
"\n",
"err",
"=",
"os",
".",
"MkdirAll",
"(",
"m",
".",
"root",
",",
"0755",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"repo",
",",
"err",
":=",
"git",
".",
"PlainInit",
"(",
"m",
".",
"root",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"repo",
".",
"CreateRemote",
"(",
"&",
"config",
".",
"RemoteConfig",
"{",
"Name",
":",
"git",
".",
"DefaultRemoteName",
",",
"URLs",
":",
"[",
"]",
"string",
"{",
"m",
".",
"repoURL",
"}",
",",
"}",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Init initializes a local git repository and sets the remote origin | [
"Init",
"initializes",
"a",
"local",
"git",
"repository",
"and",
"sets",
"the",
"remote",
"origin"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L86-L112 |
161,836 | argoproj/argo-cd | util/git/client.go | Fetch | func (m *nativeGitClient) Fetch() error {
log.Debugf("Fetching repo %s at %s", m.repoURL, m.root)
// Two techniques are used for fetching the remote depending if the remote is SSH vs. HTTPS
// If http, we fork/exec the git CLI since the go-git client does not properly support git
// providers such as AWS CodeCommit and Azure DevOps.
if _, ok := m.auth.(*ssh2.PublicKeys); ok {
return m.goGitFetch()
}
_, err := m.runCredentialedCmd("git", "fetch", "origin", "--tags", "--force")
return err
} | go | func (m *nativeGitClient) Fetch() error {
log.Debugf("Fetching repo %s at %s", m.repoURL, m.root)
// Two techniques are used for fetching the remote depending if the remote is SSH vs. HTTPS
// If http, we fork/exec the git CLI since the go-git client does not properly support git
// providers such as AWS CodeCommit and Azure DevOps.
if _, ok := m.auth.(*ssh2.PublicKeys); ok {
return m.goGitFetch()
}
_, err := m.runCredentialedCmd("git", "fetch", "origin", "--tags", "--force")
return err
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"Fetch",
"(",
")",
"error",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"m",
".",
"repoURL",
",",
"m",
".",
"root",
")",
"\n",
"// Two techniques are used for fetching the remote depending if the remote is SSH vs. HTTPS",
"// If http, we fork/exec the git CLI since the go-git client does not properly support git",
"// providers such as AWS CodeCommit and Azure DevOps.",
"if",
"_",
",",
"ok",
":=",
"m",
".",
"auth",
".",
"(",
"*",
"ssh2",
".",
"PublicKeys",
")",
";",
"ok",
"{",
"return",
"m",
".",
"goGitFetch",
"(",
")",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"m",
".",
"runCredentialedCmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // Fetch fetches latest updates from origin | [
"Fetch",
"fetches",
"latest",
"updates",
"from",
"origin"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L115-L125 |
161,837 | argoproj/argo-cd | util/git/client.go | goGitFetch | func (m *nativeGitClient) goGitFetch() error {
repo, err := git.PlainOpen(m.root)
if err != nil {
return err
}
log.Debug("git fetch origin --tags --force")
err = repo.Fetch(&git.FetchOptions{
RemoteName: git.DefaultRemoteName,
Auth: m.auth,
Tags: git.AllTags,
Force: true,
})
if err == git.NoErrAlreadyUpToDate {
return nil
}
return err
} | go | func (m *nativeGitClient) goGitFetch() error {
repo, err := git.PlainOpen(m.root)
if err != nil {
return err
}
log.Debug("git fetch origin --tags --force")
err = repo.Fetch(&git.FetchOptions{
RemoteName: git.DefaultRemoteName,
Auth: m.auth,
Tags: git.AllTags,
Force: true,
})
if err == git.NoErrAlreadyUpToDate {
return nil
}
return err
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"goGitFetch",
"(",
")",
"error",
"{",
"repo",
",",
"err",
":=",
"git",
".",
"PlainOpen",
"(",
"m",
".",
"root",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"repo",
".",
"Fetch",
"(",
"&",
"git",
".",
"FetchOptions",
"{",
"RemoteName",
":",
"git",
".",
"DefaultRemoteName",
",",
"Auth",
":",
"m",
".",
"auth",
",",
"Tags",
":",
"git",
".",
"AllTags",
",",
"Force",
":",
"true",
",",
"}",
")",
"\n",
"if",
"err",
"==",
"git",
".",
"NoErrAlreadyUpToDate",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // goGitFetch fetches the remote using go-git | [
"goGitFetch",
"fetches",
"the",
"remote",
"using",
"go",
"-",
"git"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L128-L145 |
161,838 | argoproj/argo-cd | util/git/client.go | LsFiles | func (m *nativeGitClient) LsFiles(path string) ([]string, error) {
out, err := m.runCmd("git", "ls-files", "--full-name", "-z", "--", path)
if err != nil {
return nil, err
}
// remove last element, which is blank regardless of whether we're using nullbyte or newline
ss := strings.Split(out, "\000")
return ss[:len(ss)-1], nil
} | go | func (m *nativeGitClient) LsFiles(path string) ([]string, error) {
out, err := m.runCmd("git", "ls-files", "--full-name", "-z", "--", path)
if err != nil {
return nil, err
}
// remove last element, which is blank regardless of whether we're using nullbyte or newline
ss := strings.Split(out, "\000")
return ss[:len(ss)-1], nil
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"LsFiles",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"m",
".",
"runCmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"// remove last element, which is blank regardless of whether we're using nullbyte or newline",
"ss",
":=",
"strings",
".",
"Split",
"(",
"out",
",",
"\"",
"\\000",
"\"",
")",
"\n",
"return",
"ss",
"[",
":",
"len",
"(",
"ss",
")",
"-",
"1",
"]",
",",
"nil",
"\n",
"}"
] | // LsFiles lists the local working tree, including only files that are under source control | [
"LsFiles",
"lists",
"the",
"local",
"working",
"tree",
"including",
"only",
"files",
"that",
"are",
"under",
"source",
"control"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L148-L156 |
161,839 | argoproj/argo-cd | util/git/client.go | Checkout | func (m *nativeGitClient) Checkout(revision string) error {
if revision == "" || revision == "HEAD" {
revision = "origin/HEAD"
}
if _, err := m.runCmd("git", "checkout", "--force", revision); err != nil {
return err
}
if _, err := m.runCmd("git", "clean", "-fdx"); err != nil {
return err
}
return nil
} | go | func (m *nativeGitClient) Checkout(revision string) error {
if revision == "" || revision == "HEAD" {
revision = "origin/HEAD"
}
if _, err := m.runCmd("git", "checkout", "--force", revision); err != nil {
return err
}
if _, err := m.runCmd("git", "clean", "-fdx"); err != nil {
return err
}
return nil
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"Checkout",
"(",
"revision",
"string",
")",
"error",
"{",
"if",
"revision",
"==",
"\"",
"\"",
"||",
"revision",
"==",
"\"",
"\"",
"{",
"revision",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"m",
".",
"runCmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"revision",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"m",
".",
"runCmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Checkout checkout specified git sha | [
"Checkout",
"checkout",
"specified",
"git",
"sha"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L159-L170 |
161,840 | argoproj/argo-cd | util/git/client.go | LsRemote | func (m *nativeGitClient) LsRemote(revision string) (string, error) {
if IsCommitSHA(revision) {
return revision, nil
}
repo, err := git.Init(memory.NewStorage(), nil)
if err != nil {
return "", err
}
remote, err := repo.CreateRemote(&config.RemoteConfig{
Name: git.DefaultRemoteName,
URLs: []string{m.repoURL},
})
if err != nil {
return "", err
}
refs, err := remote.List(&git.ListOptions{Auth: m.auth})
if err != nil {
return "", err
}
if revision == "" {
revision = "HEAD"
}
// refToHash keeps a maps of remote refs to their hash
// (e.g. refs/heads/master -> a67038ae2e9cb9b9b16423702f98b41e36601001)
refToHash := make(map[string]string)
// refToResolve remembers ref name of the supplied revision if we determine the revision is a
// symbolic reference (like HEAD), in which case we will resolve it from the refToHash map
refToResolve := ""
for _, ref := range refs {
refName := ref.Name().String()
if refName != "HEAD" && !strings.HasPrefix(refName, "refs/heads/") && !strings.HasPrefix(refName, "refs/tags/") {
// ignore things like 'refs/pull/' 'refs/reviewable'
continue
}
hash := ref.Hash().String()
if ref.Type() == plumbing.HashReference {
refToHash[refName] = hash
}
//log.Debugf("%s\t%s", hash, refName)
if ref.Name().Short() == revision {
if ref.Type() == plumbing.HashReference {
log.Debugf("revision '%s' resolved to '%s'", revision, hash)
return hash, nil
}
if ref.Type() == plumbing.SymbolicReference {
refToResolve = ref.Target().String()
}
}
}
if refToResolve != "" {
// If refToResolve is non-empty, we are resolving symbolic reference (e.g. HEAD).
// It should exist in our refToHash map
if hash, ok := refToHash[refToResolve]; ok {
log.Debugf("symbolic reference '%s' (%s) resolved to '%s'", revision, refToResolve, hash)
return hash, nil
}
}
// We support the ability to use a truncated commit-SHA (e.g. first 7 characters of a SHA)
if IsTruncatedCommitSHA(revision) {
log.Debugf("revision '%s' assumed to be commit sha", revision)
return revision, nil
}
// If we get here, revision string had non hexadecimal characters (indicating its a branch, tag,
// or symbolic ref) and we were unable to resolve it to a commit SHA.
return "", fmt.Errorf("Unable to resolve '%s' to a commit SHA", revision)
} | go | func (m *nativeGitClient) LsRemote(revision string) (string, error) {
if IsCommitSHA(revision) {
return revision, nil
}
repo, err := git.Init(memory.NewStorage(), nil)
if err != nil {
return "", err
}
remote, err := repo.CreateRemote(&config.RemoteConfig{
Name: git.DefaultRemoteName,
URLs: []string{m.repoURL},
})
if err != nil {
return "", err
}
refs, err := remote.List(&git.ListOptions{Auth: m.auth})
if err != nil {
return "", err
}
if revision == "" {
revision = "HEAD"
}
// refToHash keeps a maps of remote refs to their hash
// (e.g. refs/heads/master -> a67038ae2e9cb9b9b16423702f98b41e36601001)
refToHash := make(map[string]string)
// refToResolve remembers ref name of the supplied revision if we determine the revision is a
// symbolic reference (like HEAD), in which case we will resolve it from the refToHash map
refToResolve := ""
for _, ref := range refs {
refName := ref.Name().String()
if refName != "HEAD" && !strings.HasPrefix(refName, "refs/heads/") && !strings.HasPrefix(refName, "refs/tags/") {
// ignore things like 'refs/pull/' 'refs/reviewable'
continue
}
hash := ref.Hash().String()
if ref.Type() == plumbing.HashReference {
refToHash[refName] = hash
}
//log.Debugf("%s\t%s", hash, refName)
if ref.Name().Short() == revision {
if ref.Type() == plumbing.HashReference {
log.Debugf("revision '%s' resolved to '%s'", revision, hash)
return hash, nil
}
if ref.Type() == plumbing.SymbolicReference {
refToResolve = ref.Target().String()
}
}
}
if refToResolve != "" {
// If refToResolve is non-empty, we are resolving symbolic reference (e.g. HEAD).
// It should exist in our refToHash map
if hash, ok := refToHash[refToResolve]; ok {
log.Debugf("symbolic reference '%s' (%s) resolved to '%s'", revision, refToResolve, hash)
return hash, nil
}
}
// We support the ability to use a truncated commit-SHA (e.g. first 7 characters of a SHA)
if IsTruncatedCommitSHA(revision) {
log.Debugf("revision '%s' assumed to be commit sha", revision)
return revision, nil
}
// If we get here, revision string had non hexadecimal characters (indicating its a branch, tag,
// or symbolic ref) and we were unable to resolve it to a commit SHA.
return "", fmt.Errorf("Unable to resolve '%s' to a commit SHA", revision)
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"LsRemote",
"(",
"revision",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"IsCommitSHA",
"(",
"revision",
")",
"{",
"return",
"revision",
",",
"nil",
"\n",
"}",
"\n",
"repo",
",",
"err",
":=",
"git",
".",
"Init",
"(",
"memory",
".",
"NewStorage",
"(",
")",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"remote",
",",
"err",
":=",
"repo",
".",
"CreateRemote",
"(",
"&",
"config",
".",
"RemoteConfig",
"{",
"Name",
":",
"git",
".",
"DefaultRemoteName",
",",
"URLs",
":",
"[",
"]",
"string",
"{",
"m",
".",
"repoURL",
"}",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"refs",
",",
"err",
":=",
"remote",
".",
"List",
"(",
"&",
"git",
".",
"ListOptions",
"{",
"Auth",
":",
"m",
".",
"auth",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"if",
"revision",
"==",
"\"",
"\"",
"{",
"revision",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"// refToHash keeps a maps of remote refs to their hash",
"// (e.g. refs/heads/master -> a67038ae2e9cb9b9b16423702f98b41e36601001)",
"refToHash",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"// refToResolve remembers ref name of the supplied revision if we determine the revision is a",
"// symbolic reference (like HEAD), in which case we will resolve it from the refToHash map",
"refToResolve",
":=",
"\"",
"\"",
"\n",
"for",
"_",
",",
"ref",
":=",
"range",
"refs",
"{",
"refName",
":=",
"ref",
".",
"Name",
"(",
")",
".",
"String",
"(",
")",
"\n",
"if",
"refName",
"!=",
"\"",
"\"",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"refName",
",",
"\"",
"\"",
")",
"&&",
"!",
"strings",
".",
"HasPrefix",
"(",
"refName",
",",
"\"",
"\"",
")",
"{",
"// ignore things like 'refs/pull/' 'refs/reviewable'",
"continue",
"\n",
"}",
"\n",
"hash",
":=",
"ref",
".",
"Hash",
"(",
")",
".",
"String",
"(",
")",
"\n",
"if",
"ref",
".",
"Type",
"(",
")",
"==",
"plumbing",
".",
"HashReference",
"{",
"refToHash",
"[",
"refName",
"]",
"=",
"hash",
"\n",
"}",
"\n",
"//log.Debugf(\"%s\\t%s\", hash, refName)",
"if",
"ref",
".",
"Name",
"(",
")",
".",
"Short",
"(",
")",
"==",
"revision",
"{",
"if",
"ref",
".",
"Type",
"(",
")",
"==",
"plumbing",
".",
"HashReference",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"revision",
",",
"hash",
")",
"\n",
"return",
"hash",
",",
"nil",
"\n",
"}",
"\n",
"if",
"ref",
".",
"Type",
"(",
")",
"==",
"plumbing",
".",
"SymbolicReference",
"{",
"refToResolve",
"=",
"ref",
".",
"Target",
"(",
")",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"refToResolve",
"!=",
"\"",
"\"",
"{",
"// If refToResolve is non-empty, we are resolving symbolic reference (e.g. HEAD).",
"// It should exist in our refToHash map",
"if",
"hash",
",",
"ok",
":=",
"refToHash",
"[",
"refToResolve",
"]",
";",
"ok",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"revision",
",",
"refToResolve",
",",
"hash",
")",
"\n",
"return",
"hash",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"// We support the ability to use a truncated commit-SHA (e.g. first 7 characters of a SHA)",
"if",
"IsTruncatedCommitSHA",
"(",
"revision",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"revision",
")",
"\n",
"return",
"revision",
",",
"nil",
"\n",
"}",
"\n",
"// If we get here, revision string had non hexadecimal characters (indicating its a branch, tag,",
"// or symbolic ref) and we were unable to resolve it to a commit SHA.",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"revision",
")",
"\n",
"}"
] | // LsRemote resolves the commit SHA of a specific branch, tag, or HEAD. If the supplied revision
// does not resolve, and "looks" like a 7+ hexadecimal commit SHA, it return the revision string.
// Otherwise, it returns an error indicating that the revision could not be resolved. This method
// runs with in-memory storage and is safe to run concurrently, or to be run without a git
// repository locally cloned. | [
"LsRemote",
"resolves",
"the",
"commit",
"SHA",
"of",
"a",
"specific",
"branch",
"tag",
"or",
"HEAD",
".",
"If",
"the",
"supplied",
"revision",
"does",
"not",
"resolve",
"and",
"looks",
"like",
"a",
"7",
"+",
"hexadecimal",
"commit",
"SHA",
"it",
"return",
"the",
"revision",
"string",
".",
"Otherwise",
"it",
"returns",
"an",
"error",
"indicating",
"that",
"the",
"revision",
"could",
"not",
"be",
"resolved",
".",
"This",
"method",
"runs",
"with",
"in",
"-",
"memory",
"storage",
"and",
"is",
"safe",
"to",
"run",
"concurrently",
"or",
"to",
"be",
"run",
"without",
"a",
"git",
"repository",
"locally",
"cloned",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L177-L242 |
161,841 | argoproj/argo-cd | util/git/client.go | CommitSHA | func (m *nativeGitClient) CommitSHA() (string, error) {
out, err := m.runCmd("git", "rev-parse", "HEAD")
if err != nil {
return "", err
}
return strings.TrimSpace(out), nil
} | go | func (m *nativeGitClient) CommitSHA() (string, error) {
out, err := m.runCmd("git", "rev-parse", "HEAD")
if err != nil {
return "", err
}
return strings.TrimSpace(out), nil
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"CommitSHA",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"out",
",",
"err",
":=",
"m",
".",
"runCmd",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"strings",
".",
"TrimSpace",
"(",
"out",
")",
",",
"nil",
"\n",
"}"
] | // CommitSHA returns current commit sha from `git rev-parse HEAD` | [
"CommitSHA",
"returns",
"current",
"commit",
"sha",
"from",
"git",
"rev",
"-",
"parse",
"HEAD"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L245-L251 |
161,842 | argoproj/argo-cd | util/git/client.go | runCmd | func (m *nativeGitClient) runCmd(command string, args ...string) (string, error) {
cmd := exec.Command(command, args...)
return m.runCmdOutput(cmd)
} | go | func (m *nativeGitClient) runCmd(command string, args ...string) (string, error) {
cmd := exec.Command(command, args...)
return m.runCmdOutput(cmd)
} | [
"func",
"(",
"m",
"*",
"nativeGitClient",
")",
"runCmd",
"(",
"command",
"string",
",",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"command",
",",
"args",
"...",
")",
"\n",
"return",
"m",
".",
"runCmdOutput",
"(",
"cmd",
")",
"\n",
"}"
] | // runCmd is a convenience function to run a command in a given directory and return its output | [
"runCmd",
"is",
"a",
"convenience",
"function",
"to",
"run",
"a",
"command",
"in",
"a",
"given",
"directory",
"and",
"return",
"its",
"output"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/git/client.go#L254-L257 |
161,843 | argoproj/argo-cd | pkg/client/clientset/versioned/typed/application/v1alpha1/application.go | newApplications | func newApplications(c *ArgoprojV1alpha1Client, namespace string) *applications {
return &applications{
client: c.RESTClient(),
ns: namespace,
}
} | go | func newApplications(c *ArgoprojV1alpha1Client, namespace string) *applications {
return &applications{
client: c.RESTClient(),
ns: namespace,
}
} | [
"func",
"newApplications",
"(",
"c",
"*",
"ArgoprojV1alpha1Client",
",",
"namespace",
"string",
")",
"*",
"applications",
"{",
"return",
"&",
"applications",
"{",
"client",
":",
"c",
".",
"RESTClient",
"(",
")",
",",
"ns",
":",
"namespace",
",",
"}",
"\n",
"}"
] | // newApplications returns a Applications | [
"newApplications",
"returns",
"a",
"Applications"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/client/clientset/versioned/typed/application/v1alpha1/application.go#L40-L45 |
161,844 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationCommand | func NewApplicationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "app",
Short: "Manage applications",
Example: appExample,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
command.AddCommand(NewApplicationCreateCommand(clientOpts))
command.AddCommand(NewApplicationGetCommand(clientOpts))
command.AddCommand(NewApplicationDiffCommand(clientOpts))
command.AddCommand(NewApplicationSetCommand(clientOpts))
command.AddCommand(NewApplicationUnsetCommand(clientOpts))
command.AddCommand(NewApplicationSyncCommand(clientOpts))
command.AddCommand(NewApplicationHistoryCommand(clientOpts))
command.AddCommand(NewApplicationRollbackCommand(clientOpts))
command.AddCommand(NewApplicationListCommand(clientOpts))
command.AddCommand(NewApplicationDeleteCommand(clientOpts))
command.AddCommand(NewApplicationWaitCommand(clientOpts))
command.AddCommand(NewApplicationManifestsCommand(clientOpts))
command.AddCommand(NewApplicationTerminateOpCommand(clientOpts))
command.AddCommand(NewApplicationEditCommand(clientOpts))
command.AddCommand(NewApplicationPatchCommand(clientOpts))
command.AddCommand(NewApplicationPatchResourceCommand(clientOpts))
command.AddCommand(NewApplicationResourceActionsCommand(clientOpts))
return command
} | go | func NewApplicationCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "app",
Short: "Manage applications",
Example: appExample,
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
command.AddCommand(NewApplicationCreateCommand(clientOpts))
command.AddCommand(NewApplicationGetCommand(clientOpts))
command.AddCommand(NewApplicationDiffCommand(clientOpts))
command.AddCommand(NewApplicationSetCommand(clientOpts))
command.AddCommand(NewApplicationUnsetCommand(clientOpts))
command.AddCommand(NewApplicationSyncCommand(clientOpts))
command.AddCommand(NewApplicationHistoryCommand(clientOpts))
command.AddCommand(NewApplicationRollbackCommand(clientOpts))
command.AddCommand(NewApplicationListCommand(clientOpts))
command.AddCommand(NewApplicationDeleteCommand(clientOpts))
command.AddCommand(NewApplicationWaitCommand(clientOpts))
command.AddCommand(NewApplicationManifestsCommand(clientOpts))
command.AddCommand(NewApplicationTerminateOpCommand(clientOpts))
command.AddCommand(NewApplicationEditCommand(clientOpts))
command.AddCommand(NewApplicationPatchCommand(clientOpts))
command.AddCommand(NewApplicationPatchResourceCommand(clientOpts))
command.AddCommand(NewApplicationResourceActionsCommand(clientOpts))
return command
} | [
"func",
"NewApplicationCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Example",
":",
"appExample",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationCreateCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationGetCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationDiffCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationSetCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationUnsetCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationSyncCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationHistoryCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationRollbackCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationListCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationDeleteCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationWaitCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationManifestsCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationTerminateOpCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationEditCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationPatchCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationPatchResourceCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewApplicationResourceActionsCommand",
"(",
"clientOpts",
")",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationCommand returns a new instance of an `argocd app` command | [
"NewApplicationCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L62-L90 |
161,845 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationCreateCommand | func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
appOpts appOptions
fileURL string
appName string
upsert bool
)
var command = &cobra.Command{
Use: "create APPNAME",
Short: "Create an application from a git location",
Run: func(c *cobra.Command, args []string) {
var app argoappv1.Application
argocdClient := argocdclient.NewClientOrDie(clientOpts)
if fileURL != "" {
parsedURL, err := url.ParseRequestURI(fileURL)
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
err = config.UnmarshalLocalFile(fileURL, &app)
} else {
err = config.UnmarshalRemoteFile(fileURL, &app)
}
errors.CheckError(err)
if len(args) == 1 && args[0] != app.Name {
log.Fatalf("app name '%s' does not match app spec metadata.name '%s'", args[0], app.Name)
}
if appName != "" && appName != app.Name {
log.Fatalf("--name argument '%s' does not match app spec metadata.name '%s'", appName, app.Name)
}
} else {
if len(args) == 1 {
if appName != "" && appName != args[0] {
log.Fatalf("--name argument '%s' does not match app name %s", appName, args[0])
}
appName = args[0]
}
app = argoappv1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: appName,
},
}
setAppOptions(c.Flags(), &app, &appOpts)
setParameterOverrides(&app, appOpts.parameters)
}
if app.Name == "" {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdClient.NewApplicationClientOrDie()
defer util.Close(conn)
appCreateRequest := application.ApplicationCreateRequest{
Application: app,
Upsert: &upsert,
}
created, err := appIf.Create(context.Background(), &appCreateRequest)
errors.CheckError(err)
fmt.Printf("application '%s' created\n", created.ObjectMeta.Name)
},
}
command.Flags().StringVarP(&fileURL, "file", "f", "", "Filename or URL to Kubernetes manifests for the app")
command.Flags().StringVar(&appName, "name", "", "A name for the app, ignored if a file is set (DEPRECATED)")
command.Flags().BoolVar(&upsert, "upsert", false, "Allows to override application with the same name even if supplied application spec is different from existing spec")
addAppFlags(command, &appOpts)
return command
} | go | func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
appOpts appOptions
fileURL string
appName string
upsert bool
)
var command = &cobra.Command{
Use: "create APPNAME",
Short: "Create an application from a git location",
Run: func(c *cobra.Command, args []string) {
var app argoappv1.Application
argocdClient := argocdclient.NewClientOrDie(clientOpts)
if fileURL != "" {
parsedURL, err := url.ParseRequestURI(fileURL)
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
err = config.UnmarshalLocalFile(fileURL, &app)
} else {
err = config.UnmarshalRemoteFile(fileURL, &app)
}
errors.CheckError(err)
if len(args) == 1 && args[0] != app.Name {
log.Fatalf("app name '%s' does not match app spec metadata.name '%s'", args[0], app.Name)
}
if appName != "" && appName != app.Name {
log.Fatalf("--name argument '%s' does not match app spec metadata.name '%s'", appName, app.Name)
}
} else {
if len(args) == 1 {
if appName != "" && appName != args[0] {
log.Fatalf("--name argument '%s' does not match app name %s", appName, args[0])
}
appName = args[0]
}
app = argoappv1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: appName,
},
}
setAppOptions(c.Flags(), &app, &appOpts)
setParameterOverrides(&app, appOpts.parameters)
}
if app.Name == "" {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdClient.NewApplicationClientOrDie()
defer util.Close(conn)
appCreateRequest := application.ApplicationCreateRequest{
Application: app,
Upsert: &upsert,
}
created, err := appIf.Create(context.Background(), &appCreateRequest)
errors.CheckError(err)
fmt.Printf("application '%s' created\n", created.ObjectMeta.Name)
},
}
command.Flags().StringVarP(&fileURL, "file", "f", "", "Filename or URL to Kubernetes manifests for the app")
command.Flags().StringVar(&appName, "name", "", "A name for the app, ignored if a file is set (DEPRECATED)")
command.Flags().BoolVar(&upsert, "upsert", false, "Allows to override application with the same name even if supplied application spec is different from existing spec")
addAppFlags(command, &appOpts)
return command
} | [
"func",
"NewApplicationCreateCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"appOpts",
"appOptions",
"\n",
"fileURL",
"string",
"\n",
"appName",
"string",
"\n",
"upsert",
"bool",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"var",
"app",
"argoappv1",
".",
"Application",
"\n",
"argocdClient",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
"\n",
"if",
"fileURL",
"!=",
"\"",
"\"",
"{",
"parsedURL",
",",
"err",
":=",
"url",
".",
"ParseRequestURI",
"(",
"fileURL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"!",
"(",
"parsedURL",
".",
"Scheme",
"==",
"\"",
"\"",
"||",
"parsedURL",
".",
"Scheme",
"==",
"\"",
"\"",
")",
"{",
"err",
"=",
"config",
".",
"UnmarshalLocalFile",
"(",
"fileURL",
",",
"&",
"app",
")",
"\n",
"}",
"else",
"{",
"err",
"=",
"config",
".",
"UnmarshalRemoteFile",
"(",
"fileURL",
",",
"&",
"app",
")",
"\n",
"}",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"&&",
"args",
"[",
"0",
"]",
"!=",
"app",
".",
"Name",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"args",
"[",
"0",
"]",
",",
"app",
".",
"Name",
")",
"\n",
"}",
"\n",
"if",
"appName",
"!=",
"\"",
"\"",
"&&",
"appName",
"!=",
"app",
".",
"Name",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"appName",
",",
"app",
".",
"Name",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"{",
"if",
"appName",
"!=",
"\"",
"\"",
"&&",
"appName",
"!=",
"args",
"[",
"0",
"]",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"appName",
",",
"args",
"[",
"0",
"]",
")",
"\n",
"}",
"\n",
"appName",
"=",
"args",
"[",
"0",
"]",
"\n",
"}",
"\n",
"app",
"=",
"argoappv1",
".",
"Application",
"{",
"ObjectMeta",
":",
"metav1",
".",
"ObjectMeta",
"{",
"Name",
":",
"appName",
",",
"}",
",",
"}",
"\n",
"setAppOptions",
"(",
"c",
".",
"Flags",
"(",
")",
",",
"&",
"app",
",",
"&",
"appOpts",
")",
"\n",
"setParameterOverrides",
"(",
"&",
"app",
",",
"appOpts",
".",
"parameters",
")",
"\n",
"}",
"\n",
"if",
"app",
".",
"Name",
"==",
"\"",
"\"",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"conn",
",",
"appIf",
":=",
"argocdClient",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"appCreateRequest",
":=",
"application",
".",
"ApplicationCreateRequest",
"{",
"Application",
":",
"app",
",",
"Upsert",
":",
"&",
"upsert",
",",
"}",
"\n",
"created",
",",
"err",
":=",
"appIf",
".",
"Create",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"appCreateRequest",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"created",
".",
"ObjectMeta",
".",
"Name",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVarP",
"(",
"&",
"fileURL",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"appName",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"upsert",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"addAppFlags",
"(",
"command",
",",
"&",
"appOpts",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationCreateCommand returns a new instance of an `argocd app create` command | [
"NewApplicationCreateCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"create",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L93-L155 |
161,846 | argoproj/argo-cd | cmd/argocd/commands/app.go | appURL | func appURL(acdClient argocdclient.Client, appName string) string {
var scheme string
opts := acdClient.ClientOptions()
server := opts.ServerAddr
if opts.PlainText {
scheme = "http"
} else {
scheme = "https"
if strings.HasSuffix(opts.ServerAddr, ":443") {
server = server[0 : len(server)-4]
}
}
return fmt.Sprintf("%s://%s/applications/%s", scheme, server, appName)
} | go | func appURL(acdClient argocdclient.Client, appName string) string {
var scheme string
opts := acdClient.ClientOptions()
server := opts.ServerAddr
if opts.PlainText {
scheme = "http"
} else {
scheme = "https"
if strings.HasSuffix(opts.ServerAddr, ":443") {
server = server[0 : len(server)-4]
}
}
return fmt.Sprintf("%s://%s/applications/%s", scheme, server, appName)
} | [
"func",
"appURL",
"(",
"acdClient",
"argocdclient",
".",
"Client",
",",
"appName",
"string",
")",
"string",
"{",
"var",
"scheme",
"string",
"\n",
"opts",
":=",
"acdClient",
".",
"ClientOptions",
"(",
")",
"\n",
"server",
":=",
"opts",
".",
"ServerAddr",
"\n",
"if",
"opts",
".",
"PlainText",
"{",
"scheme",
"=",
"\"",
"\"",
"\n",
"}",
"else",
"{",
"scheme",
"=",
"\"",
"\"",
"\n",
"if",
"strings",
".",
"HasSuffix",
"(",
"opts",
".",
"ServerAddr",
",",
"\"",
"\"",
")",
"{",
"server",
"=",
"server",
"[",
"0",
":",
"len",
"(",
"server",
")",
"-",
"4",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"scheme",
",",
"server",
",",
"appName",
")",
"\n",
"}"
] | // appURL returns the URL of an application | [
"appURL",
"returns",
"the",
"URL",
"of",
"an",
"application"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L298-L311 |
161,847 | argoproj/argo-cd | cmd/argocd/commands/app.go | printParams | func printParams(app *argoappv1.Application, appIf application.ApplicationServiceClient) {
paramLenLimit := 80
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
if app.Spec.Source.Ksonnet != nil {
fmt.Println()
fmt.Fprintf(w, "COMPONENT\tNAME\tVALUE\n")
for _, p := range app.Spec.Source.Ksonnet.Parameters {
fmt.Fprintf(w, "%s\t%s\t%s\n", p.Component, p.Name, truncateString(p.Value, paramLenLimit))
}
} else if app.Spec.Source.Helm != nil {
fmt.Println()
fmt.Fprintf(w, "NAME\tVALUE\n")
for _, p := range app.Spec.Source.Helm.Parameters {
fmt.Fprintf(w, "%s\t%s\n", p.Name, truncateString(p.Value, paramLenLimit))
}
}
_ = w.Flush()
} | go | func printParams(app *argoappv1.Application, appIf application.ApplicationServiceClient) {
paramLenLimit := 80
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
if app.Spec.Source.Ksonnet != nil {
fmt.Println()
fmt.Fprintf(w, "COMPONENT\tNAME\tVALUE\n")
for _, p := range app.Spec.Source.Ksonnet.Parameters {
fmt.Fprintf(w, "%s\t%s\t%s\n", p.Component, p.Name, truncateString(p.Value, paramLenLimit))
}
} else if app.Spec.Source.Helm != nil {
fmt.Println()
fmt.Fprintf(w, "NAME\tVALUE\n")
for _, p := range app.Spec.Source.Helm.Parameters {
fmt.Fprintf(w, "%s\t%s\n", p.Name, truncateString(p.Value, paramLenLimit))
}
}
_ = w.Flush()
} | [
"func",
"printParams",
"(",
"app",
"*",
"argoappv1",
".",
"Application",
",",
"appIf",
"application",
".",
"ApplicationServiceClient",
")",
"{",
"paramLenLimit",
":=",
"80",
"\n",
"fmt",
".",
"Println",
"(",
")",
"\n",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"if",
"app",
".",
"Spec",
".",
"Source",
".",
"Ksonnet",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"app",
".",
"Spec",
".",
"Source",
".",
"Ksonnet",
".",
"Parameters",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"p",
".",
"Component",
",",
"p",
".",
"Name",
",",
"truncateString",
"(",
"p",
".",
"Value",
",",
"paramLenLimit",
")",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"app",
".",
"Spec",
".",
"Source",
".",
"Helm",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"app",
".",
"Spec",
".",
"Source",
".",
"Helm",
".",
"Parameters",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"p",
".",
"Name",
",",
"truncateString",
"(",
"p",
".",
"Value",
",",
"paramLenLimit",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}"
] | // printParams prints parameters and overrides | [
"printParams",
"prints",
"parameters",
"and",
"overrides"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L325-L343 |
161,848 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationSetCommand | func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
appOpts appOptions
)
var command = &cobra.Command{
Use: "set APPNAME",
Short: "Set application parameters",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
ctx := context.Background()
appName := args[0]
argocdClient := argocdclient.NewClientOrDie(clientOpts)
conn, appIf := argocdClient.NewApplicationClientOrDie()
defer util.Close(conn)
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
visited := setAppOptions(c.Flags(), app, &appOpts)
if visited == 0 {
log.Error("Please set at least one option to update")
c.HelpFunc()(c, args)
os.Exit(1)
}
setParameterOverrides(app, appOpts.parameters)
_, err = appIf.UpdateSpec(ctx, &application.ApplicationUpdateSpecRequest{
Name: &app.Name,
Spec: app.Spec,
})
errors.CheckError(err)
},
}
addAppFlags(command, &appOpts)
return command
} | go | func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
appOpts appOptions
)
var command = &cobra.Command{
Use: "set APPNAME",
Short: "Set application parameters",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
ctx := context.Background()
appName := args[0]
argocdClient := argocdclient.NewClientOrDie(clientOpts)
conn, appIf := argocdClient.NewApplicationClientOrDie()
defer util.Close(conn)
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
visited := setAppOptions(c.Flags(), app, &appOpts)
if visited == 0 {
log.Error("Please set at least one option to update")
c.HelpFunc()(c, args)
os.Exit(1)
}
setParameterOverrides(app, appOpts.parameters)
_, err = appIf.UpdateSpec(ctx, &application.ApplicationUpdateSpecRequest{
Name: &app.Name,
Spec: app.Spec,
})
errors.CheckError(err)
},
}
addAppFlags(command, &appOpts)
return command
} | [
"func",
"NewApplicationSetCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"appOpts",
"appOptions",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"argocdClient",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
"\n",
"conn",
",",
"appIf",
":=",
"argocdClient",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"app",
",",
"err",
":=",
"appIf",
".",
"Get",
"(",
"ctx",
",",
"&",
"application",
".",
"ApplicationQuery",
"{",
"Name",
":",
"&",
"appName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"visited",
":=",
"setAppOptions",
"(",
"c",
".",
"Flags",
"(",
")",
",",
"app",
",",
"&",
"appOpts",
")",
"\n",
"if",
"visited",
"==",
"0",
"{",
"log",
".",
"Error",
"(",
"\"",
"\"",
")",
"\n",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"setParameterOverrides",
"(",
"app",
",",
"appOpts",
".",
"parameters",
")",
"\n",
"_",
",",
"err",
"=",
"appIf",
".",
"UpdateSpec",
"(",
"ctx",
",",
"&",
"application",
".",
"ApplicationUpdateSpecRequest",
"{",
"Name",
":",
"&",
"app",
".",
"Name",
",",
"Spec",
":",
"app",
".",
"Spec",
",",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
",",
"}",
"\n",
"addAppFlags",
"(",
"command",
",",
"&",
"appOpts",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationSetCommand returns a new instance of an `argocd app set` command | [
"NewApplicationSetCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"set",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L346-L381 |
161,849 | argoproj/argo-cd | cmd/argocd/commands/app.go | targetObjects | func targetObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstructured, error) {
objs := make([]*unstructured.Unstructured, len(resources))
for i, resState := range resources {
obj, err := resState.TargetObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | go | func targetObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstructured, error) {
objs := make([]*unstructured.Unstructured, len(resources))
for i, resState := range resources {
obj, err := resState.TargetObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | [
"func",
"targetObjects",
"(",
"resources",
"[",
"]",
"*",
"argoappv1",
".",
"ResourceDiff",
")",
"(",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
",",
"error",
")",
"{",
"objs",
":=",
"make",
"(",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
",",
"len",
"(",
"resources",
")",
")",
"\n",
"for",
"i",
",",
"resState",
":=",
"range",
"resources",
"{",
"obj",
",",
"err",
":=",
"resState",
".",
"TargetObject",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"objs",
"[",
"i",
"]",
"=",
"obj",
"\n",
"}",
"\n",
"return",
"objs",
",",
"nil",
"\n",
"}"
] | // targetObjects deserializes the list of target states into unstructured objects | [
"targetObjects",
"deserializes",
"the",
"list",
"of",
"target",
"states",
"into",
"unstructured",
"objects"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L580-L590 |
161,850 | argoproj/argo-cd | cmd/argocd/commands/app.go | liveObjects | func liveObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstructured, error) {
objs := make([]*unstructured.Unstructured, len(resources))
for i, resState := range resources {
obj, err := resState.LiveObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | go | func liveObjects(resources []*argoappv1.ResourceDiff) ([]*unstructured.Unstructured, error) {
objs := make([]*unstructured.Unstructured, len(resources))
for i, resState := range resources {
obj, err := resState.LiveObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | [
"func",
"liveObjects",
"(",
"resources",
"[",
"]",
"*",
"argoappv1",
".",
"ResourceDiff",
")",
"(",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
",",
"error",
")",
"{",
"objs",
":=",
"make",
"(",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
",",
"len",
"(",
"resources",
")",
")",
"\n",
"for",
"i",
",",
"resState",
":=",
"range",
"resources",
"{",
"obj",
",",
"err",
":=",
"resState",
".",
"LiveObject",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"objs",
"[",
"i",
"]",
"=",
"obj",
"\n",
"}",
"\n",
"return",
"objs",
",",
"nil",
"\n",
"}"
] | // liveObjects deserializes the list of live states into unstructured objects | [
"liveObjects",
"deserializes",
"the",
"list",
"of",
"live",
"states",
"into",
"unstructured",
"objects"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L593-L603 |
161,851 | argoproj/argo-cd | cmd/argocd/commands/app.go | IsNamespaced | func (p *resourceInfoProvider) IsNamespaced(server string, obj *unstructured.Unstructured) (bool, error) {
key := kube.GetResourceKey(obj)
return p.namespacedByGk[key.GroupKind()], nil
} | go | func (p *resourceInfoProvider) IsNamespaced(server string, obj *unstructured.Unstructured) (bool, error) {
key := kube.GetResourceKey(obj)
return p.namespacedByGk[key.GroupKind()], nil
} | [
"func",
"(",
"p",
"*",
"resourceInfoProvider",
")",
"IsNamespaced",
"(",
"server",
"string",
",",
"obj",
"*",
"unstructured",
".",
"Unstructured",
")",
"(",
"bool",
",",
"error",
")",
"{",
"key",
":=",
"kube",
".",
"GetResourceKey",
"(",
"obj",
")",
"\n",
"return",
"p",
".",
"namespacedByGk",
"[",
"key",
".",
"GroupKind",
"(",
")",
"]",
",",
"nil",
"\n",
"}"
] | // Infer if obj is namespaced or not from corresponding live objects list. If corresponding live object has namespace then target object is also namespaced.
// If live object is missing then it does not matter if target is namespaced or not. | [
"Infer",
"if",
"obj",
"is",
"namespaced",
"or",
"not",
"from",
"corresponding",
"live",
"objects",
"list",
".",
"If",
"corresponding",
"live",
"object",
"has",
"namespace",
"then",
"target",
"object",
"is",
"also",
"namespaced",
".",
"If",
"live",
"object",
"is",
"missing",
"then",
"it",
"does",
"not",
"matter",
"if",
"target",
"is",
"namespaced",
"or",
"not",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L629-L632 |
161,852 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationDeleteCommand | func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
cascade bool
)
var command = &cobra.Command{
Use: "delete APPNAME",
Short: "Delete an application",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
for _, appName := range args {
appDeleteReq := application.ApplicationDeleteRequest{
Name: &appName,
}
if c.Flag("cascade").Changed {
appDeleteReq.Cascade = &cascade
}
_, err := appIf.Delete(context.Background(), &appDeleteReq)
errors.CheckError(err)
}
},
}
command.Flags().BoolVar(&cascade, "cascade", true, "Perform a cascaded deletion of all application resources")
return command
} | go | func NewApplicationDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
cascade bool
)
var command = &cobra.Command{
Use: "delete APPNAME",
Short: "Delete an application",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
for _, appName := range args {
appDeleteReq := application.ApplicationDeleteRequest{
Name: &appName,
}
if c.Flag("cascade").Changed {
appDeleteReq.Cascade = &cascade
}
_, err := appIf.Delete(context.Background(), &appDeleteReq)
errors.CheckError(err)
}
},
}
command.Flags().BoolVar(&cascade, "cascade", true, "Perform a cascaded deletion of all application resources")
return command
} | [
"func",
"NewApplicationDeleteCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"cascade",
"bool",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"conn",
",",
"appIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"for",
"_",
",",
"appName",
":=",
"range",
"args",
"{",
"appDeleteReq",
":=",
"application",
".",
"ApplicationDeleteRequest",
"{",
"Name",
":",
"&",
"appName",
",",
"}",
"\n",
"if",
"c",
".",
"Flag",
"(",
"\"",
"\"",
")",
".",
"Changed",
"{",
"appDeleteReq",
".",
"Cascade",
"=",
"&",
"cascade",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"appIf",
".",
"Delete",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"appDeleteReq",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"cascade",
",",
"\"",
"\"",
",",
"true",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationDeleteCommand returns a new instance of an `argocd app delete` command | [
"NewApplicationDeleteCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"delete",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L845-L873 |
161,853 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationListCommand | func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
output string
)
var command = &cobra.Command{
Use: "list",
Short: "List applications",
Run: func(c *cobra.Command, args []string) {
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
apps, err := appIf.List(context.Background(), &application.ApplicationQuery{})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
var fmtStr string
headers := []interface{}{"NAME", "CLUSTER", "NAMESPACE", "PROJECT", "STATUS", "HEALTH", "SYNCPOLICY", "CONDITIONS"}
if output == "wide" {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
headers = append(headers, "REPO", "PATH", "TARGET")
} else {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
}
fmt.Fprintf(w, fmtStr, headers...)
for _, app := range apps.Items {
vals := []interface{}{
app.Name,
app.Spec.Destination.Server,
app.Spec.Destination.Namespace,
app.Spec.GetProject(),
app.Status.Sync.Status,
app.Status.Health.Status,
formatSyncPolicy(app),
formatConditionsSummary(app),
}
if output == "wide" {
vals = append(vals, app.Spec.Source.RepoURL, app.Spec.Source.Path, app.Spec.Source.TargetRevision)
}
fmt.Fprintf(w, fmtStr, vals...)
}
_ = w.Flush()
},
}
command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: wide")
return command
} | go | func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
output string
)
var command = &cobra.Command{
Use: "list",
Short: "List applications",
Run: func(c *cobra.Command, args []string) {
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
apps, err := appIf.List(context.Background(), &application.ApplicationQuery{})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
var fmtStr string
headers := []interface{}{"NAME", "CLUSTER", "NAMESPACE", "PROJECT", "STATUS", "HEALTH", "SYNCPOLICY", "CONDITIONS"}
if output == "wide" {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
headers = append(headers, "REPO", "PATH", "TARGET")
} else {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
}
fmt.Fprintf(w, fmtStr, headers...)
for _, app := range apps.Items {
vals := []interface{}{
app.Name,
app.Spec.Destination.Server,
app.Spec.Destination.Namespace,
app.Spec.GetProject(),
app.Status.Sync.Status,
app.Status.Health.Status,
formatSyncPolicy(app),
formatConditionsSummary(app),
}
if output == "wide" {
vals = append(vals, app.Spec.Source.RepoURL, app.Spec.Source.Path, app.Spec.Source.TargetRevision)
}
fmt.Fprintf(w, fmtStr, vals...)
}
_ = w.Flush()
},
}
command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: wide")
return command
} | [
"func",
"NewApplicationListCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"output",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"conn",
",",
"appIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"apps",
",",
"err",
":=",
"appIf",
".",
"List",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"application",
".",
"ApplicationQuery",
"{",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"var",
"fmtStr",
"string",
"\n",
"headers",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"\n",
"if",
"output",
"==",
"\"",
"\"",
"{",
"fmtStr",
"=",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
"\n",
"headers",
"=",
"append",
"(",
"headers",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"}",
"else",
"{",
"fmtStr",
"=",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"fmtStr",
",",
"headers",
"...",
")",
"\n",
"for",
"_",
",",
"app",
":=",
"range",
"apps",
".",
"Items",
"{",
"vals",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"app",
".",
"Name",
",",
"app",
".",
"Spec",
".",
"Destination",
".",
"Server",
",",
"app",
".",
"Spec",
".",
"Destination",
".",
"Namespace",
",",
"app",
".",
"Spec",
".",
"GetProject",
"(",
")",
",",
"app",
".",
"Status",
".",
"Sync",
".",
"Status",
",",
"app",
".",
"Status",
".",
"Health",
".",
"Status",
",",
"formatSyncPolicy",
"(",
"app",
")",
",",
"formatConditionsSummary",
"(",
"app",
")",
",",
"}",
"\n",
"if",
"output",
"==",
"\"",
"\"",
"{",
"vals",
"=",
"append",
"(",
"vals",
",",
"app",
".",
"Spec",
".",
"Source",
".",
"RepoURL",
",",
"app",
".",
"Spec",
".",
"Source",
".",
"Path",
",",
"app",
".",
"Spec",
".",
"Source",
".",
"TargetRevision",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"fmtStr",
",",
"vals",
"...",
")",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVarP",
"(",
"&",
"output",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationListCommand returns a new instance of an `argocd app list` command | [
"NewApplicationListCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"list",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L876-L919 |
161,854 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationWaitCommand | func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
watchSync bool
watchHealth bool
watchSuspended bool
watchOperations bool
timeout uint
resources []string
)
var command = &cobra.Command{
Use: "wait APPNAME",
Short: "Wait for an application to reach a synced and healthy state",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
if !watchSync && !watchHealth && !watchOperations && !watchSuspended {
watchSync = true
watchHealth = true
watchOperations = true
watchSuspended = false
}
selectedResources := parseSelectedResources(resources)
appName := args[0]
acdClient := argocdclient.NewClientOrDie(clientOpts)
_, err := waitOnApplicationStatus(acdClient, appName, timeout, watchSync, watchHealth, watchOperations, watchSuspended, selectedResources)
errors.CheckError(err)
},
}
command.Flags().BoolVar(&watchSync, "sync", false, "Wait for sync")
command.Flags().BoolVar(&watchHealth, "health", false, "Wait for health")
command.Flags().BoolVar(&watchSuspended, "suspended", false, "Wait for suspended")
command.Flags().StringArrayVar(&resources, "resource", []string{}, fmt.Sprintf("Sync only specific resources as GROUP%sKIND%sNAME. Fields may be blank. This option may be specified repeatedly", resourceFieldDelimiter, resourceFieldDelimiter))
command.Flags().BoolVar(&watchOperations, "operation", false, "Wait for pending operations")
command.Flags().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds")
return command
} | go | func NewApplicationWaitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
watchSync bool
watchHealth bool
watchSuspended bool
watchOperations bool
timeout uint
resources []string
)
var command = &cobra.Command{
Use: "wait APPNAME",
Short: "Wait for an application to reach a synced and healthy state",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
if !watchSync && !watchHealth && !watchOperations && !watchSuspended {
watchSync = true
watchHealth = true
watchOperations = true
watchSuspended = false
}
selectedResources := parseSelectedResources(resources)
appName := args[0]
acdClient := argocdclient.NewClientOrDie(clientOpts)
_, err := waitOnApplicationStatus(acdClient, appName, timeout, watchSync, watchHealth, watchOperations, watchSuspended, selectedResources)
errors.CheckError(err)
},
}
command.Flags().BoolVar(&watchSync, "sync", false, "Wait for sync")
command.Flags().BoolVar(&watchHealth, "health", false, "Wait for health")
command.Flags().BoolVar(&watchSuspended, "suspended", false, "Wait for suspended")
command.Flags().StringArrayVar(&resources, "resource", []string{}, fmt.Sprintf("Sync only specific resources as GROUP%sKIND%sNAME. Fields may be blank. This option may be specified repeatedly", resourceFieldDelimiter, resourceFieldDelimiter))
command.Flags().BoolVar(&watchOperations, "operation", false, "Wait for pending operations")
command.Flags().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds")
return command
} | [
"func",
"NewApplicationWaitCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"watchSync",
"bool",
"\n",
"watchHealth",
"bool",
"\n",
"watchSuspended",
"bool",
"\n",
"watchOperations",
"bool",
"\n",
"timeout",
"uint",
"\n",
"resources",
"[",
"]",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"if",
"!",
"watchSync",
"&&",
"!",
"watchHealth",
"&&",
"!",
"watchOperations",
"&&",
"!",
"watchSuspended",
"{",
"watchSync",
"=",
"true",
"\n",
"watchHealth",
"=",
"true",
"\n",
"watchOperations",
"=",
"true",
"\n",
"watchSuspended",
"=",
"false",
"\n",
"}",
"\n",
"selectedResources",
":=",
"parseSelectedResources",
"(",
"resources",
")",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"acdClient",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
"\n",
"_",
",",
"err",
":=",
"waitOnApplicationStatus",
"(",
"acdClient",
",",
"appName",
",",
"timeout",
",",
"watchSync",
",",
"watchHealth",
",",
"watchOperations",
",",
"watchSuspended",
",",
"selectedResources",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"watchSync",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"watchHealth",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"watchSuspended",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringArrayVar",
"(",
"&",
"resources",
",",
"\"",
"\"",
",",
"[",
"]",
"string",
"{",
"}",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"resourceFieldDelimiter",
",",
"resourceFieldDelimiter",
")",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"watchOperations",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"UintVar",
"(",
"&",
"timeout",
",",
"\"",
"\"",
",",
"defaultCheckTimeoutSeconds",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationWaitCommand returns a new instance of an `argocd app wait` command | [
"NewApplicationWaitCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"wait",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L999-L1036 |
161,855 | argoproj/argo-cd | cmd/argocd/commands/app.go | printAppResources | func printAppResources(w io.Writer, app *argoappv1.Application, showOperation bool) {
messages := make(map[string]string)
opState := app.Status.OperationState
var syncRes *argoappv1.SyncOperationResult
if showOperation {
fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tSTATUS\tHEALTH\tHOOK\tMESSAGE\n")
if opState != nil {
if opState.SyncResult != nil {
syncRes = opState.SyncResult
}
}
if syncRes != nil {
for _, res := range syncRes.Resources {
if !res.IsHook() {
messages[fmt.Sprintf("%s/%s/%s/%s", res.Group, res.Kind, res.Namespace, res.Name)] = res.Message
} else if res.HookType == argoappv1.HookTypePreSync {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", res.Group, res.Kind, res.Namespace, res.Name, res.HookPhase, "", res.HookType, res.Message)
}
}
}
} else {
fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tSTATUS\tHEALTH\n")
}
for _, res := range app.Status.Resources {
healthStatus := ""
if res.Health != nil {
healthStatus = res.Health.Status
}
if showOperation {
message := messages[fmt.Sprintf("%s/%s/%s/%s", res.Group, res.Kind, res.Namespace, res.Name)]
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", res.Group, res.Kind, res.Namespace, res.Name, res.Status, healthStatus, "", message)
} else {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s", res.Group, res.Kind, res.Namespace, res.Name, res.Status, healthStatus)
}
fmt.Fprint(w, "\n")
}
if showOperation && syncRes != nil {
for _, res := range syncRes.Resources {
if res.HookType == argoappv1.HookTypeSync || res.HookType == argoappv1.HookTypePostSync {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", res.Group, res.Kind, res.Namespace, res.Name, res.HookPhase, "", res.HookType, res.Message)
}
}
}
} | go | func printAppResources(w io.Writer, app *argoappv1.Application, showOperation bool) {
messages := make(map[string]string)
opState := app.Status.OperationState
var syncRes *argoappv1.SyncOperationResult
if showOperation {
fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tSTATUS\tHEALTH\tHOOK\tMESSAGE\n")
if opState != nil {
if opState.SyncResult != nil {
syncRes = opState.SyncResult
}
}
if syncRes != nil {
for _, res := range syncRes.Resources {
if !res.IsHook() {
messages[fmt.Sprintf("%s/%s/%s/%s", res.Group, res.Kind, res.Namespace, res.Name)] = res.Message
} else if res.HookType == argoappv1.HookTypePreSync {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", res.Group, res.Kind, res.Namespace, res.Name, res.HookPhase, "", res.HookType, res.Message)
}
}
}
} else {
fmt.Fprintf(w, "GROUP\tKIND\tNAMESPACE\tNAME\tSTATUS\tHEALTH\n")
}
for _, res := range app.Status.Resources {
healthStatus := ""
if res.Health != nil {
healthStatus = res.Health.Status
}
if showOperation {
message := messages[fmt.Sprintf("%s/%s/%s/%s", res.Group, res.Kind, res.Namespace, res.Name)]
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", res.Group, res.Kind, res.Namespace, res.Name, res.Status, healthStatus, "", message)
} else {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s", res.Group, res.Kind, res.Namespace, res.Name, res.Status, healthStatus)
}
fmt.Fprint(w, "\n")
}
if showOperation && syncRes != nil {
for _, res := range syncRes.Resources {
if res.HookType == argoappv1.HookTypeSync || res.HookType == argoappv1.HookTypePostSync {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", res.Group, res.Kind, res.Namespace, res.Name, res.HookPhase, "", res.HookType, res.Message)
}
}
}
} | [
"func",
"printAppResources",
"(",
"w",
"io",
".",
"Writer",
",",
"app",
"*",
"argoappv1",
".",
"Application",
",",
"showOperation",
"bool",
")",
"{",
"messages",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"opState",
":=",
"app",
".",
"Status",
".",
"OperationState",
"\n",
"var",
"syncRes",
"*",
"argoappv1",
".",
"SyncOperationResult",
"\n\n",
"if",
"showOperation",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"if",
"opState",
"!=",
"nil",
"{",
"if",
"opState",
".",
"SyncResult",
"!=",
"nil",
"{",
"syncRes",
"=",
"opState",
".",
"SyncResult",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"syncRes",
"!=",
"nil",
"{",
"for",
"_",
",",
"res",
":=",
"range",
"syncRes",
".",
"Resources",
"{",
"if",
"!",
"res",
".",
"IsHook",
"(",
")",
"{",
"messages",
"[",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
")",
"]",
"=",
"res",
".",
"Message",
"\n",
"}",
"else",
"if",
"res",
".",
"HookType",
"==",
"argoappv1",
".",
"HookTypePreSync",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
",",
"res",
".",
"HookPhase",
",",
"\"",
"\"",
",",
"res",
".",
"HookType",
",",
"res",
".",
"Message",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"for",
"_",
",",
"res",
":=",
"range",
"app",
".",
"Status",
".",
"Resources",
"{",
"healthStatus",
":=",
"\"",
"\"",
"\n",
"if",
"res",
".",
"Health",
"!=",
"nil",
"{",
"healthStatus",
"=",
"res",
".",
"Health",
".",
"Status",
"\n",
"}",
"\n",
"if",
"showOperation",
"{",
"message",
":=",
"messages",
"[",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
")",
"]",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
",",
"res",
".",
"Status",
",",
"healthStatus",
",",
"\"",
"\"",
",",
"message",
")",
"\n",
"}",
"else",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
",",
"res",
".",
"Status",
",",
"healthStatus",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprint",
"(",
"w",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"}",
"\n",
"if",
"showOperation",
"&&",
"syncRes",
"!=",
"nil",
"{",
"for",
"_",
",",
"res",
":=",
"range",
"syncRes",
".",
"Resources",
"{",
"if",
"res",
".",
"HookType",
"==",
"argoappv1",
".",
"HookTypeSync",
"||",
"res",
".",
"HookType",
"==",
"argoappv1",
".",
"HookTypePostSync",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
",",
"res",
".",
"Group",
",",
"res",
".",
"Kind",
",",
"res",
".",
"Namespace",
",",
"res",
".",
"Name",
",",
"res",
".",
"HookPhase",
",",
"\"",
"\"",
",",
"res",
".",
"HookType",
",",
"res",
".",
"Message",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"}",
"\n",
"}"
] | // printAppResources prints the resources of an application in a tabwriter table
// Optionally prints the message from the operation state | [
"printAppResources",
"prints",
"the",
"resources",
"of",
"an",
"application",
"in",
"a",
"tabwriter",
"table",
"Optionally",
"prints",
"the",
"message",
"from",
"the",
"operation",
"state"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1040-L1085 |
161,856 | argoproj/argo-cd | cmd/argocd/commands/app.go | Key | func (rs *resourceState) Key() string {
return fmt.Sprintf("%s/%s/%s/%s", rs.Group, rs.Kind, rs.Namespace, rs.Name)
} | go | func (rs *resourceState) Key() string {
return fmt.Sprintf("%s/%s/%s/%s", rs.Group, rs.Kind, rs.Namespace, rs.Name)
} | [
"func",
"(",
"rs",
"*",
"resourceState",
")",
"Key",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rs",
".",
"Group",
",",
"rs",
".",
"Kind",
",",
"rs",
".",
"Namespace",
",",
"rs",
".",
"Name",
")",
"\n",
"}"
] | // Key returns a unique-ish key for the resource. | [
"Key",
"returns",
"a",
"unique",
"-",
"ish",
"key",
"for",
"the",
"resource",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1249-L1251 |
161,857 | argoproj/argo-cd | cmd/argocd/commands/app.go | Merge | func (rs *resourceState) Merge(newState *resourceState) bool {
updated := false
for _, field := range []string{"Status", "Health", "Hook", "Message"} {
v := reflect.ValueOf(rs).Elem().FieldByName(field)
currVal := v.String()
newVal := reflect.ValueOf(newState).Elem().FieldByName(field).String()
if newVal != "" && currVal != newVal {
v.SetString(newVal)
updated = true
}
}
return updated
} | go | func (rs *resourceState) Merge(newState *resourceState) bool {
updated := false
for _, field := range []string{"Status", "Health", "Hook", "Message"} {
v := reflect.ValueOf(rs).Elem().FieldByName(field)
currVal := v.String()
newVal := reflect.ValueOf(newState).Elem().FieldByName(field).String()
if newVal != "" && currVal != newVal {
v.SetString(newVal)
updated = true
}
}
return updated
} | [
"func",
"(",
"rs",
"*",
"resourceState",
")",
"Merge",
"(",
"newState",
"*",
"resourceState",
")",
"bool",
"{",
"updated",
":=",
"false",
"\n",
"for",
"_",
",",
"field",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"rs",
")",
".",
"Elem",
"(",
")",
".",
"FieldByName",
"(",
"field",
")",
"\n",
"currVal",
":=",
"v",
".",
"String",
"(",
")",
"\n",
"newVal",
":=",
"reflect",
".",
"ValueOf",
"(",
"newState",
")",
".",
"Elem",
"(",
")",
".",
"FieldByName",
"(",
"field",
")",
".",
"String",
"(",
")",
"\n",
"if",
"newVal",
"!=",
"\"",
"\"",
"&&",
"currVal",
"!=",
"newVal",
"{",
"v",
".",
"SetString",
"(",
"newVal",
")",
"\n",
"updated",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"updated",
"\n",
"}"
] | // Merge merges the new state with any different contents from another resourceState.
// Blank fields in the receiver state will be updated to non-blank.
// Non-blank fields in the receiver state will never be updated to blank.
// Returns whether or not any keys were updated. | [
"Merge",
"merges",
"the",
"new",
"state",
"with",
"any",
"different",
"contents",
"from",
"another",
"resourceState",
".",
"Blank",
"fields",
"in",
"the",
"receiver",
"state",
"will",
"be",
"updated",
"to",
"non",
"-",
"blank",
".",
"Non",
"-",
"blank",
"fields",
"in",
"the",
"receiver",
"state",
"will",
"never",
"be",
"updated",
"to",
"blank",
".",
"Returns",
"whether",
"or",
"not",
"any",
"keys",
"were",
"updated",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1262-L1274 |
161,858 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationHistoryCommand | func NewApplicationHistoryCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
output string
)
var command = &cobra.Command{
Use: "history APPNAME",
Short: "Show application deployment history",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
appName := args[0]
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ID\tDATE\tREVISION\n")
for _, depInfo := range app.Status.History {
rev := depInfo.Source.TargetRevision
if len(depInfo.Revision) >= 7 {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revision[0:7])
}
fmt.Fprintf(w, "%d\t%s\t%s\n", depInfo.ID, depInfo.DeployedAt, rev)
}
_ = w.Flush()
},
}
command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: wide")
return command
} | go | func NewApplicationHistoryCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
output string
)
var command = &cobra.Command{
Use: "history APPNAME",
Short: "Show application deployment history",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
appName := args[0]
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ID\tDATE\tREVISION\n")
for _, depInfo := range app.Status.History {
rev := depInfo.Source.TargetRevision
if len(depInfo.Revision) >= 7 {
rev = fmt.Sprintf("%s (%s)", rev, depInfo.Revision[0:7])
}
fmt.Fprintf(w, "%d\t%s\t%s\n", depInfo.ID, depInfo.DeployedAt, rev)
}
_ = w.Flush()
},
}
command.Flags().StringVarP(&output, "output", "o", "", "Output format. One of: wide")
return command
} | [
"func",
"NewApplicationHistoryCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"output",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"conn",
",",
"appIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"app",
",",
"err",
":=",
"appIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"application",
".",
"ApplicationQuery",
"{",
"Name",
":",
"&",
"appName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"depInfo",
":=",
"range",
"app",
".",
"Status",
".",
"History",
"{",
"rev",
":=",
"depInfo",
".",
"Source",
".",
"TargetRevision",
"\n",
"if",
"len",
"(",
"depInfo",
".",
"Revision",
")",
">=",
"7",
"{",
"rev",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"rev",
",",
"depInfo",
".",
"Revision",
"[",
"0",
":",
"7",
"]",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"depInfo",
".",
"ID",
",",
"depInfo",
".",
"DeployedAt",
",",
"rev",
")",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVarP",
"(",
"&",
"output",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationHistoryCommand returns a new instance of an `argocd app history` command | [
"NewApplicationHistoryCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"history",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1523-L1554 |
161,859 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationRollbackCommand | func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
prune bool
timeout uint
)
var command = &cobra.Command{
Use: "rollback APPNAME ID",
Short: "Rollback application to a previous deployed version by History ID",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
depID, err := strconv.Atoi(args[1])
errors.CheckError(err)
acdClient := argocdclient.NewClientOrDie(clientOpts)
conn, appIf := acdClient.NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
var depInfo *argoappv1.RevisionHistory
for _, di := range app.Status.History {
if di.ID == int64(depID) {
depInfo = &di
break
}
}
if depInfo == nil {
log.Fatalf("Application '%s' does not have deployment id '%d' in history\n", app.ObjectMeta.Name, depID)
}
_, err = appIf.Rollback(ctx, &application.ApplicationRollbackRequest{
Name: &appName,
ID: int64(depID),
Prune: prune,
})
errors.CheckError(err)
_, err = waitOnApplicationStatus(acdClient, appName, timeout, false, false, true, false, nil)
errors.CheckError(err)
},
}
command.Flags().BoolVar(&prune, "prune", false, "Allow deleting unexpected resources")
command.Flags().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds")
return command
} | go | func NewApplicationRollbackCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
prune bool
timeout uint
)
var command = &cobra.Command{
Use: "rollback APPNAME ID",
Short: "Rollback application to a previous deployed version by History ID",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
depID, err := strconv.Atoi(args[1])
errors.CheckError(err)
acdClient := argocdclient.NewClientOrDie(clientOpts)
conn, appIf := acdClient.NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
app, err := appIf.Get(ctx, &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
var depInfo *argoappv1.RevisionHistory
for _, di := range app.Status.History {
if di.ID == int64(depID) {
depInfo = &di
break
}
}
if depInfo == nil {
log.Fatalf("Application '%s' does not have deployment id '%d' in history\n", app.ObjectMeta.Name, depID)
}
_, err = appIf.Rollback(ctx, &application.ApplicationRollbackRequest{
Name: &appName,
ID: int64(depID),
Prune: prune,
})
errors.CheckError(err)
_, err = waitOnApplicationStatus(acdClient, appName, timeout, false, false, true, false, nil)
errors.CheckError(err)
},
}
command.Flags().BoolVar(&prune, "prune", false, "Allow deleting unexpected resources")
command.Flags().UintVar(&timeout, "timeout", defaultCheckTimeoutSeconds, "Time out after this many seconds")
return command
} | [
"func",
"NewApplicationRollbackCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"prune",
"bool",
"\n",
"timeout",
"uint",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"depID",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"args",
"[",
"1",
"]",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"acdClient",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
"\n",
"conn",
",",
"appIf",
":=",
"acdClient",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"app",
",",
"err",
":=",
"appIf",
".",
"Get",
"(",
"ctx",
",",
"&",
"application",
".",
"ApplicationQuery",
"{",
"Name",
":",
"&",
"appName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"var",
"depInfo",
"*",
"argoappv1",
".",
"RevisionHistory",
"\n",
"for",
"_",
",",
"di",
":=",
"range",
"app",
".",
"Status",
".",
"History",
"{",
"if",
"di",
".",
"ID",
"==",
"int64",
"(",
"depID",
")",
"{",
"depInfo",
"=",
"&",
"di",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"depInfo",
"==",
"nil",
"{",
"log",
".",
"Fatalf",
"(",
"\"",
"\\n",
"\"",
",",
"app",
".",
"ObjectMeta",
".",
"Name",
",",
"depID",
")",
"\n",
"}",
"\n\n",
"_",
",",
"err",
"=",
"appIf",
".",
"Rollback",
"(",
"ctx",
",",
"&",
"application",
".",
"ApplicationRollbackRequest",
"{",
"Name",
":",
"&",
"appName",
",",
"ID",
":",
"int64",
"(",
"depID",
")",
",",
"Prune",
":",
"prune",
",",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"_",
",",
"err",
"=",
"waitOnApplicationStatus",
"(",
"acdClient",
",",
"appName",
",",
"timeout",
",",
"false",
",",
"false",
",",
"true",
",",
"false",
",",
"nil",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"BoolVar",
"(",
"&",
"prune",
",",
"\"",
"\"",
",",
"false",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"UintVar",
"(",
"&",
"timeout",
",",
"\"",
"\"",
",",
"defaultCheckTimeoutSeconds",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationRollbackCommand returns a new instance of an `argocd app rollback` command | [
"NewApplicationRollbackCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"rollback",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1557-L1604 |
161,860 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationManifestsCommand | func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
source string
revision string
)
var command = &cobra.Command{
Use: "manifests APPNAME",
Short: "Print manifests of an application",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
resources, err := appIf.ManagedResources(context.Background(), &application.ResourcesQuery{ApplicationName: &appName})
errors.CheckError(err)
var unstructureds []*unstructured.Unstructured
switch source {
case "git":
if revision != "" {
q := application.ApplicationManifestQuery{
Name: &appName,
Revision: revision,
}
res, err := appIf.GetManifests(ctx, &q)
errors.CheckError(err)
for _, mfst := range res.Manifests {
obj, err := argoappv1.UnmarshalToUnstructured(mfst)
errors.CheckError(err)
unstructureds = append(unstructureds, obj)
}
} else {
targetObjs, err := targetObjects(resources.Items)
errors.CheckError(err)
unstructureds = targetObjs
}
case "live":
liveObjs, err := liveObjects(resources.Items)
errors.CheckError(err)
unstructureds = liveObjs
default:
log.Fatalf("Unknown source type '%s'", source)
}
for _, obj := range unstructureds {
fmt.Println("---")
yamlBytes, err := yaml.Marshal(obj)
errors.CheckError(err)
fmt.Printf("%s\n", yamlBytes)
}
},
}
command.Flags().StringVar(&source, "source", "git", "Source of manifests. One of: live|git")
command.Flags().StringVar(&revision, "revision", "", "Show manifests at a specific revision")
return command
} | go | func NewApplicationManifestsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
source string
revision string
)
var command = &cobra.Command{
Use: "manifests APPNAME",
Short: "Print manifests of an application",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
resources, err := appIf.ManagedResources(context.Background(), &application.ResourcesQuery{ApplicationName: &appName})
errors.CheckError(err)
var unstructureds []*unstructured.Unstructured
switch source {
case "git":
if revision != "" {
q := application.ApplicationManifestQuery{
Name: &appName,
Revision: revision,
}
res, err := appIf.GetManifests(ctx, &q)
errors.CheckError(err)
for _, mfst := range res.Manifests {
obj, err := argoappv1.UnmarshalToUnstructured(mfst)
errors.CheckError(err)
unstructureds = append(unstructureds, obj)
}
} else {
targetObjs, err := targetObjects(resources.Items)
errors.CheckError(err)
unstructureds = targetObjs
}
case "live":
liveObjs, err := liveObjects(resources.Items)
errors.CheckError(err)
unstructureds = liveObjs
default:
log.Fatalf("Unknown source type '%s'", source)
}
for _, obj := range unstructureds {
fmt.Println("---")
yamlBytes, err := yaml.Marshal(obj)
errors.CheckError(err)
fmt.Printf("%s\n", yamlBytes)
}
},
}
command.Flags().StringVar(&source, "source", "git", "Source of manifests. One of: live|git")
command.Flags().StringVar(&revision, "revision", "", "Show manifests at a specific revision")
return command
} | [
"func",
"NewApplicationManifestsCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"source",
"string",
"\n",
"revision",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"conn",
",",
"appIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"resources",
",",
"err",
":=",
"appIf",
".",
"ManagedResources",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"application",
".",
"ResourcesQuery",
"{",
"ApplicationName",
":",
"&",
"appName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"var",
"unstructureds",
"[",
"]",
"*",
"unstructured",
".",
"Unstructured",
"\n",
"switch",
"source",
"{",
"case",
"\"",
"\"",
":",
"if",
"revision",
"!=",
"\"",
"\"",
"{",
"q",
":=",
"application",
".",
"ApplicationManifestQuery",
"{",
"Name",
":",
"&",
"appName",
",",
"Revision",
":",
"revision",
",",
"}",
"\n",
"res",
",",
"err",
":=",
"appIf",
".",
"GetManifests",
"(",
"ctx",
",",
"&",
"q",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"for",
"_",
",",
"mfst",
":=",
"range",
"res",
".",
"Manifests",
"{",
"obj",
",",
"err",
":=",
"argoappv1",
".",
"UnmarshalToUnstructured",
"(",
"mfst",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"unstructureds",
"=",
"append",
"(",
"unstructureds",
",",
"obj",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"targetObjs",
",",
"err",
":=",
"targetObjects",
"(",
"resources",
".",
"Items",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"unstructureds",
"=",
"targetObjs",
"\n",
"}",
"\n",
"case",
"\"",
"\"",
":",
"liveObjs",
",",
"err",
":=",
"liveObjects",
"(",
"resources",
".",
"Items",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"unstructureds",
"=",
"liveObjs",
"\n",
"default",
":",
"log",
".",
"Fatalf",
"(",
"\"",
"\"",
",",
"source",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"obj",
":=",
"range",
"unstructureds",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"yamlBytes",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"obj",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"yamlBytes",
")",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"source",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVar",
"(",
"&",
"revision",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationManifestsCommand returns a new instance of an `argocd app manifests` command | [
"NewApplicationManifestsCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"manifests",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1633-L1692 |
161,861 | argoproj/argo-cd | cmd/argocd/commands/app.go | NewApplicationTerminateOpCommand | func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "terminate-op APPNAME",
Short: "Terminate running operation of an application",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
_, err := appIf.TerminateOperation(ctx, &application.OperationTerminateRequest{Name: &appName})
errors.CheckError(err)
fmt.Printf("Application '%s' operation terminating\n", appName)
},
}
return command
} | go | func NewApplicationTerminateOpCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "terminate-op APPNAME",
Short: "Terminate running operation of an application",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
appName := args[0]
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
ctx := context.Background()
_, err := appIf.TerminateOperation(ctx, &application.OperationTerminateRequest{Name: &appName})
errors.CheckError(err)
fmt.Printf("Application '%s' operation terminating\n", appName)
},
}
return command
} | [
"func",
"NewApplicationTerminateOpCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"appName",
":=",
"args",
"[",
"0",
"]",
"\n",
"conn",
",",
"appIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewApplicationClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"appIf",
".",
"TerminateOperation",
"(",
"ctx",
",",
"&",
"application",
".",
"OperationTerminateRequest",
"{",
"Name",
":",
"&",
"appName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"appName",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewApplicationTerminateOpCommand returns a new instance of an `argocd app terminate-op` command | [
"NewApplicationTerminateOpCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"app",
"terminate",
"-",
"op",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/app.go#L1695-L1714 |
161,862 | argoproj/argo-cd | cmd/argocd/commands/cluster.go | NewClusterCommand | func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
var command = &cobra.Command{
Use: "cluster",
Short: "Manage cluster credentials",
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
command.AddCommand(NewClusterAddCommand(clientOpts, pathOpts))
command.AddCommand(NewClusterGetCommand(clientOpts))
command.AddCommand(NewClusterListCommand(clientOpts))
command.AddCommand(NewClusterRemoveCommand(clientOpts))
return command
} | go | func NewClusterCommand(clientOpts *argocdclient.ClientOptions, pathOpts *clientcmd.PathOptions) *cobra.Command {
var command = &cobra.Command{
Use: "cluster",
Short: "Manage cluster credentials",
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
command.AddCommand(NewClusterAddCommand(clientOpts, pathOpts))
command.AddCommand(NewClusterGetCommand(clientOpts))
command.AddCommand(NewClusterListCommand(clientOpts))
command.AddCommand(NewClusterRemoveCommand(clientOpts))
return command
} | [
"func",
"NewClusterCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
",",
"pathOpts",
"*",
"clientcmd",
".",
"PathOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
",",
"}",
"\n\n",
"command",
".",
"AddCommand",
"(",
"NewClusterAddCommand",
"(",
"clientOpts",
",",
"pathOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewClusterGetCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewClusterListCommand",
"(",
"clientOpts",
")",
")",
"\n",
"command",
".",
"AddCommand",
"(",
"NewClusterRemoveCommand",
"(",
"clientOpts",
")",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewClusterCommand returns a new instance of an `argocd cluster` command | [
"NewClusterCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"cluster",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/cluster.go#L28-L43 |
161,863 | argoproj/argo-cd | cmd/argocd/commands/cluster.go | NewClusterGetCommand | func NewClusterGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "get",
Short: "Get cluster information",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
for _, clusterName := range args {
clst, err := clusterIf.Get(context.Background(), &cluster.ClusterQuery{Server: clusterName})
errors.CheckError(err)
yamlBytes, err := yaml.Marshal(clst)
errors.CheckError(err)
fmt.Printf("%v", string(yamlBytes))
}
},
}
return command
} | go | func NewClusterGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "get",
Short: "Get cluster information",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
for _, clusterName := range args {
clst, err := clusterIf.Get(context.Background(), &cluster.ClusterQuery{Server: clusterName})
errors.CheckError(err)
yamlBytes, err := yaml.Marshal(clst)
errors.CheckError(err)
fmt.Printf("%v", string(yamlBytes))
}
},
}
return command
} | [
"func",
"NewClusterGetCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"conn",
",",
"clusterIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewClusterClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"for",
"_",
",",
"clusterName",
":=",
"range",
"args",
"{",
"clst",
",",
"err",
":=",
"clusterIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"cluster",
".",
"ClusterQuery",
"{",
"Server",
":",
"clusterName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"yamlBytes",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"clst",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\"",
",",
"string",
"(",
"yamlBytes",
")",
")",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewClusterGetCommand returns a new instance of an `argocd cluster get` command | [
"NewClusterGetCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"cluster",
"get",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/cluster.go#L189-L210 |
161,864 | argoproj/argo-cd | cmd/argocd/commands/cluster.go | NewClusterRemoveCommand | func NewClusterRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "rm",
Short: "Remove cluster credentials",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
// clientset, err := kubernetes.NewForConfig(conf)
// errors.CheckError(err)
for _, clusterName := range args {
// TODO(jessesuen): find the right context and remove manager RBAC artifacts
// err := common.UninstallClusterManagerRBAC(clientset)
// errors.CheckError(err)
_, err := clusterIf.Delete(context.Background(), &cluster.ClusterQuery{Server: clusterName})
errors.CheckError(err)
}
},
}
return command
} | go | func NewClusterRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "rm",
Short: "Remove cluster credentials",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
os.Exit(1)
}
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
// clientset, err := kubernetes.NewForConfig(conf)
// errors.CheckError(err)
for _, clusterName := range args {
// TODO(jessesuen): find the right context and remove manager RBAC artifacts
// err := common.UninstallClusterManagerRBAC(clientset)
// errors.CheckError(err)
_, err := clusterIf.Delete(context.Background(), &cluster.ClusterQuery{Server: clusterName})
errors.CheckError(err)
}
},
}
return command
} | [
"func",
"NewClusterRemoveCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"conn",
",",
"clusterIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewClusterClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"// clientset, err := kubernetes.NewForConfig(conf)",
"// errors.CheckError(err)",
"for",
"_",
",",
"clusterName",
":=",
"range",
"args",
"{",
"// TODO(jessesuen): find the right context and remove manager RBAC artifacts",
"// err := common.UninstallClusterManagerRBAC(clientset)",
"// errors.CheckError(err)",
"_",
",",
"err",
":=",
"clusterIf",
".",
"Delete",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"cluster",
".",
"ClusterQuery",
"{",
"Server",
":",
"clusterName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewClusterRemoveCommand returns a new instance of an `argocd cluster list` command | [
"NewClusterRemoveCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"cluster",
"list",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/cluster.go#L213-L238 |
161,865 | argoproj/argo-cd | cmd/argocd/commands/cluster.go | NewClusterListCommand | func NewClusterListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "list",
Short: "List configured clusters",
Run: func(c *cobra.Command, args []string) {
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
clusters, err := clusterIf.List(context.Background(), &cluster.ClusterQuery{})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "SERVER\tNAME\tSTATUS\tMESSAGE\n")
for _, c := range clusters.Items {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", c.Server, c.Name, c.ConnectionState.Status, c.ConnectionState.Message)
}
_ = w.Flush()
},
}
return command
} | go | func NewClusterListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "list",
Short: "List configured clusters",
Run: func(c *cobra.Command, args []string) {
conn, clusterIf := argocdclient.NewClientOrDie(clientOpts).NewClusterClientOrDie()
defer util.Close(conn)
clusters, err := clusterIf.List(context.Background(), &cluster.ClusterQuery{})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "SERVER\tNAME\tSTATUS\tMESSAGE\n")
for _, c := range clusters.Items {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", c.Server, c.Name, c.ConnectionState.Status, c.ConnectionState.Message)
}
_ = w.Flush()
},
}
return command
} | [
"func",
"NewClusterListCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"conn",
",",
"clusterIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewClusterClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"clusters",
",",
"err",
":=",
"clusterIf",
".",
"List",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"cluster",
".",
"ClusterQuery",
"{",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"clusters",
".",
"Items",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\t",
"\\n",
"\"",
",",
"c",
".",
"Server",
",",
"c",
".",
"Name",
",",
"c",
".",
"ConnectionState",
".",
"Status",
",",
"c",
".",
"ConnectionState",
".",
"Message",
")",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewClusterListCommand returns a new instance of an `argocd cluster rm` command | [
"NewClusterListCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"cluster",
"rm",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/cluster.go#L241-L259 |
161,866 | argoproj/argo-cd | server/account/account.go | NewServer | func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.SettingsManager) *Server {
return &Server{
sessionMgr: sessionMgr,
settingsMgr: settingsMgr,
}
} | go | func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.SettingsManager) *Server {
return &Server{
sessionMgr: sessionMgr,
settingsMgr: settingsMgr,
}
} | [
"func",
"NewServer",
"(",
"sessionMgr",
"*",
"session",
".",
"SessionManager",
",",
"settingsMgr",
"*",
"settings",
".",
"SettingsManager",
")",
"*",
"Server",
"{",
"return",
"&",
"Server",
"{",
"sessionMgr",
":",
"sessionMgr",
",",
"settingsMgr",
":",
"settingsMgr",
",",
"}",
"\n\n",
"}"
] | // NewServer returns a new instance of the Session service | [
"NewServer",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Session",
"service"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/account/account.go#L26-L32 |
161,867 | argoproj/argo-cd | server/account/account.go | UpdatePassword | func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UpdatePasswordResponse, error) {
username := getAuthenticatedUser(ctx)
if username != common.ArgoCDAdminUsername {
return nil, status.Errorf(codes.InvalidArgument, "password can only be changed for local users, not user %q", username)
}
cdSettings, err := s.settingsMgr.GetSettings()
if err != nil {
return nil, err
}
err = s.sessionMgr.VerifyUsernamePassword(username, q.CurrentPassword)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "current password does not match")
}
hashedPassword, err := password.HashPassword(q.NewPassword)
if err != nil {
return nil, err
}
cdSettings.AdminPasswordHash = hashedPassword
cdSettings.AdminPasswordMtime = time.Now().UTC()
err = s.settingsMgr.SaveSettings(cdSettings)
if err != nil {
return nil, err
}
log.Infof("user '%s' updated password", username)
return &UpdatePasswordResponse{}, nil
} | go | func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UpdatePasswordResponse, error) {
username := getAuthenticatedUser(ctx)
if username != common.ArgoCDAdminUsername {
return nil, status.Errorf(codes.InvalidArgument, "password can only be changed for local users, not user %q", username)
}
cdSettings, err := s.settingsMgr.GetSettings()
if err != nil {
return nil, err
}
err = s.sessionMgr.VerifyUsernamePassword(username, q.CurrentPassword)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "current password does not match")
}
hashedPassword, err := password.HashPassword(q.NewPassword)
if err != nil {
return nil, err
}
cdSettings.AdminPasswordHash = hashedPassword
cdSettings.AdminPasswordMtime = time.Now().UTC()
err = s.settingsMgr.SaveSettings(cdSettings)
if err != nil {
return nil, err
}
log.Infof("user '%s' updated password", username)
return &UpdatePasswordResponse{}, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"UpdatePassword",
"(",
"ctx",
"context",
".",
"Context",
",",
"q",
"*",
"UpdatePasswordRequest",
")",
"(",
"*",
"UpdatePasswordResponse",
",",
"error",
")",
"{",
"username",
":=",
"getAuthenticatedUser",
"(",
"ctx",
")",
"\n",
"if",
"username",
"!=",
"common",
".",
"ArgoCDAdminUsername",
"{",
"return",
"nil",
",",
"status",
".",
"Errorf",
"(",
"codes",
".",
"InvalidArgument",
",",
"\"",
"\"",
",",
"username",
")",
"\n",
"}",
"\n\n",
"cdSettings",
",",
"err",
":=",
"s",
".",
"settingsMgr",
".",
"GetSettings",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"s",
".",
"sessionMgr",
".",
"VerifyUsernamePassword",
"(",
"username",
",",
"q",
".",
"CurrentPassword",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"status",
".",
"Errorf",
"(",
"codes",
".",
"InvalidArgument",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"hashedPassword",
",",
"err",
":=",
"password",
".",
"HashPassword",
"(",
"q",
".",
"NewPassword",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"cdSettings",
".",
"AdminPasswordHash",
"=",
"hashedPassword",
"\n",
"cdSettings",
".",
"AdminPasswordMtime",
"=",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
"\n\n",
"err",
"=",
"s",
".",
"settingsMgr",
".",
"SaveSettings",
"(",
"cdSettings",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"log",
".",
"Infof",
"(",
"\"",
"\"",
",",
"username",
")",
"\n",
"return",
"&",
"UpdatePasswordResponse",
"{",
"}",
",",
"nil",
"\n\n",
"}"
] | // UpdatePassword updates the password of the local admin superuser. | [
"UpdatePassword",
"updates",
"the",
"password",
"of",
"the",
"local",
"admin",
"superuser",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/account/account.go#L35-L66 |
161,868 | argoproj/argo-cd | server/version/version.go | Version | func (s *Server) Version(context.Context, *empty.Empty) (*VersionMessage, error) {
vers := argocd.GetVersion()
ksonnetVersion, err := ksutil.KsonnetVersion()
if err != nil {
return nil, err
}
return &VersionMessage{
Version: vers.Version,
BuildDate: vers.BuildDate,
GitCommit: vers.GitCommit,
GitTag: vers.GitTag,
GitTreeState: vers.GitTreeState,
GoVersion: vers.GoVersion,
Compiler: vers.Compiler,
Platform: vers.Platform,
KsonnetVersion: ksonnetVersion,
}, nil
} | go | func (s *Server) Version(context.Context, *empty.Empty) (*VersionMessage, error) {
vers := argocd.GetVersion()
ksonnetVersion, err := ksutil.KsonnetVersion()
if err != nil {
return nil, err
}
return &VersionMessage{
Version: vers.Version,
BuildDate: vers.BuildDate,
GitCommit: vers.GitCommit,
GitTag: vers.GitTag,
GitTreeState: vers.GitTreeState,
GoVersion: vers.GoVersion,
Compiler: vers.Compiler,
Platform: vers.Platform,
KsonnetVersion: ksonnetVersion,
}, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Version",
"(",
"context",
".",
"Context",
",",
"*",
"empty",
".",
"Empty",
")",
"(",
"*",
"VersionMessage",
",",
"error",
")",
"{",
"vers",
":=",
"argocd",
".",
"GetVersion",
"(",
")",
"\n",
"ksonnetVersion",
",",
"err",
":=",
"ksutil",
".",
"KsonnetVersion",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"VersionMessage",
"{",
"Version",
":",
"vers",
".",
"Version",
",",
"BuildDate",
":",
"vers",
".",
"BuildDate",
",",
"GitCommit",
":",
"vers",
".",
"GitCommit",
",",
"GitTag",
":",
"vers",
".",
"GitTag",
",",
"GitTreeState",
":",
"vers",
".",
"GitTreeState",
",",
"GoVersion",
":",
"vers",
".",
"GoVersion",
",",
"Compiler",
":",
"vers",
".",
"Compiler",
",",
"Platform",
":",
"vers",
".",
"Platform",
",",
"KsonnetVersion",
":",
"ksonnetVersion",
",",
"}",
",",
"nil",
"\n",
"}"
] | // Version returns the version of the API server | [
"Version",
"returns",
"the",
"version",
"of",
"the",
"API",
"server"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/version/version.go#L14-L31 |
161,869 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleCommand | func NewProjectRoleCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
roleCommand := &cobra.Command{
Use: "role",
Short: "Manage a project's roles",
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
roleCommand.AddCommand(NewProjectRoleListCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleGetCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleCreateCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleDeleteCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleCreateTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleDeleteTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleAddPolicyCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleRemovePolicyCommand(clientOpts))
return roleCommand
} | go | func NewProjectRoleCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
roleCommand := &cobra.Command{
Use: "role",
Short: "Manage a project's roles",
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
},
}
roleCommand.AddCommand(NewProjectRoleListCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleGetCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleCreateCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleDeleteCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleCreateTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleDeleteTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleAddPolicyCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleRemovePolicyCommand(clientOpts))
return roleCommand
} | [
"func",
"NewProjectRoleCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"roleCommand",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
",",
"}",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleListCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleGetCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleCreateCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleDeleteCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleCreateTokenCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleDeleteTokenCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleAddPolicyCommand",
"(",
"clientOpts",
")",
")",
"\n",
"roleCommand",
".",
"AddCommand",
"(",
"NewProjectRoleRemovePolicyCommand",
"(",
"clientOpts",
")",
")",
"\n",
"return",
"roleCommand",
"\n",
"}"
] | // NewProjectRoleCommand returns a new instance of the `argocd proj role` command | [
"NewProjectRoleCommand",
"returns",
"a",
"new",
"instance",
"of",
"the",
"argocd",
"proj",
"role",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L26-L44 |
161,870 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleAddPolicyCommand | func NewProjectRoleAddPolicyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
opts policyOpts
)
var command = &cobra.Command{
Use: "add-policy PROJECT ROLE-NAME",
Short: "Add a policy to a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
role, roleIndex, err := projectutil.GetRoleByName(proj, roleName)
errors.CheckError(err)
policy := fmt.Sprintf(policyTemplate, proj.Name, role.Name, opts.action, proj.Name, opts.object, opts.permission)
proj.Spec.Roles[roleIndex].Policies = append(role.Policies, policy)
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
},
}
addPolicyFlags(command, &opts)
return command
} | go | func NewProjectRoleAddPolicyCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
opts policyOpts
)
var command = &cobra.Command{
Use: "add-policy PROJECT ROLE-NAME",
Short: "Add a policy to a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
role, roleIndex, err := projectutil.GetRoleByName(proj, roleName)
errors.CheckError(err)
policy := fmt.Sprintf(policyTemplate, proj.Name, role.Name, opts.action, proj.Name, opts.object, opts.permission)
proj.Spec.Roles[roleIndex].Policies = append(role.Policies, policy)
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
},
}
addPolicyFlags(command, &opts)
return command
} | [
"func",
"NewProjectRoleAddPolicyCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"opts",
"policyOpts",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"roleName",
":=",
"args",
"[",
"1",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"proj",
",",
"err",
":=",
"projIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectQuery",
"{",
"Name",
":",
"projName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"role",
",",
"roleIndex",
",",
"err",
":=",
"projectutil",
".",
"GetRoleByName",
"(",
"proj",
",",
"roleName",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"policy",
":=",
"fmt",
".",
"Sprintf",
"(",
"policyTemplate",
",",
"proj",
".",
"Name",
",",
"role",
".",
"Name",
",",
"opts",
".",
"action",
",",
"proj",
".",
"Name",
",",
"opts",
".",
"object",
",",
"opts",
".",
"permission",
")",
"\n",
"proj",
".",
"Spec",
".",
"Roles",
"[",
"roleIndex",
"]",
".",
"Policies",
"=",
"append",
"(",
"role",
".",
"Policies",
",",
"policy",
")",
"\n\n",
"_",
",",
"err",
"=",
"projIf",
".",
"Update",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectUpdateRequest",
"{",
"Project",
":",
"proj",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
",",
"}",
"\n",
"addPolicyFlags",
"(",
"command",
",",
"&",
"opts",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleAddPolicyCommand returns a new instance of an `argocd proj role add-policy` command | [
"NewProjectRoleAddPolicyCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"role",
"add",
"-",
"policy",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L47-L79 |
161,871 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleCreateCommand | func NewProjectRoleCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
description string
)
var command = &cobra.Command{
Use: "create PROJECT ROLE-NAME",
Short: "Create a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
_, _, err = projectutil.GetRoleByName(proj, roleName)
if err == nil {
fmt.Printf("Role '%s' already exists\n", roleName)
return
}
proj.Spec.Roles = append(proj.Spec.Roles, v1alpha1.ProjectRole{Name: roleName, Description: description})
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
fmt.Printf("Role '%s' created\n", roleName)
},
}
command.Flags().StringVarP(&description, "description", "", "", "Project description")
return command
} | go | func NewProjectRoleCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
description string
)
var command = &cobra.Command{
Use: "create PROJECT ROLE-NAME",
Short: "Create a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
_, _, err = projectutil.GetRoleByName(proj, roleName)
if err == nil {
fmt.Printf("Role '%s' already exists\n", roleName)
return
}
proj.Spec.Roles = append(proj.Spec.Roles, v1alpha1.ProjectRole{Name: roleName, Description: description})
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
fmt.Printf("Role '%s' created\n", roleName)
},
}
command.Flags().StringVarP(&description, "description", "", "", "Project description")
return command
} | [
"func",
"NewProjectRoleCreateCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"description",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"roleName",
":=",
"args",
"[",
"1",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"proj",
",",
"err",
":=",
"projIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectQuery",
"{",
"Name",
":",
"projName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"_",
",",
"_",
",",
"err",
"=",
"projectutil",
".",
"GetRoleByName",
"(",
"proj",
",",
"roleName",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"roleName",
")",
"\n",
"return",
"\n",
"}",
"\n",
"proj",
".",
"Spec",
".",
"Roles",
"=",
"append",
"(",
"proj",
".",
"Spec",
".",
"Roles",
",",
"v1alpha1",
".",
"ProjectRole",
"{",
"Name",
":",
"roleName",
",",
"Description",
":",
"description",
"}",
")",
"\n\n",
"_",
",",
"err",
"=",
"projIf",
".",
"Update",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectUpdateRequest",
"{",
"Project",
":",
"proj",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"roleName",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVarP",
"(",
"&",
"description",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleCreateCommand returns a new instance of an `argocd proj role create` command | [
"NewProjectRoleCreateCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"role",
"create",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L127-L161 |
161,872 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleCreateTokenCommand | func NewProjectRoleCreateTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
expiresIn string
)
var command = &cobra.Command{
Use: "create-token PROJECT ROLE-NAME",
Short: "Create a project token",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
duration, err := timeutil.ParseDuration(expiresIn)
errors.CheckError(err)
token, err := projIf.CreateToken(context.Background(), &project.ProjectTokenCreateRequest{Project: projName, Role: roleName, ExpiresIn: int64(duration.Seconds())})
errors.CheckError(err)
fmt.Println(token.Token)
},
}
command.Flags().StringVarP(&expiresIn, "expires-in", "e", "0s", "Duration before the token will expire. (Default: No expiration)")
return command
} | go | func NewProjectRoleCreateTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
expiresIn string
)
var command = &cobra.Command{
Use: "create-token PROJECT ROLE-NAME",
Short: "Create a project token",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
duration, err := timeutil.ParseDuration(expiresIn)
errors.CheckError(err)
token, err := projIf.CreateToken(context.Background(), &project.ProjectTokenCreateRequest{Project: projName, Role: roleName, ExpiresIn: int64(duration.Seconds())})
errors.CheckError(err)
fmt.Println(token.Token)
},
}
command.Flags().StringVarP(&expiresIn, "expires-in", "e", "0s", "Duration before the token will expire. (Default: No expiration)")
return command
} | [
"func",
"NewProjectRoleCreateTokenCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"(",
"expiresIn",
"string",
"\n",
")",
"\n",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"roleName",
":=",
"args",
"[",
"1",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"duration",
",",
"err",
":=",
"timeutil",
".",
"ParseDuration",
"(",
"expiresIn",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"token",
",",
"err",
":=",
"projIf",
".",
"CreateToken",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectTokenCreateRequest",
"{",
"Project",
":",
"projName",
",",
"Role",
":",
"roleName",
",",
"ExpiresIn",
":",
"int64",
"(",
"duration",
".",
"Seconds",
"(",
")",
")",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Println",
"(",
"token",
".",
"Token",
")",
"\n",
"}",
",",
"}",
"\n",
"command",
".",
"Flags",
"(",
")",
".",
"StringVarP",
"(",
"&",
"expiresIn",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleCreateTokenCommand returns a new instance of an `argocd proj role create-token` command | [
"NewProjectRoleCreateTokenCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"role",
"create",
"-",
"token",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L198-L224 |
161,873 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleDeleteTokenCommand | func NewProjectRoleDeleteTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "delete-token PROJECT ROLE-NAME ISSUED-AT",
Short: "Delete a project token",
Run: func(c *cobra.Command, args []string) {
if len(args) != 3 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
issuedAt, err := strconv.ParseInt(args[2], 10, 64)
errors.CheckError(err)
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
_, err = projIf.DeleteToken(context.Background(), &project.ProjectTokenDeleteRequest{Project: projName, Role: roleName, Iat: issuedAt})
errors.CheckError(err)
},
}
return command
} | go | func NewProjectRoleDeleteTokenCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "delete-token PROJECT ROLE-NAME ISSUED-AT",
Short: "Delete a project token",
Run: func(c *cobra.Command, args []string) {
if len(args) != 3 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
issuedAt, err := strconv.ParseInt(args[2], 10, 64)
errors.CheckError(err)
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
_, err = projIf.DeleteToken(context.Background(), &project.ProjectTokenDeleteRequest{Project: projName, Role: roleName, Iat: issuedAt})
errors.CheckError(err)
},
}
return command
} | [
"func",
"NewProjectRoleDeleteTokenCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"3",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"roleName",
":=",
"args",
"[",
"1",
"]",
"\n",
"issuedAt",
",",
"err",
":=",
"strconv",
".",
"ParseInt",
"(",
"args",
"[",
"2",
"]",
",",
"10",
",",
"64",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"_",
",",
"err",
"=",
"projIf",
".",
"DeleteToken",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectTokenDeleteRequest",
"{",
"Project",
":",
"projName",
",",
"Role",
":",
"roleName",
",",
"Iat",
":",
"issuedAt",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleDeleteTokenCommand returns a new instance of an `argocd proj role delete-token` command | [
"NewProjectRoleDeleteTokenCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"role",
"delete",
"-",
"token",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L227-L249 |
161,874 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleListCommand | func NewProjectRoleListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "list PROJECT",
Short: "List all the roles in a project",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
project, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ROLE-NAME\tDESCRIPTION\n")
for _, role := range project.Spec.Roles {
fmt.Fprintf(w, "%s\t%s\n", role.Name, role.Description)
}
_ = w.Flush()
},
}
return command
} | go | func NewProjectRoleListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "list PROJECT",
Short: "List all the roles in a project",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
project, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ROLE-NAME\tDESCRIPTION\n")
for _, role := range project.Spec.Roles {
fmt.Fprintf(w, "%s\t%s\n", role.Name, role.Description)
}
_ = w.Flush()
},
}
return command
} | [
"func",
"NewProjectRoleListCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"project",
",",
"err",
":=",
"projIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectQuery",
"{",
"Name",
":",
"projName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"role",
":=",
"range",
"project",
".",
"Spec",
".",
"Roles",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\n",
"\"",
",",
"role",
".",
"Name",
",",
"role",
".",
"Description",
")",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleListCommand returns a new instance of an `argocd proj roles list` command | [
"NewProjectRoleListCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"roles",
"list",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L252-L276 |
161,875 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleGetCommand | func NewProjectRoleGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "get PROJECT ROLE-NAME",
Short: "Get the details of a specific role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
role, _, err := projectutil.GetRoleByName(proj, roleName)
errors.CheckError(err)
printRoleFmtStr := "%-15s%s\n"
fmt.Printf(printRoleFmtStr, "Role Name:", roleName)
fmt.Printf(printRoleFmtStr, "Description:", role.Description)
fmt.Printf("Policies:\n")
fmt.Printf("%s\n", proj.ProjectPoliciesString())
fmt.Printf("JWT Tokens:\n")
// TODO(jessesuen): print groups
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ID\tISSUED-AT\tEXPIRES-AT\n")
for _, token := range role.JWTTokens {
expiresAt := "<none>"
if token.ExpiresAt > 0 {
expiresAt = humanizeTimestamp(token.ExpiresAt)
}
fmt.Fprintf(w, "%d\t%s\t%s\n", token.IssuedAt, humanizeTimestamp(token.IssuedAt), expiresAt)
}
_ = w.Flush()
},
}
return command
} | go | func NewProjectRoleGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "get PROJECT ROLE-NAME",
Short: "Get the details of a specific role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName := args[0]
roleName := args[1]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
role, _, err := projectutil.GetRoleByName(proj, roleName)
errors.CheckError(err)
printRoleFmtStr := "%-15s%s\n"
fmt.Printf(printRoleFmtStr, "Role Name:", roleName)
fmt.Printf(printRoleFmtStr, "Description:", role.Description)
fmt.Printf("Policies:\n")
fmt.Printf("%s\n", proj.ProjectPoliciesString())
fmt.Printf("JWT Tokens:\n")
// TODO(jessesuen): print groups
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintf(w, "ID\tISSUED-AT\tEXPIRES-AT\n")
for _, token := range role.JWTTokens {
expiresAt := "<none>"
if token.ExpiresAt > 0 {
expiresAt = humanizeTimestamp(token.ExpiresAt)
}
fmt.Fprintf(w, "%d\t%s\t%s\n", token.IssuedAt, humanizeTimestamp(token.IssuedAt), expiresAt)
}
_ = w.Flush()
},
}
return command
} | [
"func",
"NewProjectRoleGetCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
":=",
"args",
"[",
"0",
"]",
"\n",
"roleName",
":=",
"args",
"[",
"1",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n\n",
"proj",
",",
"err",
":=",
"projIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectQuery",
"{",
"Name",
":",
"projName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"role",
",",
"_",
",",
"err",
":=",
"projectutil",
".",
"GetRoleByName",
"(",
"proj",
",",
"roleName",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n\n",
"printRoleFmtStr",
":=",
"\"",
"\\n",
"\"",
"\n",
"fmt",
".",
"Printf",
"(",
"printRoleFmtStr",
",",
"\"",
"\"",
",",
"roleName",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"printRoleFmtStr",
",",
"\"",
"\"",
",",
"role",
".",
"Description",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"proj",
".",
"ProjectPoliciesString",
"(",
")",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"// TODO(jessesuen): print groups",
"w",
":=",
"tabwriter",
".",
"NewWriter",
"(",
"os",
".",
"Stdout",
",",
"0",
",",
"0",
",",
"2",
",",
"' '",
",",
"0",
")",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
")",
"\n",
"for",
"_",
",",
"token",
":=",
"range",
"role",
".",
"JWTTokens",
"{",
"expiresAt",
":=",
"\"",
"\"",
"\n",
"if",
"token",
".",
"ExpiresAt",
">",
"0",
"{",
"expiresAt",
"=",
"humanizeTimestamp",
"(",
"token",
".",
"ExpiresAt",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"",
"\\t",
"\\t",
"\\n",
"\"",
",",
"token",
".",
"IssuedAt",
",",
"humanizeTimestamp",
"(",
"token",
".",
"IssuedAt",
")",
",",
"expiresAt",
")",
"\n",
"}",
"\n",
"_",
"=",
"w",
".",
"Flush",
"(",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleGetCommand returns a new instance of an `argocd proj roles get` command | [
"NewProjectRoleGetCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"roles",
"get",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L279-L319 |
161,876 | argoproj/argo-cd | cmd/argocd/commands/project_role.go | NewProjectRoleAddGroupCommand | func NewProjectRoleAddGroupCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "add-group PROJECT ROLE-NAME GROUP-CLAIM",
Short: "Add a policy to a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName, roleName, groupName := args[0], args[1], args[2]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
updated, err := projectutil.AddGroupToRole(proj, roleName, groupName)
errors.CheckError(err)
if updated {
fmt.Printf("Group '%s' already present in role '%s'\n", groupName, roleName)
return
}
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
fmt.Printf("Group '%s' added to role '%s'\n", groupName, roleName)
},
}
return command
} | go | func NewProjectRoleAddGroupCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "add-group PROJECT ROLE-NAME GROUP-CLAIM",
Short: "Add a policy to a project role",
Run: func(c *cobra.Command, args []string) {
if len(args) != 2 {
c.HelpFunc()(c, args)
os.Exit(1)
}
projName, roleName, groupName := args[0], args[1], args[2]
conn, projIf := argocdclient.NewClientOrDie(clientOpts).NewProjectClientOrDie()
defer util.Close(conn)
proj, err := projIf.Get(context.Background(), &project.ProjectQuery{Name: projName})
errors.CheckError(err)
updated, err := projectutil.AddGroupToRole(proj, roleName, groupName)
errors.CheckError(err)
if updated {
fmt.Printf("Group '%s' already present in role '%s'\n", groupName, roleName)
return
}
_, err = projIf.Update(context.Background(), &project.ProjectUpdateRequest{Project: proj})
errors.CheckError(err)
fmt.Printf("Group '%s' added to role '%s'\n", groupName, roleName)
},
}
return command
} | [
"func",
"NewProjectRoleAddGroupCommand",
"(",
"clientOpts",
"*",
"argocdclient",
".",
"ClientOptions",
")",
"*",
"cobra",
".",
"Command",
"{",
"var",
"command",
"=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"",
"\"",
",",
"Short",
":",
"\"",
"\"",
",",
"Run",
":",
"func",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"args",
"[",
"]",
"string",
")",
"{",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"c",
".",
"HelpFunc",
"(",
")",
"(",
"c",
",",
"args",
")",
"\n",
"os",
".",
"Exit",
"(",
"1",
")",
"\n",
"}",
"\n",
"projName",
",",
"roleName",
",",
"groupName",
":=",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"]",
",",
"args",
"[",
"2",
"]",
"\n",
"conn",
",",
"projIf",
":=",
"argocdclient",
".",
"NewClientOrDie",
"(",
"clientOpts",
")",
".",
"NewProjectClientOrDie",
"(",
")",
"\n",
"defer",
"util",
".",
"Close",
"(",
"conn",
")",
"\n",
"proj",
",",
"err",
":=",
"projIf",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectQuery",
"{",
"Name",
":",
"projName",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"updated",
",",
"err",
":=",
"projectutil",
".",
"AddGroupToRole",
"(",
"proj",
",",
"roleName",
",",
"groupName",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"if",
"updated",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"groupName",
",",
"roleName",
")",
"\n",
"return",
"\n",
"}",
"\n",
"_",
",",
"err",
"=",
"projIf",
".",
"Update",
"(",
"context",
".",
"Background",
"(",
")",
",",
"&",
"project",
".",
"ProjectUpdateRequest",
"{",
"Project",
":",
"proj",
"}",
")",
"\n",
"errors",
".",
"CheckError",
"(",
"err",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"groupName",
",",
"roleName",
")",
"\n",
"}",
",",
"}",
"\n",
"return",
"command",
"\n",
"}"
] | // NewProjectRoleAddGroupCommand returns a new instance of an `argocd proj role add-group` command | [
"NewProjectRoleAddGroupCommand",
"returns",
"a",
"new",
"instance",
"of",
"an",
"argocd",
"proj",
"role",
"add",
"-",
"group",
"command"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/cmd/argocd/commands/project_role.go#L322-L348 |
161,877 | argoproj/argo-cd | server/rbacpolicy/rbacpolicy.go | NewRBACPolicyEnforcer | func NewRBACPolicyEnforcer(enf *rbac.Enforcer, projLister applister.AppProjectNamespaceLister) *RBACPolicyEnforcer {
return &RBACPolicyEnforcer{
enf: enf,
projLister: projLister,
}
} | go | func NewRBACPolicyEnforcer(enf *rbac.Enforcer, projLister applister.AppProjectNamespaceLister) *RBACPolicyEnforcer {
return &RBACPolicyEnforcer{
enf: enf,
projLister: projLister,
}
} | [
"func",
"NewRBACPolicyEnforcer",
"(",
"enf",
"*",
"rbac",
".",
"Enforcer",
",",
"projLister",
"applister",
".",
"AppProjectNamespaceLister",
")",
"*",
"RBACPolicyEnforcer",
"{",
"return",
"&",
"RBACPolicyEnforcer",
"{",
"enf",
":",
"enf",
",",
"projLister",
":",
"projLister",
",",
"}",
"\n",
"}"
] | // NewRBACPolicyEnforcer returns a new RBAC Enforcer for the Argo CD API Server | [
"NewRBACPolicyEnforcer",
"returns",
"a",
"new",
"RBAC",
"Enforcer",
"for",
"the",
"Argo",
"CD",
"API",
"Server"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/rbacpolicy/rbacpolicy.go#L38-L43 |
161,878 | argoproj/argo-cd | server/rbacpolicy/rbacpolicy.go | EnforceClaims | func (p *RBACPolicyEnforcer) EnforceClaims(claims jwt.Claims, rvals ...interface{}) bool {
mapClaims, err := jwtutil.MapClaims(claims)
if err != nil {
return false
}
subject := jwtutil.GetField(mapClaims, "sub")
// Check if the request is for an application resource. We have special enforcement which takes
// into consideration the project's token and group bindings
var runtimePolicy string
proj := p.getProjectFromRequest(rvals...)
if proj != nil {
if strings.HasPrefix(subject, "proj:") {
return p.enforceProjectToken(subject, mapClaims, proj, rvals...)
}
runtimePolicy = proj.ProjectPoliciesString()
}
// Check the subject. This is typically the 'admin' case.
// NOTE: the call to EnforceRuntimePolicy will also consider the default role
vals := append([]interface{}{subject}, rvals[1:]...)
if p.enf.EnforceRuntimePolicy(runtimePolicy, vals...) {
return true
}
// Finally check if any of the user's groups grant them permissions
groups := jwtutil.GetGroups(mapClaims)
for _, group := range groups {
vals := append([]interface{}{group}, rvals[1:]...)
if p.enf.EnforceRuntimePolicy(runtimePolicy, vals...) {
return true
}
}
logCtx := log.WithField("claims", claims).WithField("rval", rvals)
logCtx.Debug("enforce failed")
return false
} | go | func (p *RBACPolicyEnforcer) EnforceClaims(claims jwt.Claims, rvals ...interface{}) bool {
mapClaims, err := jwtutil.MapClaims(claims)
if err != nil {
return false
}
subject := jwtutil.GetField(mapClaims, "sub")
// Check if the request is for an application resource. We have special enforcement which takes
// into consideration the project's token and group bindings
var runtimePolicy string
proj := p.getProjectFromRequest(rvals...)
if proj != nil {
if strings.HasPrefix(subject, "proj:") {
return p.enforceProjectToken(subject, mapClaims, proj, rvals...)
}
runtimePolicy = proj.ProjectPoliciesString()
}
// Check the subject. This is typically the 'admin' case.
// NOTE: the call to EnforceRuntimePolicy will also consider the default role
vals := append([]interface{}{subject}, rvals[1:]...)
if p.enf.EnforceRuntimePolicy(runtimePolicy, vals...) {
return true
}
// Finally check if any of the user's groups grant them permissions
groups := jwtutil.GetGroups(mapClaims)
for _, group := range groups {
vals := append([]interface{}{group}, rvals[1:]...)
if p.enf.EnforceRuntimePolicy(runtimePolicy, vals...) {
return true
}
}
logCtx := log.WithField("claims", claims).WithField("rval", rvals)
logCtx.Debug("enforce failed")
return false
} | [
"func",
"(",
"p",
"*",
"RBACPolicyEnforcer",
")",
"EnforceClaims",
"(",
"claims",
"jwt",
".",
"Claims",
",",
"rvals",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"mapClaims",
",",
"err",
":=",
"jwtutil",
".",
"MapClaims",
"(",
"claims",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"subject",
":=",
"jwtutil",
".",
"GetField",
"(",
"mapClaims",
",",
"\"",
"\"",
")",
"\n",
"// Check if the request is for an application resource. We have special enforcement which takes",
"// into consideration the project's token and group bindings",
"var",
"runtimePolicy",
"string",
"\n",
"proj",
":=",
"p",
".",
"getProjectFromRequest",
"(",
"rvals",
"...",
")",
"\n",
"if",
"proj",
"!=",
"nil",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"subject",
",",
"\"",
"\"",
")",
"{",
"return",
"p",
".",
"enforceProjectToken",
"(",
"subject",
",",
"mapClaims",
",",
"proj",
",",
"rvals",
"...",
")",
"\n",
"}",
"\n",
"runtimePolicy",
"=",
"proj",
".",
"ProjectPoliciesString",
"(",
")",
"\n",
"}",
"\n\n",
"// Check the subject. This is typically the 'admin' case.",
"// NOTE: the call to EnforceRuntimePolicy will also consider the default role",
"vals",
":=",
"append",
"(",
"[",
"]",
"interface",
"{",
"}",
"{",
"subject",
"}",
",",
"rvals",
"[",
"1",
":",
"]",
"...",
")",
"\n",
"if",
"p",
".",
"enf",
".",
"EnforceRuntimePolicy",
"(",
"runtimePolicy",
",",
"vals",
"...",
")",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"// Finally check if any of the user's groups grant them permissions",
"groups",
":=",
"jwtutil",
".",
"GetGroups",
"(",
"mapClaims",
")",
"\n",
"for",
"_",
",",
"group",
":=",
"range",
"groups",
"{",
"vals",
":=",
"append",
"(",
"[",
"]",
"interface",
"{",
"}",
"{",
"group",
"}",
",",
"rvals",
"[",
"1",
":",
"]",
"...",
")",
"\n",
"if",
"p",
".",
"enf",
".",
"EnforceRuntimePolicy",
"(",
"runtimePolicy",
",",
"vals",
"...",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"logCtx",
":=",
"log",
".",
"WithField",
"(",
"\"",
"\"",
",",
"claims",
")",
".",
"WithField",
"(",
"\"",
"\"",
",",
"rvals",
")",
"\n",
"logCtx",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"}"
] | // EnforceClaims is an RBAC claims enforcer specific to the Argo CD API server | [
"EnforceClaims",
"is",
"an",
"RBAC",
"claims",
"enforcer",
"specific",
"to",
"the",
"Argo",
"CD",
"API",
"server"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/rbacpolicy/rbacpolicy.go#L46-L82 |
161,879 | argoproj/argo-cd | server/rbacpolicy/rbacpolicy.go | enforceProjectToken | func (p *RBACPolicyEnforcer) enforceProjectToken(subject string, claims jwt.MapClaims, proj *v1alpha1.AppProject, rvals ...interface{}) bool {
subjectSplit := strings.Split(subject, ":")
if len(subjectSplit) != 3 {
return false
}
projName, roleName := subjectSplit[1], subjectSplit[2]
if projName != proj.Name {
// this should never happen (we generated a project token for a different project)
return false
}
iat, err := jwtutil.GetIssuedAt(claims)
if err != nil {
return false
}
_, _, err = projectutil.GetJWTToken(proj, roleName, iat)
if err != nil {
// if we get here the token is still valid, but has been revoked (no longer exists in the project)
return false
}
vals := append([]interface{}{subject}, rvals[1:]...)
return p.enf.EnforceRuntimePolicy(proj.ProjectPoliciesString(), vals...)
} | go | func (p *RBACPolicyEnforcer) enforceProjectToken(subject string, claims jwt.MapClaims, proj *v1alpha1.AppProject, rvals ...interface{}) bool {
subjectSplit := strings.Split(subject, ":")
if len(subjectSplit) != 3 {
return false
}
projName, roleName := subjectSplit[1], subjectSplit[2]
if projName != proj.Name {
// this should never happen (we generated a project token for a different project)
return false
}
iat, err := jwtutil.GetIssuedAt(claims)
if err != nil {
return false
}
_, _, err = projectutil.GetJWTToken(proj, roleName, iat)
if err != nil {
// if we get here the token is still valid, but has been revoked (no longer exists in the project)
return false
}
vals := append([]interface{}{subject}, rvals[1:]...)
return p.enf.EnforceRuntimePolicy(proj.ProjectPoliciesString(), vals...)
} | [
"func",
"(",
"p",
"*",
"RBACPolicyEnforcer",
")",
"enforceProjectToken",
"(",
"subject",
"string",
",",
"claims",
"jwt",
".",
"MapClaims",
",",
"proj",
"*",
"v1alpha1",
".",
"AppProject",
",",
"rvals",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"subjectSplit",
":=",
"strings",
".",
"Split",
"(",
"subject",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"subjectSplit",
")",
"!=",
"3",
"{",
"return",
"false",
"\n",
"}",
"\n",
"projName",
",",
"roleName",
":=",
"subjectSplit",
"[",
"1",
"]",
",",
"subjectSplit",
"[",
"2",
"]",
"\n",
"if",
"projName",
"!=",
"proj",
".",
"Name",
"{",
"// this should never happen (we generated a project token for a different project)",
"return",
"false",
"\n",
"}",
"\n",
"iat",
",",
"err",
":=",
"jwtutil",
".",
"GetIssuedAt",
"(",
"claims",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"_",
",",
"_",
",",
"err",
"=",
"projectutil",
".",
"GetJWTToken",
"(",
"proj",
",",
"roleName",
",",
"iat",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"// if we get here the token is still valid, but has been revoked (no longer exists in the project)",
"return",
"false",
"\n",
"}",
"\n",
"vals",
":=",
"append",
"(",
"[",
"]",
"interface",
"{",
"}",
"{",
"subject",
"}",
",",
"rvals",
"[",
"1",
":",
"]",
"...",
")",
"\n",
"return",
"p",
".",
"enf",
".",
"EnforceRuntimePolicy",
"(",
"proj",
".",
"ProjectPoliciesString",
"(",
")",
",",
"vals",
"...",
")",
"\n\n",
"}"
] | // enforceProjectToken will check to see the valid token has not yet been revoked in the project | [
"enforceProjectToken",
"will",
"check",
"to",
"see",
"the",
"valid",
"token",
"has",
"not",
"yet",
"been",
"revoked",
"in",
"the",
"project"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/server/rbacpolicy/rbacpolicy.go#L114-L136 |
161,880 | argoproj/argo-cd | controller/cache/cache.go | Run | func (c *liveStateCache) Run(ctx context.Context) {
util.RetryUntilSucceed(func() error {
clusterEventCallback := func(event *db.ClusterEvent) {
c.lock.Lock()
defer c.lock.Unlock()
if cluster, ok := c.clusters[event.Cluster.Server]; ok {
if event.Type == watch.Deleted {
cluster.invalidate()
delete(c.clusters, event.Cluster.Server)
} else if event.Type == watch.Modified {
cluster.cluster = event.Cluster
cluster.invalidate()
}
} else if event.Type == watch.Added && isClusterHasApps(c.appInformer.GetStore().List(), event.Cluster) {
go func() {
// warm up cache for cluster with apps
_, _ = c.getSyncedCluster(event.Cluster.Server)
}()
}
}
return c.db.WatchClusters(ctx, clusterEventCallback)
}, "watch clusters", ctx, clusterRetryTimeout)
<-ctx.Done()
} | go | func (c *liveStateCache) Run(ctx context.Context) {
util.RetryUntilSucceed(func() error {
clusterEventCallback := func(event *db.ClusterEvent) {
c.lock.Lock()
defer c.lock.Unlock()
if cluster, ok := c.clusters[event.Cluster.Server]; ok {
if event.Type == watch.Deleted {
cluster.invalidate()
delete(c.clusters, event.Cluster.Server)
} else if event.Type == watch.Modified {
cluster.cluster = event.Cluster
cluster.invalidate()
}
} else if event.Type == watch.Added && isClusterHasApps(c.appInformer.GetStore().List(), event.Cluster) {
go func() {
// warm up cache for cluster with apps
_, _ = c.getSyncedCluster(event.Cluster.Server)
}()
}
}
return c.db.WatchClusters(ctx, clusterEventCallback)
}, "watch clusters", ctx, clusterRetryTimeout)
<-ctx.Done()
} | [
"func",
"(",
"c",
"*",
"liveStateCache",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"util",
".",
"RetryUntilSucceed",
"(",
"func",
"(",
")",
"error",
"{",
"clusterEventCallback",
":=",
"func",
"(",
"event",
"*",
"db",
".",
"ClusterEvent",
")",
"{",
"c",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"cluster",
",",
"ok",
":=",
"c",
".",
"clusters",
"[",
"event",
".",
"Cluster",
".",
"Server",
"]",
";",
"ok",
"{",
"if",
"event",
".",
"Type",
"==",
"watch",
".",
"Deleted",
"{",
"cluster",
".",
"invalidate",
"(",
")",
"\n",
"delete",
"(",
"c",
".",
"clusters",
",",
"event",
".",
"Cluster",
".",
"Server",
")",
"\n",
"}",
"else",
"if",
"event",
".",
"Type",
"==",
"watch",
".",
"Modified",
"{",
"cluster",
".",
"cluster",
"=",
"event",
".",
"Cluster",
"\n",
"cluster",
".",
"invalidate",
"(",
")",
"\n",
"}",
"\n",
"}",
"else",
"if",
"event",
".",
"Type",
"==",
"watch",
".",
"Added",
"&&",
"isClusterHasApps",
"(",
"c",
".",
"appInformer",
".",
"GetStore",
"(",
")",
".",
"List",
"(",
")",
",",
"event",
".",
"Cluster",
")",
"{",
"go",
"func",
"(",
")",
"{",
"// warm up cache for cluster with apps",
"_",
",",
"_",
"=",
"c",
".",
"getSyncedCluster",
"(",
"event",
".",
"Cluster",
".",
"Server",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"c",
".",
"db",
".",
"WatchClusters",
"(",
"ctx",
",",
"clusterEventCallback",
")",
"\n\n",
"}",
",",
"\"",
"\"",
",",
"ctx",
",",
"clusterRetryTimeout",
")",
"\n\n",
"<-",
"ctx",
".",
"Done",
"(",
")",
"\n",
"}"
] | // Run watches for resource changes annotated with application label on all registered clusters and schedule corresponding app refresh. | [
"Run",
"watches",
"for",
"resource",
"changes",
"annotated",
"with",
"application",
"label",
"on",
"all",
"registered",
"clusters",
"and",
"schedule",
"corresponding",
"app",
"refresh",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/controller/cache/cache.go#L162-L188 |
161,881 | argoproj/argo-cd | util/oidc/provider.go | NewOIDCProvider | func NewOIDCProvider(issuerURL string, client *http.Client) Provider {
return &providerImpl{
issuerURL: issuerURL,
client: client,
}
} | go | func NewOIDCProvider(issuerURL string, client *http.Client) Provider {
return &providerImpl{
issuerURL: issuerURL,
client: client,
}
} | [
"func",
"NewOIDCProvider",
"(",
"issuerURL",
"string",
",",
"client",
"*",
"http",
".",
"Client",
")",
"Provider",
"{",
"return",
"&",
"providerImpl",
"{",
"issuerURL",
":",
"issuerURL",
",",
"client",
":",
"client",
",",
"}",
"\n",
"}"
] | // NewOIDCProvider initializes an OIDC provider | [
"NewOIDCProvider",
"initializes",
"an",
"OIDC",
"provider"
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/oidc/provider.go#L36-L41 |
161,882 | argoproj/argo-cd | util/oidc/provider.go | provider | func (p *providerImpl) provider() (*gooidc.Provider, error) {
if p.goOIDCProvider != nil {
return p.goOIDCProvider, nil
}
prov, err := p.newGoOIDCProvider()
if err != nil {
return nil, err
}
p.goOIDCProvider = prov
return p.goOIDCProvider, nil
} | go | func (p *providerImpl) provider() (*gooidc.Provider, error) {
if p.goOIDCProvider != nil {
return p.goOIDCProvider, nil
}
prov, err := p.newGoOIDCProvider()
if err != nil {
return nil, err
}
p.goOIDCProvider = prov
return p.goOIDCProvider, nil
} | [
"func",
"(",
"p",
"*",
"providerImpl",
")",
"provider",
"(",
")",
"(",
"*",
"gooidc",
".",
"Provider",
",",
"error",
")",
"{",
"if",
"p",
".",
"goOIDCProvider",
"!=",
"nil",
"{",
"return",
"p",
".",
"goOIDCProvider",
",",
"nil",
"\n",
"}",
"\n",
"prov",
",",
"err",
":=",
"p",
".",
"newGoOIDCProvider",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"p",
".",
"goOIDCProvider",
"=",
"prov",
"\n",
"return",
"p",
".",
"goOIDCProvider",
",",
"nil",
"\n",
"}"
] | // oidcProvider lazily initializes, memoizes, and returns the OIDC provider. | [
"oidcProvider",
"lazily",
"initializes",
"memoizes",
"and",
"returns",
"the",
"OIDC",
"provider",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/util/oidc/provider.go#L44-L54 |
161,883 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *AWSAuthConfig) DeepCopy() *AWSAuthConfig {
if in == nil {
return nil
}
out := new(AWSAuthConfig)
in.DeepCopyInto(out)
return out
} | go | func (in *AWSAuthConfig) DeepCopy() *AWSAuthConfig {
if in == nil {
return nil
}
out := new(AWSAuthConfig)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"AWSAuthConfig",
")",
"DeepCopy",
"(",
")",
"*",
"AWSAuthConfig",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"AWSAuthConfig",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSAuthConfig. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"AWSAuthConfig",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L20-L27 |
161,884 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *AppProject) DeepCopy() *AppProject {
if in == nil {
return nil
}
out := new(AppProject)
in.DeepCopyInto(out)
return out
} | go | func (in *AppProject) DeepCopy() *AppProject {
if in == nil {
return nil
}
out := new(AppProject)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"AppProject",
")",
"DeepCopy",
"(",
")",
"*",
"AppProject",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"AppProject",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppProject. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"AppProject",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L39-L46 |
161,885 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *AppProjectList) DeepCopy() *AppProjectList {
if in == nil {
return nil
}
out := new(AppProjectList)
in.DeepCopyInto(out)
return out
} | go | func (in *AppProjectList) DeepCopy() *AppProjectList {
if in == nil {
return nil
}
out := new(AppProjectList)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"AppProjectList",
")",
"DeepCopy",
"(",
")",
"*",
"AppProjectList",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"AppProjectList",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppProjectList. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"AppProjectList",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L72-L79 |
161,886 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *AppProjectSpec) DeepCopy() *AppProjectSpec {
if in == nil {
return nil
}
out := new(AppProjectSpec)
in.DeepCopyInto(out)
return out
} | go | func (in *AppProjectSpec) DeepCopy() *AppProjectSpec {
if in == nil {
return nil
}
out := new(AppProjectSpec)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"AppProjectSpec",
")",
"DeepCopy",
"(",
")",
"*",
"AppProjectSpec",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"AppProjectSpec",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AppProjectSpec. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"AppProjectSpec",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L123-L130 |
161,887 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *Application) DeepCopy() *Application {
if in == nil {
return nil
}
out := new(Application)
in.DeepCopyInto(out)
return out
} | go | func (in *Application) DeepCopy() *Application {
if in == nil {
return nil
}
out := new(Application)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"Application",
")",
"DeepCopy",
"(",
")",
"*",
"Application",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"Application",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Application. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"Application",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L148-L155 |
161,888 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationCondition) DeepCopy() *ApplicationCondition {
if in == nil {
return nil
}
out := new(ApplicationCondition)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationCondition) DeepCopy() *ApplicationCondition {
if in == nil {
return nil
}
out := new(ApplicationCondition)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationCondition",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationCondition",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationCondition",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationCondition. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationCondition",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L172-L179 |
161,889 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationDestination) DeepCopy() *ApplicationDestination {
if in == nil {
return nil
}
out := new(ApplicationDestination)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationDestination) DeepCopy() *ApplicationDestination {
if in == nil {
return nil
}
out := new(ApplicationDestination)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationDestination",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationDestination",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationDestination",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationDestination. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationDestination",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L188-L195 |
161,890 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationList) DeepCopy() *ApplicationList {
if in == nil {
return nil
}
out := new(ApplicationList)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationList) DeepCopy() *ApplicationList {
if in == nil {
return nil
}
out := new(ApplicationList)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationList",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationList",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationList",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationList. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationList",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L213-L220 |
161,891 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSource) DeepCopy() *ApplicationSource {
if in == nil {
return nil
}
out := new(ApplicationSource)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSource) DeepCopy() *ApplicationSource {
if in == nil {
return nil
}
out := new(ApplicationSource)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSource",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSource",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSource",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSource. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSource",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L262-L269 |
161,892 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourceDirectory) DeepCopy() *ApplicationSourceDirectory {
if in == nil {
return nil
}
out := new(ApplicationSourceDirectory)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourceDirectory) DeepCopy() *ApplicationSourceDirectory {
if in == nil {
return nil
}
out := new(ApplicationSourceDirectory)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourceDirectory",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourceDirectory",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourceDirectory",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceDirectory. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourceDirectory",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L279-L286 |
161,893 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourceHelm) DeepCopy() *ApplicationSourceHelm {
if in == nil {
return nil
}
out := new(ApplicationSourceHelm)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourceHelm) DeepCopy() *ApplicationSourceHelm {
if in == nil {
return nil
}
out := new(ApplicationSourceHelm)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourceHelm",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourceHelm",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourceHelm",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceHelm. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourceHelm",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L305-L312 |
161,894 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourceJsonnet) DeepCopy() *ApplicationSourceJsonnet {
if in == nil {
return nil
}
out := new(ApplicationSourceJsonnet)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourceJsonnet) DeepCopy() *ApplicationSourceJsonnet {
if in == nil {
return nil
}
out := new(ApplicationSourceJsonnet)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourceJsonnet",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourceJsonnet",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourceJsonnet",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceJsonnet. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourceJsonnet",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L331-L338 |
161,895 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourceKsonnet) DeepCopy() *ApplicationSourceKsonnet {
if in == nil {
return nil
}
out := new(ApplicationSourceKsonnet)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourceKsonnet) DeepCopy() *ApplicationSourceKsonnet {
if in == nil {
return nil
}
out := new(ApplicationSourceKsonnet)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourceKsonnet",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourceKsonnet",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourceKsonnet",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceKsonnet. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourceKsonnet",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L352-L359 |
161,896 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourceKustomize) DeepCopy() *ApplicationSourceKustomize {
if in == nil {
return nil
}
out := new(ApplicationSourceKustomize)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourceKustomize) DeepCopy() *ApplicationSourceKustomize {
if in == nil {
return nil
}
out := new(ApplicationSourceKustomize)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourceKustomize",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourceKustomize",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourceKustomize",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceKustomize. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourceKustomize",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L378-L385 |
161,897 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSourcePlugin) DeepCopy() *ApplicationSourcePlugin {
if in == nil {
return nil
}
out := new(ApplicationSourcePlugin)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSourcePlugin) DeepCopy() *ApplicationSourcePlugin {
if in == nil {
return nil
}
out := new(ApplicationSourcePlugin)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSourcePlugin",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSourcePlugin",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSourcePlugin",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourcePlugin. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSourcePlugin",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L394-L401 |
161,898 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationSpec) DeepCopy() *ApplicationSpec {
if in == nil {
return nil
}
out := new(ApplicationSpec)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationSpec) DeepCopy() *ApplicationSpec {
if in == nil {
return nil
}
out := new(ApplicationSpec)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationSpec",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationSpec",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationSpec",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSpec. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationSpec",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L424-L431 |
161,899 | argoproj/argo-cd | pkg/apis/application/v1alpha1/zz_generated.deepcopy.go | DeepCopy | func (in *ApplicationStatus) DeepCopy() *ApplicationStatus {
if in == nil {
return nil
}
out := new(ApplicationStatus)
in.DeepCopyInto(out)
return out
} | go | func (in *ApplicationStatus) DeepCopy() *ApplicationStatus {
if in == nil {
return nil
}
out := new(ApplicationStatus)
in.DeepCopyInto(out)
return out
} | [
"func",
"(",
"in",
"*",
"ApplicationStatus",
")",
"DeepCopy",
"(",
")",
"*",
"ApplicationStatus",
"{",
"if",
"in",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
":=",
"new",
"(",
"ApplicationStatus",
")",
"\n",
"in",
".",
"DeepCopyInto",
"(",
"out",
")",
"\n",
"return",
"out",
"\n",
"}"
] | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationStatus. | [
"DeepCopy",
"is",
"an",
"autogenerated",
"deepcopy",
"function",
"copying",
"the",
"receiver",
"creating",
"a",
"new",
"ApplicationStatus",
"."
] | 5c353a12f2c67d8ab0d5d9aa619c9059c5261640 | https://github.com/argoproj/argo-cd/blob/5c353a12f2c67d8ab0d5d9aa619c9059c5261640/pkg/apis/application/v1alpha1/zz_generated.deepcopy.go#L473-L480 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.