Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support aqua update command updating packages and registries #1657

Closed
suzuki-shunsuke opened this issue Feb 22, 2023 · 27 comments
Closed

Support aqua update command updating packages and registries #1657

suzuki-shunsuke opened this issue Feb 22, 2023 · 27 comments
Labels
command:update enhancement New feature or request
Milestone

Comments

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Feb 22, 2023

Feature Overview

Add a command to update packages and registries.

Why is the feature needed?

Please explain the problem you want to solve.

Feedback from @sheldonhull

Upgrade an aqua config without renovate. I'm a huge fan of renovate but it's a huge ask for folks to all use it especially if they are just setting up a global tools config.

Does the feature include Breaking Changes?

No.

Example Code

command and configuration

Prepare aqua.yaml which contains old registries and packages

registries:
- type: standard
  ref: v3.90.0 # Old
packages:
- name: cli/[email protected] # Old
- name: junegunn/[email protected] # Old

Run aqua update.

$ aqua update

Then all registries and packages are updated.

registries:
- type: standard
  ref: v3.166.1 # Updated
packages:
- name: cli/[email protected] # Updated
- name: junegunn/[email protected] # Updated

Support -tag. https://aquaproj.github.io/docs/tutorial-extras/package-tag/

aqua update -t dev

Ideas

  1. Support version constraint like ^1.0.0
  2. Add a field to exclude update
packages:
- name: cli/[email protected]
  exclude_update: true

I prefer 3 than 2.

  1. Exclude packages using long syntax
packages:
- name: cli/[email protected] # Update
- name: cli/cli
  version: v2.0.0 # Don't update
  1. Conform to policy

This is nice to have but isn't mandatory.
I guess it is a bit difficult to implement this feature.

Reference

@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Feb 22, 2023
@suzuki-shunsuke suzuki-shunsuke moved this to Todo in main Feb 22, 2023
@CrystalMethod
Copy link

CrystalMethod commented Feb 22, 2023

This exact question came up today in my project team. A must have is that update respects pinned versions and leaves them unchanged. And maybe a --dry-run option.

@suzuki-shunsuke
Copy link
Member Author

A must have is that update respects pinned versions and leaves them unchanged.

What do you mean?
aqua forces to pin all registries and packages versions, so I can't understand what you want.
Do you expect version constraint like ^1.0.0?

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Feb 23, 2023

I like and strongly recommend Renovate, so I'd like to know why users who want this feature don't use Renovate.

especially if they are just setting up a global tools config

Some users manage aqua.yaml in their dotfiles repositories, which means you can update global configuration by Renovate as well.

@suzuki-shunsuke suzuki-shunsuke moved this from Todo to Backlog in main Mar 1, 2023
@CrystalMethod
Copy link

I like and strongly recommend Renovate, so I'd like to know why users who want this feature don't use Renovate.

In my case: because the company policies do not allow it. It is not allowed - or requires a separate and lengthy review/audit - to use such managed services. We are experimenting with running Renovate selfhosted, but it is not the same.

@suzuki-shunsuke
Copy link
Member Author

Thank you for your explanation.

@CrystalMethod
Copy link

Currently I try to use updatecli for this - maybe this is a good companion, because it supports other systems as well. This could be a suitable replacement for Renovate; at least in my case.

@suzuki-shunsuke
Copy link
Member Author

I don't know updatecli well, but I wonder you can update aqua.yaml by updatecli.
If so, it can be used instead of aqua update command.

And I think Self hosted Renovate by GitHub Actions is also useful if it is allowed in your company.
This is just a GitHub Actions, so the hosting isn't difficult.

@CrystalMethod
Copy link

I don't know updatecli well, but I wonder you can update aqua.yaml by updatecli. If so, it can be used instead of aqua update command.

I am working on a PoC for this and will share my findings.

And I think Self hosted Renovate by GitHub Actions is also useful if it is allowed in your company. This is just a GitHub Actions, so the hosting isn't difficult.

