From c8293d0e3ccd04954a68a572279f477c62efb7a6 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 25 Jan 2025 16:36:35 +0100 Subject: [PATCH] chore(refactor): remove deadcode from port of Add API for `Variables` (#29520) --- .deadcode-out | 1 - models/actions/variable.go | 4 ---- services/actions/variables.go | 33 --------------------------------- 3 files changed, 38 deletions(-) diff --git a/.deadcode-out b/.deadcode-out index f305839cb3..80359e7dbb 100644 --- a/.deadcode-out +++ b/.deadcode-out @@ -22,7 +22,6 @@ package "code.gitea.io/gitea/models/actions" func (ScheduleList).GetRepoIDs func (ScheduleList).LoadTriggerUser func (ScheduleList).LoadRepos - func GetVariableByID package "code.gitea.io/gitea/models/asymkey" func (ErrGPGKeyAccessDenied).Error diff --git a/models/actions/variable.go b/models/actions/variable.go index 4aab2db3ba..bf3e28abab 100644 --- a/models/actions/variable.go +++ b/models/actions/variable.go @@ -69,10 +69,6 @@ func (opts FindVariablesOpts) ToConds() builder.Cond { return cond } -func FindVariables(ctx context.Context, opts FindVariablesOpts) ([]*ActionVariable, error) { - return db.Find[ActionVariable](ctx, opts) -} - func UpdateVariable(ctx context.Context, variable *ActionVariable) (bool, error) { count, err := db.GetEngine(ctx).ID(variable.ID).Where("owner_id = ? AND repo_id = ?", variable.OwnerID, variable.RepoID).Cols("name", "data"). Update(&ActionVariable{ diff --git a/services/actions/variables.go b/services/actions/variables.go index a5703898ab..2824073336 100644 --- a/services/actions/variables.go +++ b/services/actions/variables.go @@ -49,39 +49,6 @@ func UpdateVariable(ctx context.Context, variableID, ownerID, repoID int64, name }) } -func DeleteVariableByName(ctx context.Context, ownerID, repoID int64, name string) error { - if err := secret_service.ValidateName(name); err != nil { - return err - } - - if err := envNameCIRegexMatch(name); err != nil { - return err - } - - v, err := GetVariable(ctx, actions_model.FindVariablesOpts{ - OwnerID: ownerID, - RepoID: repoID, - Name: name, - }) - if err != nil { - return err - } - - _, err = actions_model.DeleteVariable(ctx, v.ID, ownerID, repoID) - return err -} - -func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error) { - vars, err := actions_model.FindVariables(ctx, opts) - if err != nil { - return nil, err - } - if len(vars) != 1 { - return nil, util.NewNotExistErrorf("variable not found") - } - return vars[0], nil -} - // some regular expression of `variables` and `secrets` // reference to: // https://docs.github.com/en/actions/learn-github-actions/variables#naming-conventions-for-configuration-variables