[go: up one dir, main page]

Skip to content

feat(badges):add ability to create and update badges from projects

Description

// similar to the NewCmdCreate in create.go file, create a NewCmdSet function that is given a project id, badge name, and badge value which are passed to 
// the CreateOrUpdateProjectBadge function made available in the api/badge library
// NewCmdSet should return a badgeSetCmd
// eventually this, should allow us to create a new badge for a project:
// glab badge set name value
// Also, use these imports to get the job done:
// 	"fmt"
//	"strings"
//	"gitlab.com/gitlab-org/cli/api"
//	"gitlab.com/gitlab-org/cli/commands/cmdutils"
//	"github.com/MakeNowJust/heredoc/v2"
//	"github.com/spf13/cobra"
//	"github.com/xanzy/go-gitlab"

Great results for

// Similar to NewCmdSchedule in schedule.go, create a NewCmdBadge that relies on the badgeSetCmd in set.go to add a new command for badge with set being one of the available commands. Be sure to import badgeSetCmd from the set.go file in this repository. 
// Assume there are more commands being created, so return it as badgeCmd.

Was not as successful on as it failed to import from the local repo.

// Create tests for the functions in set.go. Be sure to use the httpmock library for any external calls though. These are the libraries that should be imported:
// 	"net/http"
// "testing"
// "github.com/stretchr/testify/assert"
// "github.com/stretchr/testify/require"
// "gitlab.com/gitlab-org/cli/commands/cmdtest"
// "gitlab.com/gitlab-org/cli/pkg/httpmock"
// "gitlab.com/gitlab-org/cli/test"

Helpful to provide the actual libraries to use.

// using the github.com/xanzy/go-gitlab library, create an api call to the project badge api that, given a project id, badge name, and badge value, use the API to see if the
// badge exists, to either create or edit the badge.
// a badge using the name of the badge as the key identifier. After querying the API for the badge name, if the badge doesn't exist,
// go ahead and use the POST api endpoint. If the badge does exist, use the PUT api endpoint. The API payload should consist
// of the ID (if this is the POST), the image_url as https://img.shields.io/badge/name-value-blue, and name. The name
// in the image_url should be the same as the name field. The value should also be able to be set.

Related Issues

Resolves #7658

How has this been tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap

Closes #7658

Edited by Tim Poffenbarger

Merge request reports

Loading