Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…re-aria into 148-vra-ngpull-command-faillure-when-importexport-tags-contains-underscore

Signed-off-by: Petar Penev <[email protected]>
  • Loading branch information
iludart committed Jul 21, 2023
2 parents c5ec777 + 836730b commit 691e9a7
Show file tree
Hide file tree
Showing 18 changed files with 13,028 additions and 20,291 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixes
* [artifact-manager] 148 / vra-ng:pull command failure when import/export tags contains underscore
* [maven-plugins] 146 / Pull operations fail on Windows with release 2.34.0

## v2.34.0 - 05 Jul 2023

Expand Down Expand Up @@ -1094,4 +1095,4 @@
* Cloud Client could not import bundles

## v1.0.0 - 02 Mar 2018
* Initial version
* Initial version
17 changes: 13 additions & 4 deletions docs/versions/latest/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
[//]: # (You can utilize internal links /e.g. link to the upgrade procedure, link to the improvement|deprecation that introduced this/)



## Deprecations
[//]: # (### *Deprecation*)
[//]: # (Explain what is deprecated and suggest alternatives)



[//]: # (Features -> New Functionality)
## Features
[//]: # (### *Feature Name*)
Expand All @@ -25,7 +23,6 @@
[//]: # (#### Relevant Documentation:)



[//]: # (Improvements -> Bugfixes/hotfixes or general improvements)
## Improvements
[//]: # (### *Improvement Name* )
Expand All @@ -39,9 +36,21 @@
[//]: # (Optional But higlhy recommended Specify *NONE* if missing)
[//]: # (#### Relevant Documentation:)

### Fixed pull operations, which were failing on Windows
#### Previous Behavior

Pull operation was failing on Windows for abx, ssh, vra-ng, vra, vrli.
Whenever a pull was initiated, it was failing with:

pull failed: 'posix:permissions' not supported as initial attribute

when trying to create a temporary directory.
This is due to PosixPermissions which can be used only with POSIX compatible operating systems.

#### New Behavior
Using another library for temp dir creation which checks if POSIX is supported.

## Upgrade procedure:
## Upgrade procedure
[//]: # (Explain in details if something needs to be done)

[//]: # (## Changelog:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
* %%
* Build Tools for VMware Aria
* Copyright 2023 VMware, Inc.
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
* #L%
*/

import com.google.common.io.Files;
import com.vmware.pscoe.iac.artifact.PackageManager;
import com.vmware.pscoe.iac.artifact.PackageStore;
import com.vmware.pscoe.iac.artifact.PackageStoreFactory;
import com.vmware.pscoe.iac.artifact.configuration.Configuration;
import com.vmware.pscoe.iac.artifact.configuration.ConfigurationException;
import com.vmware.pscoe.iac.artifact.model.Package;
import com.vmware.pscoe.iac.artifact.model.PackageFactory;
import com.vmware.pscoe.iac.artifact.model.PackageType;
import org.apache.maven.plugin.MojoExecutionException;
Expand All @@ -31,29 +31,55 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;

@Mojo(name = "pull")
public class PullMojo extends AbstractIacMojo {

/**
* The project that is built with the tools.
*/
@Parameter(defaultValue = "${project}")
private MavenProject project;

/**
* Dry run or not. Default value is false.
*/
@Parameter(required = false, property = "dryrun", defaultValue = "false")
private boolean dryrun;

/**
* Set the importOldVersions property.
*
* @param type The package type.
* @param props The properties.
*/
@Override
protected void overwriteConfigurationPropertiesForType(PackageType type, Properties props) {
props.setProperty(Configuration.IMPORT_OLD_VERSIONS, "true");
}

/**
* Implement the pull operation for abx.
*
* @throws MojoExecutionException If the maven plugin execution fails.
* @throws MojoFailureException If the Mojo (maven plugin) fails.
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
super.execute();

Path tempDir;
try {
tempDir = Files.createTempDirectory("abx-pull");
} catch (IOException e) {
throw new MojoExecutionException("Could not create a temp directory");
}

MavenProjectPackageInfoProvider pkgInfoProvider = new MavenProjectPackageInfoProvider(project);
File pkgFile = new File(Files.createTempDir(), pkgInfoProvider.getPackageName() + "." + PackageType.ABX.getPackageExtention());
com.vmware.pscoe.iac.artifact.model.Package pkg = PackageFactory.getInstance(PackageType.ABX, pkgFile);
File pkgFile = tempDir.resolve(pkgInfoProvider.getPackageName() + "." + PackageType.ABX.getPackageExtention()).toFile();
Package pkg = PackageFactory.getInstance(PackageType.ABX, pkgFile);

try {
PackageStore<?> store = PackageStoreFactory.getInstance(getConfigurationForAbx());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* This module is about abx pull operation.
*/
package com.vmware.pscoe.maven.plugins;

/*-
* #%L
* abx-package-maven-plugin
* %%
* Copyright (C) 2023 VMware
* %%
* Build Tools for VMware Aria
* Copyright 2023 VMware, Inc.
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
* #L%
*/
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
* %%
* Build Tools for VMware Aria
* Copyright 2023 VMware, Inc.
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
* #L%
*/

import com.google.common.io.Files;
import com.vmware.pscoe.iac.artifact.PackageManager;
import com.vmware.pscoe.iac.artifact.PackageStore;
import com.vmware.pscoe.iac.artifact.PackageStoreFactory;
import com.vmware.pscoe.iac.artifact.configuration.*;
import com.vmware.pscoe.iac.artifact.configuration.Configuration;
import com.vmware.pscoe.iac.artifact.configuration.ConfigurationException;
import com.vmware.pscoe.iac.artifact.model.Package;
import com.vmware.pscoe.iac.artifact.model.PackageFactory;
import com.vmware.pscoe.iac.artifact.model.PackageType;
import com.vmware.pscoe.iac.artifact.PackageManager;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
Expand All @@ -30,34 +31,61 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

@Mojo(name = "pull")
public class SshPullMojo extends AbstractIacMojo {
/**
* The project that is built with the tools.
*/
@Parameter(defaultValue = "${project}")
private MavenProject project;

/**
* Dry run or not. Default value is false.
*/
@Parameter(required = false, property = "dryrun", defaultValue = "false")
private boolean dryrun;

/**
* Set the importOldVersions property.
*
* @param type The package type.
* @param props The properties.
*/
@Override
protected void overwriteConfigurationPropertiesForType(PackageType type, Properties props) {
props.setProperty(Configuration.IMPORT_OLD_VERSIONS, "true");
}

/**
* Implement the pull operation for ssh.
*
* @throws MojoExecutionException If the maven plugin execution fails.
* @throws MojoFailureException If the Mojo (maven plugin) fails.
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
super.execute();

Path tempDir;
try {
tempDir = Files.createTempDirectory("ssh-pull");
} catch (IOException e) {
throw new MojoExecutionException("Could not create a temp directory");
}

MavenProjectPackageInfoProvider pkgInfoProvider = new MavenProjectPackageInfoProvider(project);
File pkgFile = new File(Files.createTempDir(), pkgInfoProvider.getPackageName() + "." + PackageType.BASIC.getPackageExtention());
com.vmware.pscoe.iac.artifact.model.Package pkg = PackageFactory.getInstance(PackageType.BASIC, pkgFile);
File pkgFile = tempDir.resolve(pkgInfoProvider.getPackageName() + "." + PackageType.BASIC.getPackageExtention()).toFile();
Package pkg = PackageFactory.getInstance(PackageType.BASIC, pkgFile);
try {
PackageStore store = PackageStoreFactory.getInstance(getConfigurationForSsh());
PackageStore<?> store = PackageStoreFactory.getInstance(getConfigurationForSsh());
store.exportPackage(pkg, new File(project.getBasedir(), "content.yaml"), dryrun);
PackageManager.copyContents(Paths.get(pkg.getFilesystemPath(), "content").toFile(),
new File(project.getBasedir(), "src"));
PackageManager.copyContents(Paths.get(pkg.getFilesystemPath(), "content").toFile(),
new File(project.getBasedir(), "src"));
} catch (ConfigurationException | IOException e) {
getLog().error(e);
throw new MojoExecutionException(e, "Error pulling SSH package", "Error pulling SSH package");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* This module is about ssh pull operation.
*/
package com.vmware.pscoe.maven.plugins;

/*-
* #%L
* ssh-maven-plugin
* %%
* Copyright (C) 2023 VMware
* %%
* Build Tools for VMware Aria
* Copyright 2023 VMware, Inc.
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
* #L%
*/
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,87 @@
* %%
* Build Tools for VMware Aria
* Copyright 2023 VMware, Inc.
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
*
* This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.
*
* This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
* #L%
*/

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import com.google.common.io.Files;
import com.vmware.pscoe.iac.artifact.PackageManager;
import com.vmware.pscoe.iac.artifact.PackageStore;
import com.vmware.pscoe.iac.artifact.PackageStoreFactory;
import com.vmware.pscoe.iac.artifact.configuration.Configuration;
import com.vmware.pscoe.iac.artifact.configuration.ConfigurationException;
import com.vmware.pscoe.iac.artifact.model.Package;
import com.vmware.pscoe.iac.artifact.model.PackageFactory;
import com.vmware.pscoe.iac.artifact.model.PackageType;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;


@Mojo(name = "pull")
public class PullMojo extends AbstractIacMojo {

/**
* The project that is built with the tools.
*/
@Parameter(defaultValue = "${project}")
private MavenProject project;

/**
* Dry run or not. Default value is false.
*/
@Parameter(required = false, property = "dryrun", defaultValue = "false")
private boolean dryrun;

/**
* Set the importOldVersions property.
*
* @param type The package type.
* @param props The properties.
*/
@Override
protected void overwriteConfigurationPropertiesForType(PackageType type, Properties props) {
props.setProperty(Configuration.IMPORT_OLD_VERSIONS, "true");
}

/**
* Implement the pull operation for vra-ng.
*
* @throws MojoExecutionException If the maven plugin execution fails.
* @throws MojoFailureException If the Mojo (maven plugin) fails.
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
super.execute();

Path tempDir;
try {
tempDir = Files.createTempDirectory("vra-ng-pull");
} catch (IOException e) {
throw new MojoExecutionException("Could not create a temp directory");
}

MavenProjectPackageInfoProvider pkgInfoProvider = new MavenProjectPackageInfoProvider(project);
File pkgFile = new File(Files.createTempDir(), pkgInfoProvider.getPackageName() + "." + PackageType.VRANG.getPackageExtention());
com.vmware.pscoe.iac.artifact.model.Package pkg = PackageFactory.getInstance(PackageType.VRANG, pkgFile);
File pkgFile = tempDir.resolve(pkgInfoProvider.getPackageName() + "." + PackageType.VRANG.getPackageExtention()).toFile();
Package pkg = PackageFactory.getInstance(PackageType.VRANG, pkgFile);
try {
PackageStore<?> store = PackageStoreFactory.getInstance(getConfigurationForVraNg());
PackageStore<?> store = PackageStoreFactory.getInstance(getConfigurationForVraNg());
store.exportPackage(pkg, new File(project.getBasedir(), "content.yaml"), dryrun);
PackageManager.copyContents(new File(pkg.getFilesystemPath()), new File(pkgInfoProvider.getSourceDirectory().getAbsolutePath()));
PackageManager.copyContents(new File(pkg.getFilesystemPath()), new File(pkgInfoProvider.getSourceDirectory().getAbsolutePath()));
} catch (ConfigurationException | IOException e) {
getLog().error(e);
String message = String.format("Error pulling vRA ng package : %s", e.getMessage());
throw new MojoExecutionException(e, message, message);
String message = String.format("Error pulling vRA ng package : %s", e.getMessage());
throw new MojoExecutionException(e, message, message);
}
}
}
Loading

0 comments on commit 691e9a7

Please sign in to comment.