This is a completely different story: we are using the self-hosted Bitbucket (formerly known as Stash) and finishing the migration to GitHub Enterpise will take several more months.

@suzuki-shunsuke
Copy link
Member Author

I am working on a PoC for this and will share my findings.

Thanks. I'm looking forward to it. I'll also take a look updatecli when I have a time.

This is a completely different story: we are using the self-hosted Bitbucket (formerly known as Stash) and finishing the migration to GitHub Enterpise will take several more months.

Oh, I see.

@CrystalMethod
Copy link

aqua.yaml
---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
registries:
  - type: standard
    ref: v3.138.0
packages:
- name: argoproj/[email protected]
- name: dagger/[email protected] # latest is v0.3.13
- name: kubernetes/kubectl
  version: v1.24.10
updatecli.dagger.yaml
name: Update Dagger GitHub Release

sources:
  dagger:
    name: Get latest Dagger version from GitHub releases
    kind: githubrelease
    spec:
      owner: dagger
      repository: dagger
      token: '{{ requiredEnv "GITHUB_TOKEN" }}'
      username: '{{ requiredEnv "GITHUB_ACTOR" }}'
      versionfilter:
        kind: regex
        pattern: ^v(\d+)\.(\d+)\.(\d+)$

conditions:
  dagger:
    name: Check latest Dagger release
    kind: githubrelease
    sourceid: dagger
    spec:
      owner: dagger
      repository: dagger
      token: '{{ requiredEnv "GITHUB_TOKEN" }}'
      username: '{{ requiredEnv "GITHUB_ACTOR" }}'
      typefilter:
        release: true

targets:
  dagger:
    name: Update Dagger version in aqua.yaml
    kind: yaml
    transformers:
      - addprefix: "dagger/dagger@"
    spec:
      file: "aqua.yaml"
      key: "packages[1].name" # array access is limited to indices

The targets.<yaml>.spec.key syntax is currently limited to named keys and array indices. In addition, the challenge is not to modify pinned versions. (But this would probably have to be ensured by an additional condition)

updatecli diff --config updatecli.dagger.yaml
+++++++++++
+ PREPARE +
+++++++++++

Loading Pipeline "updatecli.dagger.yaml"

SCM repository retrieved: 0


++++++++++++++++++
+ AUTO DISCOVERY +
++++++++++++++++++



++++++++++++
+ PIPELINE +
++++++++++++



#############
# EXAMPLE 1 #
#############


SOURCES
=======

dagger
------
Searching for version matching pattern "^v(\\d+)\\.(\\d+)\\.(\\d+)$"
✔ Github Release version "v0.3.13" found matching pattern "^v(\\d+)\\.(\\d+)\\.(\\d+)$"


CHANGELOG:
----------

Release published on the 2023-02-24 18:06:22 +0000 UTC at the url https://github.com/dagger/dagger/releases/tag/v0.3.13

## Changelog

* :sparkles: Services, a.k.a. container-to-container networking by @vito in https://github.com/dagger/dagger/pull/4505
* :lock: Scrub secrets by @dolanor in https://github.com/dagger/dagger/pull/4518
* Initial support for remote cache config. by @sipsma in https://github.com/dagger/dagger/pull/4543
* Download runc binary instead of building it.  by @sipsma in https://github.com/dagger/dagger/pull/4559
* fix: remove workdir & configPath default values. by @TomChv in https://github.com/dagger/dagger/pull/4465
* Remove import dependency of CLI on containerd packages.  by @sipsma in https://github.com/dagger/dagger/pull/4562
* Use comma instead of semicolon for cache config separator. by @sipsma in https://github.com/dagger/dagger/pull/4563
* Disable logrus output only in CLI main. by @sipsma in https://github.com/dagger/dagger/pull/4572
* fix Directory.WithTimestamps with subdir by @vito in https://github.com/dagger/dagger/pull/4606
* docs: improve GraphQL with example and better format by @TomChv in https://github.com/dagger/dagger/pull/4367
* Get sha of the image after Container.From by @LokeshN in https://github.com/dagger/dagger/pull/4600
* Update buildkit to commit w/ cache exporter fix + nil panic fix by @sipsma in https://github.com/dagger/dagger/pull/4630
* Additive caching support for S3 backend by @sipsma in https://github.com/dagger/dagger/pull/4577

