Giter Site home page Giter Site logo

Comments (6)

oliveirarafa avatar oliveirarafa commented on June 28, 2024 1

Hmm... I didn't realize earlier that the "Edit project" API endpoint had an avatar property. I was curious how that works. So, tried a few things using curl. That API endpoint does allow updating project avatar like this:

curl --silent --request PUT --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" --url "${GITLAB_API_URL}/projects/<PROJECT_ID>" --form "avatar=@${HOME}/Downloads/sample-logo.jpeg" | jq .

The API for "Upload a project avatar" works the same way.

So, in theory the config you had is fine. But, I don't think gitlabform has logic to process that config because as you can see the avatar requires sending an image file to the API endpoint. And right now it's probably just sending the file path as string, which isn't what the api is expecting. That's probably why you're seeing that error about invalid value.

Oh I see. I haven't looked into gitlabform's code but maybe it is possible to use the curl to use the already available edit project endpoint when the avatar urls is used?

I don't know if im have enought knowledge about gitlabform to send a PR. Maybe in the future, but I think it a good feature to have.

Thank you for helping me, @amimas!

from gitlabform.

amimas avatar amimas commented on June 28, 2024

Hi. Could you please share a sample config you have tried?

from gitlabform.

oliveirarafa avatar oliveirarafa commented on June 28, 2024

Hi. Could you please share a sample config you have tried?

Yeah, no problem.

  project_settings:
      avatar: './my-photo.jpg',
      description: |
        Projeto de documentação

I tried putting a base64 image, svg, png. Searched some forums and the gitlab api docs but couldnt figure out the format that I should use.

from gitlabform.

amimas avatar amimas commented on June 28, 2024

Thanks for the sample config. What you tried won't work, regardless of value format. It comes down to Gitlab's API.

The project_settings config uses Project API as per the gitlabform documentation. This API doesnt handle the project avatar.

Project avatar is managed by a different gitlab API. Gitlabform currently doesn't have support for it. PR is welcome though.

Would you be interested in implementing it? Let's discuss what the config should be like for this setting. This feature probably should also support deleting a project avatar.

from gitlabform.

oliveirarafa avatar oliveirarafa commented on June 28, 2024

Thanks for the sample config. What you tried won't work, regardless of value format. It comes down to Gitlab's API.

The project_settings config uses Project API as per the gitlabform documentation. This API doesnt handle the project avatar.

Project avatar is managed by a different gitlab API. Gitlabform currently doesn't have support for it. PR is welcome though.

Would you be interested in implementing it? Let's discuss what the config should be like for this setting. This feature probably should also support deleting a project avatar.

Oh, ok. Thank you. Do you know what is the avatar prop in Project API? I think their documentation needs a fix, it kind of implies that it is possible to change the avatar from this api.

About the config file in my opinion, the easiest way would the passing a relative url of the image file.

from gitlabform.

amimas avatar amimas commented on June 28, 2024

Hmm... I didn't realize earlier that the "Edit project" API endpoint had an avatar property. I was curious how that works. So, tried a few things using curl. That API endpoint does allow updating project avatar like this:

curl --silent --request PUT --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" --url "${GITLAB_API_URL}/projects/<PROJECT_ID>" --form "avatar=@${HOME}/Downloads/sample-logo.jpeg" | jq .

The API for "Upload a project avatar" works the same way.

So, in theory the config you had is fine. But, I don't think gitlabform has logic to process that config because as you can see the avatar requires sending an image file to the API endpoint. And right now it's probably just sending the file path as string, which isn't what the api is expecting. That's probably why you're seeing that error about invalid value.

from gitlabform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.