Skip to content

Commit

Permalink
feat(travis): Support for filteredRepositories parameter (spinnaker#1730
Browse files Browse the repository at this point in the history
)

* feat(travis): Support for filteredRepositories parameter

Signed-off-by: cmuraru <[email protected]>

* Implement review

* Implement review

Co-authored-by: cmuraru <[email protected]>
  • Loading branch information
costimuraru and cmuraru authored Jun 30, 2020
1 parent 7915d42 commit 3fee73a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -4419,6 +4419,7 @@ hal config ci travis master add MASTER [parameters]
* `--base-url`: (*Required*) The base URL to the travis UI ([https://travis-ci.org](https://travis-ci.org)).
* `--build-result-limit`: Defines how many builds Igor should return when querying for builds for a specific repo. This affects for instance how many builds that will be displayed in the drop down when starting a manual execution of a pipeline. If set too high, the Travis API might return an error for jobs that writes a lot of logs, which is why the default setting is a bit conservative. Defaults to 10. Used for spinnaker >= 1.17.
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--filtered-repositories`: (*Default*: `[]`) Defines the list of repositories that will be scraped. Useful if the organization has a lot of repositories and you wish to speed things up by scanning only a subset.
* `--github-token`: (*Sensitive data* - user will be prompted on standard input) The github token to authentiacte against travis with.
* `--no-validate`: (*Default*: `false`) Skip validation.
* `--number-of-jobs`: Defines how many jobs the Travis integration should retrieve per polling cycle. Defaults to 100. Used for spinnaker >= 1.17.
Expand Down Expand Up @@ -4461,6 +4462,7 @@ hal config ci travis master edit MASTER [parameters]
* `--base-url`: The base URL to the travis UI ([https://travis-ci.org](https://travis-ci.org)).
* `--build-result-limit`: Defines how many builds Igor should return when querying for builds for a specific repo. This affects for instance how many builds that will be displayed in the drop down when starting a manual execution of a pipeline. If set too high, the Travis API might return an error for jobs that writes a lot of logs, which is why the default setting is a bit conservative. Defaults to 10. Used for spinnaker >= 1.17.
* `--deployment`: If supplied, use this Halyard deployment. This will _not_ create a new deployment.
* `--filtered-repositories`: (*Default*: `[]`) Defines the list of repositories that will be scraped. Useful if the organization has a lot of repositories and you wish to speed things up by scanning only a subset.
* `--github-token`: (*Sensitive data* - user will be prompted on standard input) The github token to authentiacte against travis with.
* `--no-validate`: (*Default*: `false`) Skip validation.
* `--number-of-jobs`: Defines how many jobs the Travis integration should retrieve per polling cycle. Defaults to 100. Used for spinnaker >= 1.17.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.netflix.spinnaker.halyard.cli.command.v1.config.ci.master.AbstractAddMasterCommand;
import com.netflix.spinnaker.halyard.config.model.v1.ci.travis.TravisMaster;
import com.netflix.spinnaker.halyard.config.model.v1.node.CIAccount;
import java.util.ArrayList;
import java.util.List;

@Parameters(separators = "=")
public class TravisAddMasterCommand extends AbstractAddMasterCommand {
Expand Down Expand Up @@ -61,6 +63,11 @@ protected String getCiName() {
description = TravisCommandProperties.BUILD_RESULT_LIMIT_DESCRIPTION)
public Integer buildResultLimit;

@Parameter(
names = "--filtered-repositories",
description = TravisCommandProperties.FILTERED_REPOSITORIES_DESCRIPTION)
public List<String> filteredRepositories = new ArrayList<>();

@Override
protected CIAccount buildMaster(String masterName) {
TravisMaster master = (TravisMaster) new TravisMaster().setName(masterName);
Expand All @@ -70,7 +77,8 @@ protected CIAccount buildMaster(String masterName) {
.setGithubToken(githubToken)
.setNumberOfRepositories(numberOfRepositories)
.setNumberOfJobs(numberOfJobs)
.setBuildResultLimit(buildResultLimit);
.setBuildResultLimit(buildResultLimit)
.setFilteredRepositories(filteredRepositories);

return master;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public class TravisCommandProperties {
+ " jobs that writes a lot of logs, which is why the default setting is a bit conservative."
+ " Defaults to 10."
+ " Used for spinnaker >= 1.17.";

static final String FILTERED_REPOSITORIES_DESCRIPTION =
"Defines the list of repositories that will be scraped. Useful if the organization has a lot of"
+ " repositories and you wish to speed things up by scanning only a subset.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.netflix.spinnaker.halyard.cli.command.v1.config.ci.master.AbstractEditMasterCommand;
import com.netflix.spinnaker.halyard.config.model.v1.ci.travis.TravisMaster;
import com.netflix.spinnaker.halyard.config.model.v1.node.CIAccount;
import java.util.ArrayList;
import java.util.List;

@Parameters(separators = "=")
public class TravisEditMasterCommand extends AbstractEditMasterCommand<TravisMaster> {
Expand Down Expand Up @@ -55,6 +57,11 @@ protected String getCiName() {
description = TravisCommandProperties.BUILD_RESULT_LIMIT_DESCRIPTION)
public Integer buildResultLimit;

@Parameter(
names = "--filtered-repositories",
description = TravisCommandProperties.FILTERED_REPOSITORIES_DESCRIPTION)
public List<String> filteredRepositories = new ArrayList<>();

@Override
protected CIAccount editMaster(TravisMaster master) {
master.setAddress(isSet(address) ? address : master.getAddress());
Expand All @@ -65,6 +72,8 @@ protected CIAccount editMaster(TravisMaster master) {
master.setNumberOfJobs(isSet(numberOfJobs) ? numberOfJobs : master.getNumberOfJobs());
master.setBuildResultLimit(
isSet(buildResultLimit) ? buildResultLimit : master.getBuildResultLimit());
master.setFilteredRepositories(
isSet(filteredRepositories) ? filteredRepositories : master.getFilteredRepositories());

return master;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator;
import com.netflix.spinnaker.halyard.config.model.v1.node.NodeIteratorFactory;
import com.netflix.spinnaker.halyard.config.model.v1.node.Secret;
import com.netflix.spinnaker.halyard.config.model.v1.node.ValidForSpinnakerVersion;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;

Expand All @@ -37,4 +39,9 @@ public NodeIterator getChildren() {
private Integer numberOfRepositories;
private Integer numberOfJobs;
private Integer buildResultLimit;

@ValidForSpinnakerVersion(
lowerBound = "1.22.0",
tooLowMessage = "Filtered repositories is not supported prior to this release.")
private List<String> filteredRepositories;
}

0 comments on commit 3fee73a

Please sign in to comment.