-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve config_hash and image_digest resolving (#88)
* Read and write configHash from/to all resources * Replace digest in all resources * Check config hash in plain apps
- Loading branch information
Showing
12 changed files
with
137 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ plugins { | |
|
||
group 'io.microconfig.osdf' | ||
|
||
version '1.7.0' | ||
version '1.7.1' | ||
|
||
sourceCompatibility = 11 | ||
|
||
|
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
17 changes: 12 additions & 5 deletions
17
src/main/java/io/osdf/actions/management/deploy/smart/checker/UpToDatePlainAppChecker.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 |
---|---|---|
@@ -1,22 +1,29 @@ | ||
package io.osdf.actions.management.deploy.smart.checker; | ||
|
||
import io.osdf.common.yaml.YamlObject; | ||
import io.osdf.core.application.core.Application; | ||
import io.osdf.core.application.core.description.CoreDescription; | ||
import io.osdf.core.application.plain.PlainAppDescription; | ||
import io.osdf.core.application.plain.PlainApplication; | ||
|
||
import java.util.Optional; | ||
|
||
import static io.osdf.actions.management.deploy.smart.hash.ResourcesHashComputer.resourcesHashComputer; | ||
import static io.osdf.core.application.plain.PlainApplication.plainApplication; | ||
|
||
public class UpToDatePlainAppChecker implements UpToDateChecker { | ||
public static UpToDatePlainAppChecker upToDatePlainAppChecker() { | ||
return new UpToDatePlainAppChecker(); | ||
} | ||
|
||
@Override | ||
public boolean check(Application app) { | ||
Optional<CoreDescription> description = app.coreDescription(); | ||
PlainApplication plainApp = plainApplication(app); | ||
Optional<PlainAppDescription> description = plainApp.loadDescription(PlainAppDescription.class, "plain"); | ||
if (description.isEmpty()) return false; | ||
|
||
YamlObject deployProperties = app.files().deployProperties(); | ||
return description.get().getConfigVersion().equals(deployProperties.get("config.version")); | ||
String remoteHash = description.get().getConfigHash(); | ||
if (remoteHash == null) return false; | ||
|
||
String localHash = resourcesHashComputer().currentHash(app.files()); | ||
return remoteHash.equals(localHash); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/io/osdf/core/application/plain/PlainAppDescription.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,22 @@ | ||
package io.osdf.core.application.plain; | ||
|
||
import io.osdf.core.application.core.files.ApplicationFiles; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import static io.osdf.actions.management.deploy.smart.hash.ResourcesHashComputer.resourcesHashComputer; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PlainAppDescription { | ||
private String configHash; | ||
|
||
public static PlainAppDescription from(ApplicationFiles files) { | ||
String hash = resourcesHashComputer().currentHash(files); | ||
return new PlainAppDescription(hash); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
app: | ||
version: latest | ||
|
||
config: | ||
version: master |
9 changes: 9 additions & 0 deletions
9
src/test/resources/components/plain-app/resources/resource1.yaml
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,9 @@ | ||
kind: FakeResource | ||
metadata: | ||
name: fake | ||
labels: | ||
configHash: <CONFIG_HASH> | ||
body: | ||
image: url/image:<IMAGE_DIGEST:version> | ||
sameImage: url/image:<IMAGE_DIGEST:version> | ||
image2: url/image2:<IMAGE_DIGEST:version> |
6 changes: 6 additions & 0 deletions
6
src/test/resources/components/plain-app/resources/resource2.yaml
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,6 @@ | ||
kind: FakeResource | ||
metadata: | ||
name: fake | ||
body: | ||
randomValue: <CONFIG_HASH> | ||
image: url/image:<IMAGE_DIGEST:version> |