id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c161800 |
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_t... | |
c161801 | err := NewClient(opts)
if err != nil {
log.Fatal(err)
}
return client
} | |
c161802 | 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 appEvent... | |
c161803 | = wrap(rt)
}
return &metricsRoundTripper{roundTripper: rt, metricsServer: server, app: app}
}
return config
} | |
c161804 | nil {
return nil, err
}
return &unstructured.Unstructured{Object: uObj}, nil
} | |
c161805 | {
uObj, err := ToUnstructured(obj)
if err != nil {
panic(err)
}
return uObj
} | |
c161806 | string {
if labels := un.GetLabels(); labels != nil {
return labels[key]
}
return ""
} | |
c161807 | unstructured.RemoveNestedField(target.Object, "metadata", "labels")
} else {
target.SetLabels(labels)
}
}
}
} | |
c161808 | "; if you choose to ignore these errors, turn validation off with --validate=false", "", -1)
s = strings.Replace(s, "error: error", "error", -1)
return s
} | |
c161809 | NewKubeConfig(restConfig, namespace)
return clientcmd.WriteToFile(*kubeConfig, filename)
} | |
c161810 | 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
... | |
c161811 | }
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)
}
contin... | |
c161812 | 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{Objec... | |
c161813 | <-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
} | |
c161814 | = cluster
if cluster.Server == common.KubernetesInternalAPIServerAddr {
hasInClusterCredentials = true
}
}
if !hasInClusterCredentials {
clusterList.Items = append(clusterList.Items, localCluster)
}
return &clusterList, nil
} | |
c161815 | },
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, s... | |
c161816 | 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 {
loc... | |
c161817 | server == common.KubernetesInternalAPIServerAddr {
return &localCluster, nil
} else {
return nil, err
}
}
return secretToCluster(clusterSecret), nil
} | |
c161818 | clusterSecret, err = db.kubeclientset.CoreV1().Secrets(db.ns).Update(clusterSecret)
if err != nil {
return nil, err
}
return secretToCluster(clusterSecret), db.settingsMgr.ResyncInformers()
} | |
c161819 | 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
} | |
c161820 |
configBytes, err := json.Marshal(c.Config)
if err != nil {
panic(err)
}
data["config"] = configBytes
return data
} | |
c161821 | Server: string(s.Data["server"]),
Name: string(s.Data["name"]),
Config: config,
}
return &cluster
} | |
c161822 | {
return "", fmt.Errorf("blank passwords are not allowed")
}
return hashers[0].HashPassword(password)
} | |
c161823 | db,
repoClientset: repoClientset,
enf: enf,
cache: cache,
}
} | |
c161824 | 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
} | |
c161825 |
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
} | |
c161826 | 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 {
re... | |
c161827 | return nil, err
}
_, err := s.db.UpdateRepository(ctx, q.Repo)
return &appsv1.Repository{Repo: q.Repo.Repo}, err
} | |
c161828 |
<-ticker.C
LogStats()
}
}()
} | |
c161829 | syscall.SIGUSR1)
for {
<-sigs
LogStack()
}
}()
} | |
c161830 | {
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)
}
}
}()
} | |
c161831 | TotalAlloc=%v Sys=%v NumGC=%v Goroutines=%d",
m.Alloc/1024, m.TotalAlloc/1024, m.Sys/1024, m.NumGC, runtime.NumGoroutine())
} | |
c161832 | true)
log.Infof("*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
} | |
c161833 | *metrics.MetricsServer,
) AppStateManager {
return &appStateManager{
liveStateCache: liveStateCache,
db: db,
appclientset: appclientset,
kubectl: kubectl,
repoClientset: repoClientset,
namespace: namespace,
settings: settings,
projInformer: projInformer,
metricsSer... | |
c161834 | return RegisterApplicationServiceHandlerClient(ctx, mux, NewApplicationServiceClient(conn))
} | |
c161835 |
}
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
} | |
c161836 | 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
} | |
c161837 | m.auth,
Tags: git.AllTags,
Force: true,
})
if err == git.NoErrAlreadyUpToDate {
return nil
}
return err
} | |
c161838 | element, which is blank regardless of whether we're using nullbyte or newline
ss := strings.Split(out, "\000")
return ss[:len(ss)-1], nil
} | |
c161839 | err
}
if _, err := m.runCmd("git", "clean", "-fdx"); err != nil {
return err
}
return nil
} | |
c161840 | "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 {
... | |
c161841 | return "", err
}
return strings.TrimSpace(out), nil
} | |
c161842 | cmd := exec.Command(command, args...)
return m.runCmdOutput(cmd)
} | |
c161843 | *applications {
return &applications{
client: c.RESTClient(),
ns: namespace,
}
} | |
c161844 | command.AddCommand(NewApplicationDeleteCommand(clientOpts))
command.AddCommand(NewApplicationWaitCommand(clientOpts))
command.AddCommand(NewApplicationManifestsCommand(clientOpts))
command.AddCommand(NewApplicationTerminateOpCommand(clientOpts))
command.AddCommand(NewApplicationEditCommand(clientOpts))
command.Ad... | |
c161845 | 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)
... | |
c161846 | strings.HasSuffix(opts.ServerAddr, ":443") {
server = server[0 : len(server)-4]
}
}
return fmt.Sprintf("%s://%s/applications/%s", scheme, server, appName)
} | |
c161847 |
}
} 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()
} | |
c161848 | 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(er... | |
c161849 |
obj, err := resState.TargetObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | |
c161850 |
obj, err := resState.LiveObject()
if err != nil {
return nil, err
}
objs[i] = obj
}
return objs, nil
} | |
c161851 | key := kube.GetResourceKey(obj)
return p.namespacedByGk[key.GroupKind()], nil
} | |
c161852 | 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
} | |
c161853 | 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.... | |
c161854 | }
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 onl... | |
c161855 | 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 showOperati... | |
c161856 | fmt.Sprintf("%s/%s/%s/%s", rs.Group, rs.Kind, rs.Namespace, rs.Name)
} | |
c161857 | reflect.ValueOf(newState).Elem().FieldByName(field).String()
if newVal != "" && currVal != newVal {
v.SetString(newVal)
updated = true
}
}
return updated
} | |
c161858 |
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().StringV... | |
c161859 | 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(a... | |
c161860 | 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)
... | |
c161861 | ctx := context.Background()
_, err := appIf.TerminateOperation(ctx, &application.OperationTerminateRequest{Name: &appName})
errors.CheckError(err)
fmt.Printf("Application '%s' operation terminating\n", appName)
},
}
return command
} | |
c161862 |
command.AddCommand(NewClusterAddCommand(clientOpts, pathOpts))
command.AddCommand(NewClusterGetCommand(clientOpts))
command.AddCommand(NewClusterListCommand(clientOpts))
command.AddCommand(NewClusterRemoveCommand(clientOpts))
return command
} | |
c161863 | }
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)
... | |
c161864 | 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
} | |
c161865 | 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... | |
c161866 | *Server {
return &Server{
sessionMgr: sessionMgr,
settingsMgr: settingsMgr,
}
} | |
c161867 | := 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... | |
c161868 | vers.GitTag,
GitTreeState: vers.GitTreeState,
GoVersion: vers.GoVersion,
Compiler: vers.Compiler,
Platform: vers.Platform,
KsonnetVersion: ksonnetVersion,
}, nil
} | |
c161869 | roleCommand.AddCommand(NewProjectRoleDeleteCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleCreateTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleDeleteTokenCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleAddPolicyCommand(clientOpts))
roleCommand.AddCommand(NewProjectRoleRemovePol... | |
c161870 | 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)
},
}
add... | |
c161871 | {
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("R... | |
c161872 | 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, Exp... | |
c161873 |
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
} | |
c161874 | 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\tDESCRIPT... | |
c161875 | "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.JW... | |
c161876 | {
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
} | |
c161877 | &RBACPolicyEnforcer{
enf: enf,
projLister: projLister,
}
} | |
c161878 | 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{}{g... | |
c161879 | _, _, 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...... | |
c161880 | 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, cluste... | |
c161881 | Provider {
return &providerImpl{
issuerURL: issuerURL,
client: client,
}
} | |
c161882 |
}
prov, err := p.newGoOIDCProvider()
if err != nil {
return nil, err
}
p.goOIDCProvider = prov
return p.goOIDCProvider, nil
} | |
c161883 |
out := new(AWSAuthConfig)
in.DeepCopyInto(out)
return out
} | |
c161884 | out := new(AppProject)
in.DeepCopyInto(out)
return out
} | |
c161885 |
out := new(AppProjectList)
in.DeepCopyInto(out)
return out
} | |
c161886 |
out := new(AppProjectSpec)
in.DeepCopyInto(out)
return out
} | |
c161887 | out := new(Application)
in.DeepCopyInto(out)
return out
} | |
c161888 |
}
out := new(ApplicationCondition)
in.DeepCopyInto(out)
return out
} | |
c161889 | if in == nil {
return nil
}
out := new(ApplicationDestination)
in.DeepCopyInto(out)
return out
} | |
c161890 |
out := new(ApplicationList)
in.DeepCopyInto(out)
return out
} | |
c161891 | }
out := new(ApplicationSource)
in.DeepCopyInto(out)
return out
} | |
c161892 |
if in == nil {
return nil
}
out := new(ApplicationSourceDirectory)
in.DeepCopyInto(out)
return out
} | |
c161893 | if in == nil {
return nil
}
out := new(ApplicationSourceHelm)
in.DeepCopyInto(out)
return out
} | |
c161894 |
if in == nil {
return nil
}
out := new(ApplicationSourceJsonnet)
in.DeepCopyInto(out)
return out
} | |
c161895 |
if in == nil {
return nil
}
out := new(ApplicationSourceKsonnet)
in.DeepCopyInto(out)
return out
} | |
c161896 |
if in == nil {
return nil
}
out := new(ApplicationSourceKustomize)
in.DeepCopyInto(out)
return out
} | |
c161897 |
if in == nil {
return nil
}
out := new(ApplicationSourcePlugin)
in.DeepCopyInto(out)
return out
} | |
c161898 |
out := new(ApplicationSpec)
in.DeepCopyInto(out)
return out
} | |
c161899 | }
out := new(ApplicationStatus)
in.DeepCopyInto(out)
return out
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.