Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from sheroy/master
Sets an environment variable with artifact image details
- Loading branch information
Showing
12 changed files
with
196 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/cd/go/artifact/docker/registry/model/FetchArtifactConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2018 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cd.go.artifact.docker.registry.model; | ||
|
||
import cd.go.artifact.docker.registry.annotation.FieldMetadata; | ||
import cd.go.artifact.docker.registry.annotation.Validatable; | ||
import cd.go.artifact.docker.registry.annotation.ValidationError; | ||
import cd.go.artifact.docker.registry.annotation.ValidationResult; | ||
import cd.go.artifact.docker.registry.utils.Util; | ||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
public class FetchArtifactConfig implements Validatable { | ||
@Expose | ||
@SerializedName("EnvironmentVariablePrefix") | ||
@FieldMetadata(key = "EnvironmentVariablePrefix", required = false) | ||
private String environmentVariablePrefix; | ||
|
||
public FetchArtifactConfig() { | ||
} | ||
|
||
public FetchArtifactConfig(String environmentVariablePrefix) { | ||
this.environmentVariablePrefix = environmentVariablePrefix; | ||
} | ||
|
||
public static FetchArtifactConfig fromJSON(String json) { | ||
return Util.GSON.fromJson(json, FetchArtifactConfig.class); | ||
} | ||
|
||
public String getEnvironmentVariablePrefix() { | ||
return environmentVariablePrefix; | ||
} | ||
|
||
@Override | ||
public ValidationResult validate() { | ||
ValidationResult validationResult = new ValidationResult(); | ||
if (StringUtils.isNotBlank(environmentVariablePrefix) && !environmentVariablePrefix.matches("(?i)[a-z][a-z0-9_]*")) { | ||
validationResult.addError(new ValidationError("EnvironmentVariablePrefix", "Invalid environment name prefix. Valid prefixes contain characters, numbers, and underscore; and can't start with a number.")); | ||
} | ||
return validationResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
<div></div> | ||
<div class="form_item_block"> | ||
<label ng-class="{'is-invalid-label': GOINPUTNAME[EnvironmentVariablePrefix].$error.server}">Environment Variable Prefix:</label> | ||
<input ng-class="{'is-invalid-input': GOINPUTNAME[EnvironmentVariablePrefix].$error.server}" type="text" ng-model="EnvironmentVariablePrefix" placeholder="PREFIX"/> | ||
<span class="form_error form-error" ng-class="{'is-visible': GOINPUTNAME[EnvironmentVariablePrefix].$error.server}" ng-show="GOINPUTNAME[EnvironmentVariablePrefix].$error.server">{{GOINPUTNAME[EnvironmentVariablePrefix].$error.server}}</span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.