**Full Changelog**: https://github.com/dagger/dagger/compare/v0.3.12...v0.3.13

## What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)



CONDITIONS:
===========

dagger
------
✔ Github Release version "v0.3.13" found


TARGETS
========

dagger
------

**Dry Run enabled**

⚠ Key 'packages[1].name', from file 'aqua.yaml', was updated from 'dagger/[email protected]' to 'dagger/[email protected]'

=============================

REPORTS:


⚠ Example 1:
        Source:
                ✔ [dagger] Get latest Dagger version from GitHub releases (kind: githubrelease)
        Condition:
                ✔ [dagger] Check latest Dagger release (kind: githubrelease)
        Target:
                ⚠ [dagger] Update Dagger version in aqua.yaml (kind: yaml)


Run Summary
===========
Pipeline(s) run:
  * Changed:    1
  * Failed:     0
  * Skipped:    0
  * Succeeded:  0
  * Total:      1

@CrystalMethod
Copy link

aqua forces to pin all registries and packages versions, so I can't understand what you want.
Do you expect version constraint like ^1.0.0?

Originally I only referred to "3. Exclude packages using long syntax".

But in the meantime I also believe that version ranges - especially based on semver - can be an interesting pattern.

@suzuki-shunsuke
Copy link
Member Author

Oh, thank you for sharing! It looks interesting.
Should we prepare configuration per tool?
If so, it is hard to maintain when the number of tools increases.

And the restriction The targets.<yaml>.spec.key syntax is currently limited to named keys and array indices. is also cumbersome.

@suzuki-shunsuke
Copy link
Member Author

aqua forces to pin all registries and packages versions, so I can't understand what you want.
Do you expect version constraint like ^1.0.0?

Originally I only referred to "3. Exclude packages using long syntax".

But in the meantime I also believe that version ranges - especially based on semver - can be an interesting pattern.

I see. Thanks. I think version range is interesting too, but it can make aqua complicated and hard to maintain.

@CrystalMethod
Copy link

I see. Thanks. I think version range is interesting too, but it can make aqua complicated and hard to maintain.

This is the reason why I am evaluating Updatecli. I think that tools like Renovate or Updatecli are better suited for this kind of tasks.

@CrystalMethod
Copy link

CrystalMethod commented Mar 2, 2023

Should we prepare configuration per tool? If so, it is hard to maintain when the number of tools increases.

I'm not sure what the best layout would be. It was just a first shot, to be more used as a prototype.

Check out this exhaustive update definition, where they are using one file (pipeline) per tool: https://github.com/jenkins-infra/packer-images/tree/main/updatecli/updatecli.d

And the restriction The targets.<yaml>.spec.key syntax is currently limited to named keys and array indices. is also cumbersome.

Looking at the source code, I come to the conclusion that this is a self-made implementation of Yamlpath.

I just noticed that there is a target type file defining targets.<file>.spec.matchpattern and targets.<file>.spec.replacepattern . That might fit better.

Otherwise you will propaply need a special type "aqua" whose implementation encapsulates some of the necessary but verbose yaml configuration.

@CrystalMethod
Copy link

CrystalMethod commented Mar 2, 2023

I think one configuration (pipeline) per tool has the advantage to have individual commits/pr per tool to be updated. If you dont need or want this then you are fine to add all pairs of source-target (one per tool) to the same configuration.

Update: Kind file works much smoother. Also the "do not touch pinned versions" issue is solved, because you only have to define a proper regexp. It's still a bunch of Yaml source code. But in the first step I'm somewhat happy with this solution. I'll push my configuration as a separate "showcase" repository to GitHub.

