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

[Merged by Bors] - fix: install.sh, fluvio install/update, add arch/target overrides #3463

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/fluvio-cli/src/install/plugins.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::str::FromStr;
use clap::Parser;
use tracing::debug;
use anyhow::Result;
Expand Down Expand Up @@ -49,7 +50,7 @@ pub struct InstallOpt {
#[arg(long, hide_short_help = true)]
pub channel: Option<String>,

/// When this flag is provided, use the hub. Dev-only
/// override default target arch determination
#[arg(long, hide_short_help = true)]
pub target: Option<String>,
}
Expand Down Expand Up @@ -144,7 +145,14 @@ impl InstallOpt {
}

async fn install_plugin(&self, agent: &HttpAgent) -> Result<()> {
let target = fluvio_index::package_target()?;
let target = if let Some(user_override) = &self.target {
fluvio_index::Target::from_str(&user_override.to_string())?
} else {
// need to analyze to if we can make CURRENT_PLATFORM
// the default instead of PACKAGE_TARGET, keep
// each use the same for now
fluvio_index::package_target()?
};

// If a version is given in the package ID, use it. Otherwise, use latest
let id = match self
Expand Down
15 changes: 14 additions & 1 deletion crates/fluvio-cli/src/install/update.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::path::{Path, PathBuf};
use std::str::FromStr;

use clap::Parser;
use tracing::{debug, instrument};
Expand Down Expand Up @@ -32,6 +33,10 @@ pub struct UpdateOpt {
// pub develop_fluvio_channel: bool,
/// (Optional) the name of one or more plugins to update
plugins: Vec<PackageId>,

/// override default target arch determination
#[arg(long, hide_short_help = true)]
pub target: Option<String>,
}

impl UpdateOpt {
Expand Down Expand Up @@ -90,7 +95,15 @@ impl UpdateOpt {

#[instrument(skip(self, agent))]
async fn update_fluvio_cli(&self, agent: &HttpAgent) -> Result<()> {
let target = fluvio_index::package_target()?;
let target = if let Some(user_override) = &self.target {
fluvio_index::Target::from_str(&user_override.to_string())?
} else {
// need to analyze to if we can make CURRENT_PLATFORM
// the default instead of PACKAGE_TARGET, keep
// each use the same for now
fluvio_index::package_target()?
};

let id: PackageId = FLUVIO_CLI_PACKAGE_ID.parse()?;
debug!(%target, %id, "Fluvio CLI updating self:");

Expand Down
3 changes: 3 additions & 0 deletions crates/fluvio-cli/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use sha2::{Digest, Sha256};
use clap::Parser;
use anyhow::Result;
use current_platform::CURRENT_PLATFORM;

use fluvio::Fluvio;
use fluvio::config::ConfigFile;
Expand All @@ -20,6 +21,7 @@ impl VersionOpt {
};

self.print("Fluvio CLI", crate::VERSION.trim());
self.print("Fluvio CLI Arch", CURRENT_PLATFORM);

if let Some(sha) = self.format_cli_sha() {
self.print("Fluvio CLI SHA256", &sha);
Expand All @@ -29,6 +31,7 @@ impl VersionOpt {
}
let platform = self.format_platform_version(target).await;
self.print("Fluvio Platform", &platform);

self.print("Git Commit", env!("GIT_HASH"));
if let Some(os_info) = os_info() {
self.print("OS Details", &os_info);
Expand Down
14 changes: 12 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ readonly FLUVIO_EXTENSIONS="${HOME}/.fluvio/extensions"

# Ensure that this target is supported and matches the
# naming convention of known platform releases in the registry
# A number of short aliases are also supported for use with FLUVIO_ARCH
#
# @param $1: The target triple of this architecture
# @return: Status 0 if the architecture is supported, exit if not
Expand All @@ -37,6 +38,10 @@ normalize_target() {
echo "aarch64-unknown-linux-musl"
return 0
;;
armv7)
echo "armv7-unknown-linux-gnueabihf"
return 0
;;
esac

echo "${_target}"
Expand Down Expand Up @@ -140,7 +145,7 @@ verify_checksum() {
remind_path() {
say "💡 You'll need to add '~/.fluvio/bin/' to your PATH variable"
say " You can run the following to set your PATH on shell startup:"

# shellcheck disable=SC2016,SC2155
local bash_hint="$(tput bold)"'echo '\''export PATH="${HOME}/.fluvio/bin:${PATH}"'\'' >> ~/.bashrc'"$(tput sgr0)"
# shellcheck disable=SC2016,SC2155
Expand Down Expand Up @@ -281,6 +286,11 @@ get_architecture() {
_cputype="$(uname -m)"
_clibtype="gnu"

if [ -n "$FLUVIO_ARCH" ]; then
RETVAL="$FLUVIO_ARCH"
return 0
fi

if [ "$_ostype" = Linux ]; then
if [ "$(uname -o)" = Android ]; then
_ostype=Android
Expand Down Expand Up @@ -549,7 +559,7 @@ main() {
fi

local _install_file="${FLUVIO_BIN}/fluvio-${VERSION}"
else
else
# If we installed a specific version, place extension in that dir
# Ex. fluvio-0.x.y
local _install_file="${FLUVIO_BIN}/fluvio-${_version}"
Expand Down
Loading