You've already forked woodpecker
							
							
				mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-30 23:27:39 +02:00 
			
		
		
		
	Lowercase all log strings (#3173)
from #3161 --------- Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		| @@ -57,6 +57,6 @@ func logLevel(c *cli.Context) error { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	log.Info().Msgf("Logging level: %s", ll.Level) | ||||
| 	log.Info().Msgf("logging level: %s", ll.Level) | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
| @@ -121,15 +121,15 @@ func run(c *cli.Context) error { | ||||
|  | ||||
| 	agentConfigPersisted := abool.New() | ||||
| 	ctx = utils.WithContextSigtermCallback(ctx, func() { | ||||
| 		log.Info().Msg("Termination signal is received, shutting down") | ||||
| 		log.Info().Msg("termination signal is received, shutting down") | ||||
| 		sigterm.Set() | ||||
|  | ||||
| 		// Remove stateless agents from server | ||||
| 		if agentConfigPersisted.IsNotSet() { | ||||
| 			log.Debug().Msg("Unregistering agent from server") | ||||
| 			log.Debug().Msg("unregistering agent from server") | ||||
| 			err := client.UnregisterAgent(ctx) | ||||
| 			if err != nil { | ||||
| 				log.Err(err).Msg("Failed to unregister agent from server") | ||||
| 				log.Err(err).Msg("failed to unregister agent from server") | ||||
| 			} | ||||
| 		} | ||||
| 	}) | ||||
| @@ -142,7 +142,7 @@ func run(c *cli.Context) error { | ||||
| 	} | ||||
| 	if grpcServerVersion.GrpcVersion != agentRpc.ClientGrpcVersion { | ||||
| 		err := errors.New("GRPC version mismatch") | ||||
| 		log.Error().Err(err).Msgf("Server version %s does report grpc version %d but we only understand %d", | ||||
| 		log.Error().Err(err).Msgf("server version %s does report grpc version %d but we only understand %d", | ||||
| 			grpcServerVersion.ServerVersion, | ||||
| 			grpcServerVersion.GrpcVersion, | ||||
| 			agentRpc.ClientGrpcVersion) | ||||
| @@ -199,18 +199,18 @@ func run(c *cli.Context) error { | ||||
| 		Labels: labels, | ||||
| 	} | ||||
|  | ||||
| 	log.Debug().Msgf("Agent registered with ID %d", agentConfig.AgentID) | ||||
| 	log.Debug().Msgf("agent registered with ID %d", agentConfig.AgentID) | ||||
|  | ||||
| 	go func() { | ||||
| 		for { | ||||
| 			if sigterm.IsSet() { | ||||
| 				log.Debug().Msg("Terminating health reporting") | ||||
| 				log.Debug().Msg("terminating health reporting") | ||||
| 				return | ||||
| 			} | ||||
|  | ||||
| 			err := client.ReportHealth(ctx) | ||||
| 			if err != nil { | ||||
| 				log.Err(err).Msg("Failed to report health") | ||||
| 				log.Err(err).Msg("failed to report health") | ||||
| 				return | ||||
| 			} | ||||
|  | ||||
| @@ -242,7 +242,7 @@ func run(c *cli.Context) error { | ||||
| 	} | ||||
|  | ||||
| 	log.Info().Msgf( | ||||
| 		"Starting Woodpecker agent with version '%s' and backend '%s' using platform '%s' running up to %d pipelines in parallel", | ||||
| 		"starting Woodpecker agent with version '%s' and backend '%s' using platform '%s' running up to %d pipelines in parallel", | ||||
| 		version.String(), backendEngine.Name(), engInfo.Platform, parallel) | ||||
|  | ||||
| 	wg.Wait() | ||||
|   | ||||
| @@ -266,7 +266,7 @@ func run(c *cli.Context) error { | ||||
| 		}) | ||||
| 	} | ||||
|  | ||||
| 	log.Info().Msgf("Starting Woodpecker server with version '%s'", version.String()) | ||||
| 	log.Info().Msgf("starting Woodpecker server with version '%s'", version.String()) | ||||
|  | ||||
| 	return g.Wait() | ||||
| } | ||||
|   | ||||
| @@ -187,7 +187,7 @@ func setupBitbucket(c *cli.Context) (forge.Forge, error) { | ||||
| 		Client: c.String("bitbucket-client"), | ||||
| 		Secret: c.String("bitbucket-secret"), | ||||
| 	} | ||||
| 	log.Trace().Msgf("Forge (bitbucket) opts: %#v", opts) | ||||
| 	log.Trace().Msgf("forge (bitbucket) opts: %#v", opts) | ||||
| 	return bitbucket.New(opts) | ||||
| } | ||||
|  | ||||
| @@ -206,7 +206,7 @@ func setupGitea(c *cli.Context) (forge.Forge, error) { | ||||
| 	if len(opts.URL) == 0 { | ||||
| 		return nil, fmt.Errorf("WOODPECKER_GITEA_URL must be set") | ||||
| 	} | ||||
| 	log.Trace().Msgf("Forge (gitea) opts: %#v", opts) | ||||
| 	log.Trace().Msgf("forge (gitea) opts: %#v", opts) | ||||
| 	return gitea.New(opts) | ||||
| } | ||||
|  | ||||
| @@ -229,7 +229,7 @@ func setupGitHub(c *cli.Context) (forge.Forge, error) { | ||||
| 		SkipVerify: c.Bool("github-skip-verify"), | ||||
| 		MergeRef:   c.Bool("github-merge-ref"), | ||||
| 	} | ||||
| 	log.Trace().Msgf("Forge (github) opts: %#v", opts) | ||||
| 	log.Trace().Msgf("forge (github) opts: %#v", opts) | ||||
| 	return github.New(opts) | ||||
| } | ||||
|  | ||||
| @@ -307,7 +307,7 @@ func setupSignatureKeys(_store store.Store) (crypto.PrivateKey, crypto.PublicKey | ||||
| 		if err != nil { | ||||
| 			return nil, nil, fmt.Errorf("failed to store private key: %w", err) | ||||
| 		} | ||||
| 		log.Debug().Msg("Created private key") | ||||
| 		log.Debug().Msg("created private key") | ||||
| 		return privKey, privKey.Public(), nil | ||||
| 	} else if err != nil { | ||||
| 		return nil, nil, fmt.Errorf("failed to load private key: %w", err) | ||||
|   | ||||
| @@ -184,7 +184,7 @@ func (e *kube) SetupWorkflow(ctx context.Context, conf *types.Config, taskUUID s | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	log.Trace().Msgf("Adding extra hosts: %v", extraHosts) | ||||
| 	log.Trace().Msgf("adding extra hosts: %v", extraHosts) | ||||
| 	for _, stage := range conf.Stages { | ||||
| 		for _, step := range stage.Steps { | ||||
| 			step.ExtraHosts = extraHosts | ||||
| @@ -201,7 +201,7 @@ func (e *kube) StartStep(ctx context.Context, step *types.Step, taskUUID string) | ||||
| 		log.Trace().Msgf("StartStep got service '%s', ignoring it.", step.Name) | ||||
| 		return nil | ||||
| 	} | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("Starting step: %s", step.Name) | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("starting step: %s", step.Name) | ||||
| 	_, err := startPod(ctx, e, step) | ||||
| 	return err | ||||
| } | ||||
| @@ -214,7 +214,7 @@ func (e *kube) WaitStep(ctx context.Context, step *types.Step, taskUUID string) | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("Waiting for pod: %s", podName) | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("waiting for pod: %s", podName) | ||||
|  | ||||
| 	finished := make(chan bool) | ||||
|  | ||||
| @@ -274,7 +274,7 @@ func (e *kube) TailStep(ctx context.Context, step *types.Step, taskUUID string) | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("Tail logs of pod: %s", podName) | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("tail logs of pod: %s", podName) | ||||
|  | ||||
| 	up := make(chan bool) | ||||
|  | ||||
| @@ -340,14 +340,14 @@ func (e *kube) DestroyStep(_ context.Context, step *types.Step, taskUUID string) | ||||
| 		log.Trace().Msgf("DestroyStep got service '%s', ignoring it.", step.Name) | ||||
| 		return nil | ||||
| 	} | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("Stopping step: %s", step.Name) | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msgf("stopping step: %s", step.Name) | ||||
| 	err := stopPod(e.ctx, e, step, defaultDeleteOptions) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // Destroy the pipeline environment. | ||||
| func (e *kube) DestroyWorkflow(_ context.Context, conf *types.Config, taskUUID string) error { | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msg("Deleting Kubernetes primitives") | ||||
| 	log.Trace().Str("taskUUID", taskUUID).Msg("deleting Kubernetes primitives") | ||||
|  | ||||
| 	// Use noContext because the ctx sent to this function will be canceled/done in case of error or canceled by user. | ||||
| 	for _, stage := range conf.Stages { | ||||
|   | ||||
| @@ -205,7 +205,7 @@ func hostAlias(extraHost types.HostAlias) v1.HostAlias { | ||||
| } | ||||
|  | ||||
| func imagePullSecretsReferences(imagePullSecretNames []string) []v1.LocalObjectReference { | ||||
| 	log.Trace().Msgf("Using the image pull secrets: %v", imagePullSecretNames) | ||||
| 	log.Trace().Msgf("using the image pull secrets: %v", imagePullSecretNames) | ||||
|  | ||||
| 	secretReferences := make([]v1.LocalObjectReference, len(imagePullSecretNames)) | ||||
| 	for i, imagePullSecretName := range imagePullSecretNames { | ||||
| @@ -256,11 +256,11 @@ func nodeSelector(backendNodeSelector map[string]string, platform string) map[st | ||||
| 	if platform != "" { | ||||
| 		arch := strings.Split(platform, "/")[1] | ||||
| 		nodeSelector[v1.LabelArchStable] = arch | ||||
| 		log.Trace().Msgf("Using the node selector from the Agent's platform: %v", nodeSelector) | ||||
| 		log.Trace().Msgf("using the node selector from the Agent's platform: %v", nodeSelector) | ||||
| 	} | ||||
|  | ||||
| 	if len(backendNodeSelector) > 0 { | ||||
| 		log.Trace().Msgf("Appending labels to the node selector from the backend options: %v", backendNodeSelector) | ||||
| 		log.Trace().Msgf("appending labels to the node selector from the backend options: %v", backendNodeSelector) | ||||
| 		maps.Copy(nodeSelector, backendNodeSelector) | ||||
| 	} | ||||
|  | ||||
| @@ -271,7 +271,7 @@ func tolerations(backendTolerations []types.Toleration) []v1.Toleration { | ||||
| 	var tolerations []v1.Toleration | ||||
|  | ||||
| 	if len(backendTolerations) > 0 { | ||||
| 		log.Trace().Msgf("Tolerations that will be used in the backend options: %v", backendTolerations) | ||||
| 		log.Trace().Msgf("tolerations that will be used in the backend options: %v", backendTolerations) | ||||
| 		for _, backendToleration := range backendTolerations { | ||||
| 			toleration := toleration(backendToleration) | ||||
| 			tolerations = append(tolerations, toleration) | ||||
| @@ -323,7 +323,7 @@ func podSecurityContext(sc *types.SecurityContext, secCtxConf SecurityContextCon | ||||
| 		RunAsGroup:   group, | ||||
| 		FSGroup:      fsGroup, | ||||
| 	} | ||||
| 	log.Trace().Msgf("Pod security context that will be used: %v", securityContext) | ||||
| 	log.Trace().Msgf("pod security context that will be used: %v", securityContext) | ||||
| 	return securityContext | ||||
| } | ||||
|  | ||||
| @@ -343,7 +343,7 @@ func containerSecurityContext(sc *types.SecurityContext, stepPrivileged bool) *v | ||||
| 	securityContext := &v1.SecurityContext{ | ||||
| 		Privileged: privileged, | ||||
| 	} | ||||
| 	log.Trace().Msgf("Container security context that will be used: %v", securityContext) | ||||
| 	log.Trace().Msgf("container security context that will be used: %v", securityContext) | ||||
| 	return securityContext | ||||
| } | ||||
|  | ||||
| @@ -368,7 +368,7 @@ func startPod(ctx context.Context, engine *kube, step *types.Step) (*v1.Pod, err | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	log.Trace().Msgf("Creating pod: %s", pod.Name) | ||||
| 	log.Trace().Msgf("creating pod: %s", pod.Name) | ||||
| 	return engine.client.CoreV1().Pods(engine.config.Namespace).Create(ctx, pod, metav1.CreateOptions{}) | ||||
| } | ||||
|  | ||||
| @@ -377,7 +377,7 @@ func stopPod(ctx context.Context, engine *kube, step *types.Step, deleteOpts met | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	log.Trace().Str("name", podName).Msg("Deleting pod") | ||||
| 	log.Trace().Str("name", podName).Msg("deleting pod") | ||||
|  | ||||
| 	err = engine.client.CoreV1().Pods(engine.config.Namespace).Delete(ctx, podName, deleteOpts) | ||||
| 	if errors.IsNotFound(err) { | ||||
|   | ||||
| @@ -19,11 +19,12 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" | ||||
| 	v1 "k8s.io/api/core/v1" | ||||
| 	"k8s.io/apimachinery/pkg/api/errors" | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| 	"k8s.io/apimachinery/pkg/util/intstr" | ||||
|  | ||||
| 	"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -81,12 +82,12 @@ func stopService(ctx context.Context, engine *kube, step *types.Step, deleteOpts | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	log.Trace().Str("name", svcName).Msg("Deleting service") | ||||
| 	log.Trace().Str("name", svcName).Msg("deleting service") | ||||
|  | ||||
| 	err = engine.client.CoreV1().Services(engine.config.Namespace).Delete(ctx, svcName, deleteOpts) | ||||
| 	if errors.IsNotFound(err) { | ||||
| 		// Don't abort on 404 errors from k8s, they most likely mean that the pod hasn't been created yet, usually because pipeline was canceled before running all steps. | ||||
| 		log.Trace().Err(err).Msgf("Unable to delete service %s", svcName) | ||||
| 		log.Trace().Err(err).Msgf("unable to delete service %s", svcName) | ||||
| 		return nil | ||||
| 	} | ||||
| 	return err | ||||
|   | ||||
| @@ -81,7 +81,7 @@ func startVolume(ctx context.Context, engine *kube, name string) (*v1.Persistent | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	log.Trace().Msgf("Creating volume: %s", pvc.Name) | ||||
| 	log.Trace().Msgf("creating volume: %s", pvc.Name) | ||||
| 	return engine.client.CoreV1().PersistentVolumeClaims(engine.config.Namespace).Create(ctx, pvc, metav1.CreateOptions{}) | ||||
| } | ||||
|  | ||||
| @@ -90,12 +90,12 @@ func stopVolume(ctx context.Context, engine *kube, name string, deleteOpts metav | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	log.Trace().Str("name", pvcName).Msg("Deleting volume") | ||||
| 	log.Trace().Str("name", pvcName).Msg("deleting volume") | ||||
|  | ||||
| 	err = engine.client.CoreV1().PersistentVolumeClaims(engine.config.Namespace).Delete(ctx, pvcName, deleteOpts) | ||||
| 	if errors.IsNotFound(err) { | ||||
| 		// Don't abort on 404 errors from k8s, they most likely mean that the pod hasn't been created yet, usually because pipeline was canceled before running all steps. | ||||
| 		log.Trace().Err(err).Msgf("Unable to delete service %s", pvcName) | ||||
| 		log.Trace().Err(err).Msgf("unable to delete service %s", pvcName) | ||||
| 		return nil | ||||
| 	} | ||||
| 	return err | ||||
|   | ||||
| @@ -92,7 +92,7 @@ func (r *Runtime) MakeLogger() zerolog.Logger { | ||||
| // Starts the execution of an workflow and waits for it to complete | ||||
| func (r *Runtime) Run(runnerCtx context.Context) error { | ||||
| 	logger := r.MakeLogger() | ||||
| 	logger.Debug().Msgf("Executing %d stages, in order of:", len(r.spec.Stages)) | ||||
| 	logger.Debug().Msgf("executing %d stages, in order of:", len(r.spec.Stages)) | ||||
| 	for stagePos, stage := range r.spec.Stages { | ||||
| 		stepNames := []string{} | ||||
| 		for _, step := range stage.Steps { | ||||
|   | ||||
| @@ -80,7 +80,7 @@ func HandleAuth(c *gin.Context) { | ||||
| 		if server.Config.Permissions.Orgs.IsConfigured { | ||||
| 			teams, terr := _forge.Teams(c, tmpuser) | ||||
| 			if terr != nil || !server.Config.Permissions.Orgs.IsMember(teams) { | ||||
| 				log.Error().Err(terr).Msgf("cannot verify team membership for %s.", u.Login) | ||||
| 				log.Error().Err(terr).Msgf("cannot verify team membership for %s", u.Login) | ||||
| 				c.Redirect(303, server.Config.Server.RootPath+"/login?error=access_denied") | ||||
| 				return | ||||
| 			} | ||||
| @@ -130,7 +130,7 @@ func HandleAuth(c *gin.Context) { | ||||
| 	if server.Config.Permissions.Orgs.IsConfigured { | ||||
| 		teams, terr := _forge.Teams(c, u) | ||||
| 		if terr != nil || !server.Config.Permissions.Orgs.IsMember(teams) { | ||||
| 			log.Error().Err(terr).Msgf("cannot verify team membership for %s.", u.Login) | ||||
| 			log.Error().Err(terr).Msgf("cannot verify team membership for %s", u.Login) | ||||
| 			c.Redirect(http.StatusSeeOther, server.Config.Server.RootPath+"/login?error=access_denied") | ||||
| 			return | ||||
| 		} | ||||
| @@ -166,7 +166,7 @@ func HandleAuth(c *gin.Context) { | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		log.Debug().Msgf("Synced user permission for %s %s", u.Login, dbRepo.FullName) | ||||
| 		log.Debug().Msgf("synced user permission for %s %s", u.Login, dbRepo.FullName) | ||||
| 		perm := forgeRepo.Perm | ||||
| 		perm.Repo = dbRepo | ||||
| 		perm.RepoID = dbRepo.ID | ||||
|   | ||||
| @@ -140,7 +140,7 @@ func LookupOrg(c *gin.Context) { | ||||
| 		} else if !user.Admin { | ||||
| 			perm, err := server.Config.Services.Membership.Get(c, user, org.Name) | ||||
| 			if err != nil { | ||||
| 				log.Error().Err(err).Msg("Failed to check membership") | ||||
| 				log.Error().Err(err).Msg("failed to check membership") | ||||
| 				c.Status(http.StatusInternalServerError) | ||||
| 				return | ||||
| 			} | ||||
|   | ||||
| @@ -61,7 +61,7 @@ func PostRepo(c *gin.Context) { | ||||
| 		c.String(http.StatusConflict, "Repository is already active.") | ||||
| 		return | ||||
| 	} else if err != nil && !errors.Is(err, types.RecordNotExist) { | ||||
| 		msg := "Could not get repo by remote id from store." | ||||
| 		msg := "could not get repo by remote id from store." | ||||
| 		log.Error().Err(err).Msg(msg) | ||||
| 		c.String(http.StatusInternalServerError, msg) | ||||
| 		return | ||||
| @@ -115,7 +115,7 @@ func PostRepo(c *gin.Context) { | ||||
| 	t := token.New(token.HookToken, repo.FullName) | ||||
| 	sig, err := t.Sign(repo.Hash) | ||||
| 	if err != nil { | ||||
| 		msg := "Could not generate new jwt token." | ||||
| 		msg := "could not generate new jwt token." | ||||
| 		log.Error().Err(err).Msg(msg) | ||||
| 		c.String(http.StatusInternalServerError, msg) | ||||
| 		return | ||||
| @@ -139,7 +139,7 @@ func PostRepo(c *gin.Context) { | ||||
| 	if errors.Is(err, types.RecordNotExist) { | ||||
| 		org, err = forge.Org(c, user, repo.Owner) | ||||
| 		if err != nil { | ||||
| 			msg := "Could not fetch organization from forge." | ||||
| 			msg := "could not fetch organization from forge." | ||||
| 			log.Error().Err(err).Msg(msg) | ||||
| 			c.String(http.StatusInternalServerError, msg) | ||||
| 			return | ||||
| @@ -147,7 +147,7 @@ func PostRepo(c *gin.Context) { | ||||
|  | ||||
| 		err = _store.OrgCreate(org) | ||||
| 		if err != nil { | ||||
| 			msg := "Could not create organization in store." | ||||
| 			msg := "could not create organization in store." | ||||
| 			log.Error().Err(err).Msg(msg) | ||||
| 			c.String(http.StatusInternalServerError, msg) | ||||
| 			return | ||||
| @@ -158,7 +158,7 @@ func PostRepo(c *gin.Context) { | ||||
|  | ||||
| 	err = forge.Activate(c, user, repo, hookURL) | ||||
| 	if err != nil { | ||||
| 		msg := "Could not create webhook in forge." | ||||
| 		msg := "could not create webhook in forge." | ||||
| 		log.Error().Err(err).Msg(msg) | ||||
| 		c.String(http.StatusInternalServerError, msg) | ||||
| 		return | ||||
| @@ -170,7 +170,7 @@ func PostRepo(c *gin.Context) { | ||||
| 		err = _store.CreateRepo(repo) | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		msg := "Could not create/update repo in store." | ||||
| 		msg := "could not create/update repo in store." | ||||
| 		log.Error().Err(err).Msg(msg) | ||||
| 		c.String(http.StatusInternalServerError, msg) | ||||
| 		return | ||||
|   | ||||
| @@ -45,7 +45,7 @@ func Start(ctx context.Context, store store.Store, forge forge.Forge) error { | ||||
| 		case <-time.After(checkTime): | ||||
| 			go func() { | ||||
| 				now := time.Now() | ||||
| 				log.Trace().Msg("Cron: fetch next crons") | ||||
| 				log.Trace().Msg("cron: fetch next crons") | ||||
|  | ||||
| 				crons, err := store.CronListNextExecute(now.Unix(), checkItems) | ||||
| 				if err != nil { | ||||
| @@ -78,7 +78,7 @@ func CalcNewNext(schedule string, now time.Time) (time.Time, error) { | ||||
| } | ||||
|  | ||||
| func runCron(store store.Store, forge forge.Forge, cron *model.Cron, now time.Time) error { | ||||
| 	log.Trace().Msgf("Cron: run id[%d]", cron.ID) | ||||
| 	log.Trace().Msgf("cron: run id[%d]", cron.ID) | ||||
| 	ctx := context.Background() | ||||
|  | ||||
| 	newNext, err := CalcNewNext(cron.Schedule, now) | ||||
|   | ||||
| @@ -57,7 +57,7 @@ func NewConfigFetcher(forge Forge, timeout time.Duration, configExtension config | ||||
|  | ||||
| // Fetch pipeline config from source forge | ||||
| func (cf *configFetcher) Fetch(ctx context.Context) (files []*types.FileMeta, err error) { | ||||
| 	log.Trace().Msgf("Start Fetching config for '%s'", cf.repo.FullName) | ||||
| 	log.Trace().Msgf("start fetching config for '%s'", cf.repo.FullName) | ||||
|  | ||||
| 	// try to fetch 3 times | ||||
| 	for i := 0; i < 3; i++ { | ||||
| @@ -73,7 +73,7 @@ func (cf *configFetcher) Fetch(ctx context.Context) (files []*types.FileMeta, er | ||||
| 			fetchCtx, cancel := context.WithTimeout(ctx, cf.timeout) | ||||
| 			defer cancel() // ok here as we only try http fetching once, returning on fail and success | ||||
|  | ||||
| 			log.Trace().Msgf("ConfigFetch[%s]: getting config from external http service", cf.repo.FullName) | ||||
| 			log.Trace().Msgf("configFetcher[%s]: getting config from external http service", cf.repo.FullName) | ||||
| 			netrc, err := cf.forge.Netrc(cf.user, cf.repo) | ||||
| 			if err != nil { | ||||
| 				return nil, fmt.Errorf("could not get Netrc data from forge: %w", err) | ||||
| @@ -101,7 +101,7 @@ func (cf *configFetcher) fetch(c context.Context, timeout time.Duration, config | ||||
| 	defer cancel() | ||||
|  | ||||
| 	if len(config) > 0 { | ||||
| 		log.Trace().Msgf("ConfigFetch[%s]: use user config '%s'", cf.repo.FullName, config) | ||||
| 		log.Trace().Msgf("configFetcher[%s]: use user config '%s'", cf.repo.FullName, config) | ||||
|  | ||||
| 		// could be adapted to allow the user to supply a list like we do in the defaults | ||||
| 		configs := []string{config} | ||||
| @@ -114,7 +114,7 @@ func (cf *configFetcher) fetch(c context.Context, timeout time.Duration, config | ||||
| 		return nil, fmt.Errorf("user defined config '%s' not found: %w", config, err) | ||||
| 	} | ||||
|  | ||||
| 	log.Trace().Msgf("ConfigFetch[%s]: user did not define own config, following default procedure", cf.repo.FullName) | ||||
| 	log.Trace().Msgf("configFetcher[%s]: user did not define own config, following default procedure", cf.repo.FullName) | ||||
| 	// for the order see shared/constants/constants.go | ||||
| 	fileMeta, err := cf.getFirstAvailableConfig(ctx, constant.DefaultConfigOrder[:]) | ||||
| 	if err == nil { | ||||
| @@ -145,7 +145,7 @@ func (cf *configFetcher) checkPipelineFile(c context.Context, config string) ([] | ||||
| 	file, err := cf.forge.File(c, cf.user, cf.repo, cf.pipeline, config) | ||||
|  | ||||
| 	if err == nil && len(file) != 0 { | ||||
| 		log.Trace().Msgf("ConfigFetch[%s]: found file '%s'", cf.repo.FullName, config) | ||||
| 		log.Trace().Msgf("configFetcher[%s]: found file '%s'", cf.repo.FullName, config) | ||||
|  | ||||
| 		return []*types.FileMeta{{ | ||||
| 			Name: config, | ||||
| @@ -172,14 +172,14 @@ func (cf *configFetcher) getFirstAvailableConfig(c context.Context, configs []st | ||||
| 			} | ||||
| 			files = filterPipelineFiles(files) | ||||
| 			if len(files) != 0 { | ||||
| 				log.Trace().Msgf("ConfigFetch[%s]: found %d files in '%s'", cf.repo.FullName, len(files), fileOrFolder) | ||||
| 				log.Trace().Msgf("configFetcher[%s]: found %d files in '%s'", cf.repo.FullName, len(files), fileOrFolder) | ||||
| 				return files, nil | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// config is a file | ||||
| 		if fileMeta, err := cf.checkPipelineFile(c, fileOrFolder); err == nil { | ||||
| 			log.Trace().Msgf("ConfigFetch[%s]: found file: '%s'", cf.repo.FullName, fileOrFolder) | ||||
| 			log.Trace().Msgf("configFetcher[%s]: found file: '%s'", cf.repo.FullName, fileOrFolder) | ||||
| 			return fileMeta, nil | ||||
| 		} else if !errors.Is(err, &types.ErrConfigNotFound{}) { | ||||
| 			forgeErr = append(forgeErr, err) | ||||
|   | ||||
| @@ -369,7 +369,7 @@ func (c *client) Org(ctx context.Context, u *model.User, owner string) (*model.O | ||||
| 	client := c.newClientToken(ctx, u.Token) | ||||
|  | ||||
| 	user, _, err := client.Users.Get(ctx, owner) | ||||
| 	log.Trace().Msgf("Github user for owner %s = %v", owner, user) | ||||
| 	log.Trace().Msgf("GitHub user for owner %s = %v", owner, user) | ||||
| 	if user != nil && err == nil { | ||||
| 		return &model.Org{ | ||||
| 			Name:   user.GetLogin(), | ||||
| @@ -378,7 +378,7 @@ func (c *client) Org(ctx context.Context, u *model.User, owner string) (*model.O | ||||
| 	} | ||||
|  | ||||
| 	org, _, err := client.Organizations.Get(ctx, owner) | ||||
| 	log.Trace().Msgf("Github organization for owner %s = %v", owner, org) | ||||
| 	log.Trace().Msgf("GitHub organization for owner %s = %v", owner, org) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -69,7 +69,7 @@ func (s *WoodpeckerAuthServer) getAgent(agentID int64, agentToken string) (*mode | ||||
| 			agent.Capacity = -1 | ||||
| 			err := s.store.AgentCreate(agent) | ||||
| 			if err != nil { | ||||
| 				log.Error().Err(err).Msg("Error creating system agent") | ||||
| 				log.Error().Err(err).Msg("error creating system agent") | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			return agent, nil | ||||
|   | ||||
| @@ -169,7 +169,7 @@ func (s *RPC) Init(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	workflow, err := s.store.WorkflowLoad(stepID) | ||||
| 	if err != nil { | ||||
| 		log.Error().Msgf("error: cannot find step with id %d: %s", stepID, err) | ||||
| 		log.Error().Err(err).Msgf("cannot find step with id %d", stepID) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| @@ -181,19 +181,19 @@ func (s *RPC) Init(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	currentPipeline, err := s.store.GetPipeline(workflow.PipelineID) | ||||
| 	if err != nil { | ||||
| 		log.Error().Msgf("error: cannot find pipeline with id %d: %s", workflow.PipelineID, err) | ||||
| 		log.Error().Err(err).Msgf("cannot find pipeline with id %d", workflow.PipelineID) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	repo, err := s.store.GetRepo(currentPipeline.RepoID) | ||||
| 	if err != nil { | ||||
| 		log.Error().Msgf("error: cannot find repo with id %d: %s", currentPipeline.RepoID, err) | ||||
| 		log.Error().Err(err).Msgf("cannot find repo with id %d", currentPipeline.RepoID) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if currentPipeline.Status == model.StatusPending { | ||||
| 		if currentPipeline, err = pipeline.UpdateToStatusRunning(s.store, *currentPipeline, state.Started); err != nil { | ||||
| 			log.Error().Msgf("error: init: cannot update build_id %d state: %s", currentPipeline.ID, err) | ||||
| 			log.Error().Err(err).Msgf("init: cannot update build_id %d state", currentPipeline.ID) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -401,7 +401,7 @@ func (s *RPC) completeChildrenIfParentCompleted(completedWorkflow *model.Workflo | ||||
| 	for _, c := range completedWorkflow.Children { | ||||
| 		if c.Running() { | ||||
| 			if _, err := pipeline.UpdateStepToStatusSkipped(s.store, *c, completedWorkflow.Stopped); err != nil { | ||||
| 				log.Error().Msgf("error: done: cannot update step_id %d child state: %s", c.ID, err) | ||||
| 				log.Error().Err(err).Msgf("done: cannot update step_id %d child state", c.ID) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
| @@ -33,23 +33,23 @@ import ( | ||||
| func parsePipeline(store store.Store, currentPipeline *model.Pipeline, user *model.User, repo *model.Repo, yamls []*forge_types.FileMeta, envs map[string]string) ([]*stepbuilder.Item, error) { | ||||
| 	netrc, err := server.Config.Services.Forge.Netrc(user, repo) | ||||
| 	if err != nil { | ||||
| 		log.Error().Err(err).Msg("Failed to generate netrc file") | ||||
| 		log.Error().Err(err).Msg("failed to generate netrc file") | ||||
| 	} | ||||
|  | ||||
| 	// get the previous pipeline so that we can send status change notifications | ||||
| 	last, err := store.GetPipelineLastBefore(repo, currentPipeline.Branch, currentPipeline.ID) | ||||
| 	if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||||
| 		log.Error().Err(err).Str("repo", repo.FullName).Msgf("Error getting last pipeline before pipeline number '%d'", currentPipeline.Number) | ||||
| 		log.Error().Err(err).Str("repo", repo.FullName).Msgf("error getting last pipeline before pipeline number '%d'", currentPipeline.Number) | ||||
| 	} | ||||
|  | ||||
| 	secs, err := server.Config.Services.Secrets.SecretListPipeline(repo, currentPipeline, &model.ListOptions{All: true}) | ||||
| 	if err != nil { | ||||
| 		log.Error().Err(err).Msgf("Error getting secrets for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 		log.Error().Err(err).Msgf("error getting secrets for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 	} | ||||
|  | ||||
| 	regs, err := server.Config.Services.Registries.RegistryList(repo, &model.ListOptions{All: true}) | ||||
| 	if err != nil { | ||||
| 		log.Error().Err(err).Msgf("Error getting registry credentials for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 		log.Error().Err(err).Msgf("error getting registry credentials for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 	} | ||||
|  | ||||
| 	if envs == nil { | ||||
| @@ -94,7 +94,7 @@ func createPipelineItems(c context.Context, store store.Store, | ||||
| 	if pipeline_errors.HasBlockingErrors(err) { | ||||
| 		currentPipeline, uerr := UpdateToStatusError(store, *currentPipeline, err) | ||||
| 		if uerr != nil { | ||||
| 			log.Error().Err(uerr).Msgf("Error setting error status of pipeline for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 			log.Error().Err(uerr).Msgf("error setting error status of pipeline for %s#%d", repo.FullName, currentPipeline.Number) | ||||
| 		} else { | ||||
| 			updatePipelineStatus(c, currentPipeline, repo, user) | ||||
| 		} | ||||
|   | ||||
| @@ -29,7 +29,7 @@ func start(ctx context.Context, store store.Store, activePipeline *model.Pipelin | ||||
| 	// call to cancel previous pipelines if needed | ||||
| 	if err := cancelPreviousPipelines(ctx, store, activePipeline, repo, user); err != nil { | ||||
| 		// should be not breaking | ||||
| 		log.Error().Err(err).Msg("Failed to cancel previous pipelines") | ||||
| 		log.Error().Err(err).Msg("failed to cancel previous pipelines") | ||||
| 	} | ||||
|  | ||||
| 	if err := store.WorkflowsCreate(activePipeline.Workflows); err != nil { | ||||
|   | ||||
| @@ -154,12 +154,12 @@ func (b *StepBuilder) genItemForWorkflow(workflow *model.Workflow, axis matrix.A | ||||
| 	// checking if filtered. | ||||
| 	if match, err := parsed.When.Match(workflowMetadata, true, environ); !match && err == nil { | ||||
| 		log.Debug().Str("pipeline", workflow.Name).Msg( | ||||
| 			"Marked as skipped, does not match metadata", | ||||
| 			"marked as skipped, does not match metadata", | ||||
| 		) | ||||
| 		return nil, nil | ||||
| 	} else if err != nil { | ||||
| 		log.Debug().Str("pipeline", workflow.Name).Msg( | ||||
| 			"Pipeline config could not be parsed", | ||||
| 			"pipeline config could not be parsed", | ||||
| 		) | ||||
| 		return nil, multierr.Append(errorsAndWarnings, err) | ||||
| 	} | ||||
|   | ||||
| @@ -74,7 +74,7 @@ func SetRepo() gin.HandlerFunc { | ||||
| 		} | ||||
|  | ||||
| 		// debugging | ||||
| 		log.Debug().Err(err).Msgf("Cannot find repository %s", fullName) | ||||
| 		log.Debug().Err(err).Msgf("cannot find repository %s", fullName) | ||||
|  | ||||
| 		if user == nil { | ||||
| 			c.AbortWithStatus(http.StatusUnauthorized) | ||||
| @@ -113,13 +113,13 @@ func SetPerm() gin.HandlerFunc { | ||||
| 			var err error | ||||
| 			perm, err = _store.PermFind(user, repo) | ||||
| 			if err != nil { | ||||
| 				log.Error().Err(err).Msgf("Error fetching permission for %s %s", | ||||
| 				log.Error().Err(err).Msgf("error fetching permission for %s %s", | ||||
| 					user.Login, repo.FullName) | ||||
| 			} | ||||
| 			if time.Unix(perm.Synced, 0).Add(time.Hour).Before(time.Now()) { | ||||
| 				_repo, err := server.Config.Services.Forge.Repo(c, user, repo.ForgeRemoteID, repo.Owner, repo.Name) | ||||
| 				if err == nil { | ||||
| 					log.Debug().Msgf("Synced user permission for %s %s", user.Login, repo.FullName) | ||||
| 					log.Debug().Msgf("synced user permission for %s %s", user.Login, repo.FullName) | ||||
| 					perm = _repo.Perm | ||||
| 					perm.Repo = repo | ||||
| 					perm.RepoID = repo.ID | ||||
| @@ -151,7 +151,7 @@ func SetPerm() gin.HandlerFunc { | ||||
| 			log.Debug().Msgf("%s granted %+v permission to %s", | ||||
| 				user.Login, perm, repo.FullName) | ||||
| 		} else { | ||||
| 			log.Debug().Msgf("Guest granted %+v to %s", perm, repo.FullName) | ||||
| 			log.Debug().Msgf("guest granted %+v to %s", perm, repo.FullName) | ||||
| 		} | ||||
|  | ||||
| 		c.Set("perm", perm) | ||||
| @@ -171,11 +171,11 @@ func MustPull(c *gin.Context) { | ||||
| 	// debugging | ||||
| 	if user != nil { | ||||
| 		c.AbortWithStatus(http.StatusNotFound) | ||||
| 		log.Debug().Msgf("User %s denied read access to %s", | ||||
| 		log.Debug().Msgf("user %s denied read access to %s", | ||||
| 			user.Login, c.Request.URL.Path) | ||||
| 	} else { | ||||
| 		c.AbortWithStatus(http.StatusUnauthorized) | ||||
| 		log.Debug().Msgf("Guest denied read access to %s %s", | ||||
| 		log.Debug().Msgf("guest denied read access to %s %s", | ||||
| 			c.Request.Method, | ||||
| 			c.Request.URL.Path, | ||||
| 		) | ||||
| @@ -196,11 +196,11 @@ func MustPush(c *gin.Context) { | ||||
| 	// debugging | ||||
| 	if user != nil { | ||||
| 		c.AbortWithStatus(http.StatusNotFound) | ||||
| 		log.Debug().Msgf("User %s denied write access to %s", | ||||
| 		log.Debug().Msgf("user %s denied write access to %s", | ||||
| 			user.Login, c.Request.URL.Path) | ||||
| 	} else { | ||||
| 		c.AbortWithStatus(http.StatusUnauthorized) | ||||
| 		log.Debug().Msgf("Guest denied write access to %s %s", | ||||
| 		log.Debug().Msgf("guest denied write access to %s %s", | ||||
| 			c.Request.Method, | ||||
| 			c.Request.URL.Path, | ||||
| 		) | ||||
|   | ||||
| @@ -147,14 +147,14 @@ func MustOrgMember(admin bool) gin.HandlerFunc { | ||||
|  | ||||
| 		perm, err := server.Config.Services.Membership.Get(c, user, org.Name) | ||||
| 		if err != nil { | ||||
| 			log.Error().Err(err).Msg("Failed to check membership") | ||||
| 			log.Error().Err(err).Msg("failed to check membership") | ||||
| 			c.String(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)) | ||||
| 			c.Abort() | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| 		if perm == nil || (!admin && !perm.Member) || (admin && !perm.Admin) { | ||||
| 			c.String(http.StatusForbidden, "User not authorized") | ||||
| 			c.String(http.StatusForbidden, "user not authorized") | ||||
| 			c.Abort() | ||||
| 			return | ||||
| 		} | ||||
|   | ||||
| @@ -98,7 +98,7 @@ func SetupGlobalLogger(c *cli.Context, outputLvl bool) error { | ||||
| 	} | ||||
|  | ||||
| 	if outputLvl { | ||||
| 		log.Info().Msgf("LogLevel = %s", zerolog.GlobalLevel().String()) | ||||
| 		log.Info().Msgf("log level: %s", zerolog.GlobalLevel().String()) | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
|   | ||||
		Reference in New Issue
	
	Block a user