@CrystalMethod
Copy link

CrystalMethod commented Mar 3, 2023

https://github.com/CrystalMethod/aqua-meets-updatecli

TODO:

  • document the motivation
  • document more findings
  • add GHA Workflow

@olblak
Copy link

olblak commented Mar 10, 2023

sorry to jump in your discussion, accidentally found it and it was too much interesting to ignore it.
Getting feedback on opensource project can be challenging and yet super valuable.

Looking at the source code, I come to the conclusion that this is a self-made implementation of Yamlpath.

You are right, at the beginning of the project I didn't find a library that suited my need and went with the custom one. The situation changed and I am evaluating different library. updatecli/updatecli#903 (comment)

when those situation happen do not hesitate to add a +1 on an issue, it helps to prioritize.

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Mar 11, 2023

We also use goccy/go-yaml to patch YAML.
https://github.com/aquaproj/aqua/blob/3f31cf223d8968ee662fe2a06bc5a577958b7b10/pkg/controller/generate/output/insert.go

goccy/go-yaml is awesome, but let me share some known issues.

@suzuki-shunsuke
Copy link
Member Author

Update only the specific package

Change the version of cli/cli to v2.2.0. If cli/cli isn't found in aqua.yaml, the command fails.

$ aqua update cli/[email protected]

Select the version of cli/cli interactively and change the version. If cli/cli isn't found in aqua.yaml, the command fails.

$ aqua update -s cli/cli

Update cli/cli to the latest.

$ aqua update cli/cli

@suzuki-shunsuke
Copy link
Member Author

Idea: -major option: Major update

By default, aqua update avoids major updates to keep the compatibility.
aqua update -major allows major updates.

@tmeijn
Copy link

tmeijn commented Jul 26, 2023

Hey @suzuki-shunsuke I was wondering if you might have plans to add this command to the CLI.

@suzuki-shunsuke
Copy link
Member Author

suzuki-shunsuke commented Jul 26, 2023

Yeah, we have a plan to work on this, but we're working on other tasks so we can't work on this for a while.
You need this feature because you can't use Renovate in your projects, right?

@suzuki-shunsuke suzuki-shunsuke moved this from Todo to Backlog in main Jul 26, 2023
@suzuki-shunsuke suzuki-shunsuke moved this from Backlog to Todo in main Jul 26, 2023
@suzuki-shunsuke suzuki-shunsuke pinned this issue Aug 29, 2023
@suzuki-shunsuke
Copy link
Member Author

We're working on it.
We'd like to handle this issue by this year.

@suzuki-shunsuke
Copy link
Member Author

I'm working on it at #2329 .
I published a prerelease version v2.14.0-1.

For the detail, please see the description of the pull request.

You can try the prerelease version by downloading the prebuilt binary from GitHub Release or running aqua update-aqua.

aqua update-aqua v2.14.0-1

Note that this is still work in progress so there may be bugs and the specification may be changed.
I'm adding tests.
Your feedback is welcome.

@suzuki-shunsuke suzuki-shunsuke moved this from Todo to In Progress in main Oct 16, 2023
@suzuki-shunsuke
Copy link
Member Author

aqua v2.14.0 is out 🎉
https://github.com/aquaproj/aqua/releases/tag/v2.14.0

@github-project-automation github-project-automation bot moved this from In Progress to Done in main Oct 16, 2023
@suzuki-shunsuke suzuki-shunsuke added this to the v2.14.0 milestone Oct 16, 2023
@suzuki-shunsuke suzuki-shunsuke unpinned this issue Oct 16, 2023
@sheldonhull
Copy link

You are amazing as usual. Thank you so much for this. A great quality of life improvement even if renovate is possible. Great for adhoc updates. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command:update enhancement New feature or request
Projects
No open projects
Status: Done
Development

No branches or pull requests

5 participants