From ce7e085be863e8838aa6a16957ec2693711d55cc Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Tue, 24 Dec 2024 10:39:12 +0300 Subject: [PATCH] env instead of manifests --- src/main/java/com/rultor/Entry.java | 13 ++++---- src/main/java/com/rultor/Toggles.java | 3 +- src/main/java/com/rultor/agents/Agents.java | 32 +++++++++---------- .../rultor/agents/daemons/StartsDaemon.java | 6 ++-- .../java/com/rultor/agents/daemons/Tail.java | 12 +++---- .../com/rultor/agents/github/CommentsTag.java | 4 +-- .../rultor/agents/github/qtn/QnVersion.java | 6 ++-- .../java/com/rultor/agents/req/Decrypt.java | 6 ++-- .../java/com/rultor/profiles/Profiles.java | 4 +-- src/main/java/com/rultor/web/RsPage.java | 10 +++--- src/main/java/com/rultor/web/TkApp.java | 4 +-- src/main/java/com/rultor/web/TkAppAuth.java | 10 +++--- .../java/com/rultor/web/TkAppFallback.java | 4 +-- .../java/com/rultor/agents/MailsTest.java | 4 +-- .../agents/github/qtn/QnVersionTest.java | 4 +-- .../com/rultor/dynamo/DyTalksITTestCase.java | 6 ++-- 16 files changed, 63 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/rultor/Entry.java b/src/main/java/com/rultor/Entry.java index 7c7ecdae21..31b1f09ffc 100644 --- a/src/main/java/com/rultor/Entry.java +++ b/src/main/java/com/rultor/Entry.java @@ -44,7 +44,6 @@ import com.jcabi.github.mock.MkGithub; import com.jcabi.github.wire.RetryCarefulWire; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; import com.jcabi.urn.URN; import com.rultor.cached.CdTalks; import com.rultor.dynamo.DyTalks; @@ -101,7 +100,7 @@ public static void main(final String... args) throws IOException { * @throws IOException If fails */ public void exec() throws IOException { - final String dsn = Manifests.read("Rultor-SentryDsn"); + final String dsn = Env.read("Rultor-SentryDsn"); if (!dsn.startsWith("test")) { Sentry.init(dsn); } @@ -133,7 +132,7 @@ public void exec() throws IOException { @Cacheable(forever = true) private Github github() throws IOException { Logger.info(this, "Connecting GitHub..."); - final String token = Manifests.read("Rultor-GithubToken"); + final String token = Env.read("Rultor-GithubToken"); final Github github; if (token.startsWith("${")) { github = new MkGithub(); @@ -164,8 +163,8 @@ private Sttc sttc() throws IOException { final Sttc sttc = new CdSttc( new ReSttc( RtSttc.make( - URN.create(Manifests.read("Rultor-SttcUrn")), - Manifests.read("Rultor-SttcToken") + URN.create(Env.read("Rultor-SttcUrn")), + Env.read("Rultor-SttcToken") ) ) ); @@ -184,10 +183,10 @@ private Sttc sttc() throws IOException { @Cacheable(forever = true) private Region dynamo() { Logger.info(this, "Connecting DynamoDB..."); - final String key = Manifests.read("Rultor-DynamoKey"); + final String key = Env.read("Rultor-DynamoKey"); Credentials creds = new Credentials.Simple( key, - Manifests.read("Rultor-DynamoSecret") + Env.read("Rultor-DynamoSecret") ); if (key.startsWith("AAAAA")) { final int port = Integer.parseInt( diff --git a/src/main/java/com/rultor/Toggles.java b/src/main/java/com/rultor/Toggles.java index 9a9b6f31d0..d9e116b178 100644 --- a/src/main/java/com/rultor/Toggles.java +++ b/src/main/java/com/rultor/Toggles.java @@ -31,7 +31,6 @@ import com.jcabi.aspects.Immutable; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; import java.io.File; import java.io.IOException; import lombok.EqualsAndHashCode; @@ -72,7 +71,7 @@ final class InFile implements Toggles { * Directory to work in. */ private static final String DIR = String.format( - "/tmp/rultor-%s", Manifests.read("Rultor-Revision") + "/tmp/rultor-%s", Env.read("Rultor-Revision") ); @Override diff --git a/src/main/java/com/rultor/agents/Agents.java b/src/main/java/com/rultor/agents/Agents.java index 6ae5874cd7..86e6d88b38 100644 --- a/src/main/java/com/rultor/agents/Agents.java +++ b/src/main/java/com/rultor/agents/Agents.java @@ -34,10 +34,10 @@ import com.jcabi.aspects.Immutable; import com.jcabi.github.Github; import com.jcabi.immutable.Array; -import com.jcabi.manifests.Manifests; import com.jcabi.s3.Region; import com.jcabi.s3.retry.ReRegion; import com.jcabi.ssh.Ssh; +import com.rultor.Env; import com.rultor.agents.aws.AwsEc2; import com.rultor.agents.aws.ConnectsInstance; import com.rultor.agents.aws.DescribesInstance; @@ -171,8 +171,8 @@ public Agents(final Github ghub, final Sttc stc) { */ public SuperAgent starter() throws IOException { final AwsEc2 aws = new AwsEc2( - Manifests.read("Rultor-EC2Key"), - Manifests.read("Rultor-EC2Secret") + Env.read("Rultor-EC2Key"), + Env.read("Rultor-EC2Secret") ); return new SuperAgent.Iterative( new Array<>( @@ -273,8 +273,8 @@ public Agent agent(final Talk talk, final Profile profile) ) ); final AwsEc2 aws = new AwsEc2( - Manifests.read("Rultor-EC2Key"), - Manifests.read("Rultor-EC2Secret") + Env.read("Rultor-EC2Key"), + Env.read("Rultor-EC2Secret") ); return new VerboseAgent( new Agent.Iterative( @@ -291,10 +291,10 @@ public Agent agent(final Talk talk, final Profile profile) new StartsInstance( profile, aws, - Manifests.read("Rultor-EC2Image"), - Manifests.read("Rultor-EC2Type"), - Manifests.read("Rultor-EC2Group"), - Manifests.read("Rultor-EC2Subnet") + Env.read("Rultor-EC2Image"), + Env.read("Rultor-EC2Type"), + Env.read("Rultor-EC2Group"), + Env.read("Rultor-EC2Subnet") ), false ) @@ -340,10 +340,10 @@ public Agent agent(final Talk talk, final Profile profile) new Tweets( this.github, new OAuthTwitter( - Manifests.read("Rultor-TwitterKey"), - Manifests.read("Rultor-TwitterSecret"), - Manifests.read("Rultor-TwitterToken"), - Manifests.read("Rultor-TwitterTokenSecret") + Env.read("Rultor-TwitterKey"), + Env.read("Rultor-TwitterSecret"), + Env.read("Rultor-TwitterToken"), + Env.read("Rultor-TwitterTokenSecret") ) ) ), @@ -361,10 +361,10 @@ public Agent agent(final Talk talk, final Profile profile) new ArchivesDaemon( new ReRegion( new Region.Simple( - Manifests.read("Rultor-S3Key"), - Manifests.read("Rultor-S3Secret") + Env.read("Rultor-S3Key"), + Env.read("Rultor-S3Secret") ) - ).bucket(Manifests.read("Rultor-S3Bucket")) + ).bucket(Env.read("Rultor-S3Bucket")) ) ), new Publishes(profile, this.github), diff --git a/src/main/java/com/rultor/agents/daemons/StartsDaemon.java b/src/main/java/com/rultor/agents/daemons/StartsDaemon.java index 8ef29f1fd7..790bf2763f 100644 --- a/src/main/java/com/rultor/agents/daemons/StartsDaemon.java +++ b/src/main/java/com/rultor/agents/daemons/StartsDaemon.java @@ -34,10 +34,10 @@ import com.jcabi.aspects.Timeable; import com.jcabi.immutable.Array; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; import com.jcabi.ssh.Shell; import com.jcabi.ssh.Ssh; import com.jcabi.xml.XML; +import com.rultor.Env; import com.rultor.Time; import com.rultor.agents.Required; import com.rultor.agents.shells.TalkShells; @@ -162,8 +162,8 @@ public String run(final XML xml) throws IOException { Ssh.escape( String.format( "%s %s", - Manifests.read("Rultor-Version"), - Manifests.read("Rultor-Revision") + Env.read("Rultor-Version"), + Env.read("Rultor-Revision") ) ) ), diff --git a/src/main/java/com/rultor/agents/daemons/Tail.java b/src/main/java/com/rultor/agents/daemons/Tail.java index 92d570faa5..442f5057a3 100644 --- a/src/main/java/com/rultor/agents/daemons/Tail.java +++ b/src/main/java/com/rultor/agents/daemons/Tail.java @@ -31,13 +31,13 @@ import com.jcabi.aspects.Immutable; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; import com.jcabi.s3.Bucket; import com.jcabi.s3.Region; import com.jcabi.s3.retry.ReRegion; import com.jcabi.ssh.Shell; import com.jcabi.ssh.Ssh; import com.jcabi.xml.XML; +import com.rultor.Env; import com.rultor.agents.shells.TalkShells; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -121,9 +121,9 @@ public InputStream read() throws IOException { new Joined( "", "rultor.com ", - Manifests.read("Rultor-Version"), + Env.read("Rultor-Version"), "/", - Manifests.read("Rultor-Version"), + Env.read("Rultor-Version"), "\n", "nothing yet, try again in 15 seconds" ), @@ -208,10 +208,10 @@ public InputStream read() throws IOException { private static Bucket bucket() { return new ReRegion( new Region.Simple( - Manifests.read("Rultor-S3Key"), - Manifests.read("Rultor-S3Secret") + Env.read("Rultor-S3Key"), + Env.read("Rultor-S3Secret") ) - ).bucket(Manifests.read("Rultor-S3Bucket")); + ).bucket(Env.read("Rultor-S3Bucket")); } } diff --git a/src/main/java/com/rultor/agents/github/CommentsTag.java b/src/main/java/com/rultor/agents/github/CommentsTag.java index f477af0e1e..31be6ccec1 100644 --- a/src/main/java/com/rultor/agents/github/CommentsTag.java +++ b/src/main/java/com/rultor/agents/github/CommentsTag.java @@ -37,8 +37,8 @@ import com.jcabi.github.Repo; import com.jcabi.github.Smarts; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; import com.jcabi.xml.XML; +import com.rultor.Env; import com.rultor.agents.AbstractAgent; import com.rultor.agents.daemons.Home; import com.rultor.spi.Profile; @@ -141,7 +141,7 @@ public Iterable process(final XML xml) throws IOException { "See #%d, release log:\n\n%s\n\nReleased by Rultor %s, see [build log](%s)", issue.number(), new CommitsLog(repo).build(prev, rel.publishedAt()), - Manifests.read("Rultor-Version"), home + Env.read("Rultor-Version"), home ) ); Logger.info(this, "tag %s created and commented", tag); diff --git a/src/main/java/com/rultor/agents/github/qtn/QnVersion.java b/src/main/java/com/rultor/agents/github/qtn/QnVersion.java index 24178ebf90..38e67a3088 100644 --- a/src/main/java/com/rultor/agents/github/qtn/QnVersion.java +++ b/src/main/java/com/rultor/agents/github/qtn/QnVersion.java @@ -32,7 +32,7 @@ import com.jcabi.aspects.Immutable; import com.jcabi.github.Comment; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import com.rultor.agents.github.Answer; import com.rultor.agents.github.Question; import com.rultor.agents.github.Req; @@ -65,8 +65,8 @@ public Req understand(final Comment.Smart comment, true, String.format( QnVersion.PHRASES.getString("QnVersion.intro"), - Manifests.read("Rultor-Version"), - Manifests.read("Rultor-Revision") + Env.read("Rultor-Version"), + Env.read("Rultor-Revision") ) ); Logger.info(this, "version request in #%d", comment.issue().number()); diff --git a/src/main/java/com/rultor/agents/req/Decrypt.java b/src/main/java/com/rultor/agents/req/Decrypt.java index d3feb94a01..a98c815bdd 100644 --- a/src/main/java/com/rultor/agents/req/Decrypt.java +++ b/src/main/java/com/rultor/agents/req/Decrypt.java @@ -30,9 +30,9 @@ package com.rultor.agents.req; import com.jcabi.aspects.Immutable; -import com.jcabi.manifests.Manifests; import com.jcabi.ssh.Ssh; import com.jcabi.xml.XML; +import com.rultor.Env; import com.rultor.agents.daemons.StartsDaemon; import com.rultor.spi.Profile; import java.io.IOException; @@ -109,7 +109,7 @@ public Iterable commands() throws IOException { this.proxy, String.format( "--verbose --recv-keys %s", - Manifests.read("Rultor-GpgPublic") + Env.read("Rultor-GpgPublic") ) ) ); @@ -168,7 +168,7 @@ public Iterable commands() throws IOException { commands.add( String.format( "gpg --batch --yes --delete-secret-keys %s", - Manifests.read("Rultor-GpgSecret") + Env.read("Rultor-GpgSecret") ) ); } diff --git a/src/main/java/com/rultor/profiles/Profiles.java b/src/main/java/com/rultor/profiles/Profiles.java index 6e9f8a1d70..2c2072d2e3 100644 --- a/src/main/java/com/rultor/profiles/Profiles.java +++ b/src/main/java/com/rultor/profiles/Profiles.java @@ -35,8 +35,8 @@ import com.jcabi.github.Repo; import com.jcabi.github.RtGithub; import com.jcabi.github.wire.RetryCarefulWire; -import com.jcabi.manifests.Manifests; import com.jcabi.xml.XML; +import com.rultor.Env; import com.rultor.agents.github.TalkIssues; import com.rultor.agents.github.qtn.DefaultBranch; import com.rultor.spi.Profile; @@ -199,7 +199,7 @@ private Profile fetch(final XML xml) throws IOException { private static Github github() { return new RtGithub( new RtGithub( - Manifests.read("Rultor-GithubToken") + Env.read("Rultor-GithubToken") ).entry().through( RetryCarefulWire.class, 100 diff --git a/src/main/java/com/rultor/web/RsPage.java b/src/main/java/com/rultor/web/RsPage.java index dac88a20eb..e6f7fed52e 100644 --- a/src/main/java/com/rultor/web/RsPage.java +++ b/src/main/java/com/rultor/web/RsPage.java @@ -29,7 +29,7 @@ */ package com.rultor.web; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import java.io.IOException; import java.util.Collection; import java.util.HashSet; @@ -101,13 +101,13 @@ private static Response make(final String xsl, final Request req, new XeLocalhost(), new XeIdentity(req), new XeFlash(req), - new XeGithubLink(req, Manifests.read("Rultor-GithubId")), + new XeGithubLink(req, Env.read("Rultor-GithubId")), new XeLogoutLink(req), new XeAppend( "version", - new XeAppend("name", Manifests.read("Rultor-Version")), - new XeAppend("revision", Manifests.read("Rultor-Revision")), - new XeAppend("date", Manifests.read("Rultor-Date")) + new XeAppend("name", Env.read("Rultor-Version")), + new XeAppend("revision", Env.read("Rultor-Revision")), + new XeAppend("date", Env.read("Rultor-Date")) ) ) ); diff --git a/src/main/java/com/rultor/web/TkApp.java b/src/main/java/com/rultor/web/TkApp.java index 5f8549f97b..d28b3c3a39 100644 --- a/src/main/java/com/rultor/web/TkApp.java +++ b/src/main/java/com/rultor/web/TkApp.java @@ -29,7 +29,7 @@ */ package com.rultor.web; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import com.rultor.Toggles; import com.rultor.spi.Pulse; import com.rultor.spi.Talks; @@ -58,7 +58,7 @@ public final class TkApp extends TkWrap { /** * Revision of rultor. */ - private static final String REV = Manifests.read("Rultor-Revision"); + private static final String REV = Env.read("Rultor-Revision"); /** * Ctor. diff --git a/src/main/java/com/rultor/web/TkAppAuth.java b/src/main/java/com/rultor/web/TkAppAuth.java index b97b5cc304..5aaa048127 100644 --- a/src/main/java/com/rultor/web/TkAppAuth.java +++ b/src/main/java/com/rultor/web/TkAppAuth.java @@ -29,7 +29,7 @@ */ package com.rultor.web; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import java.util.regex.Pattern; import org.takes.Take; import org.takes.facets.auth.PsByFlag; @@ -82,14 +82,14 @@ private static Take make(final Take take) { ), new PsChain( new PsFake( - Manifests.read("Rultor-DynamoKey").startsWith("AAAA") + Env.read("Rultor-DynamoKey").startsWith("AAAA") ), new PsByFlag( new PsByFlag.Pair( PsGithub.class.getSimpleName(), new PsGithub( - Manifests.read("Rultor-GithubId"), - Manifests.read("Rultor-GithubSecret") + Env.read("Rultor-GithubId"), + Env.read("Rultor-GithubSecret") ) ), new PsByFlag.Pair( @@ -102,7 +102,7 @@ private static Take make(final Take take) { new CcHex( new CcXor( new CcSalted(new CcCompact()), - Manifests.read("Rultor-SecurityKey") + Env.read("Rultor-SecurityKey") ) ) ) diff --git a/src/main/java/com/rultor/web/TkAppFallback.java b/src/main/java/com/rultor/web/TkAppFallback.java index c3bb645b0f..033c738a13 100644 --- a/src/main/java/com/rultor/web/TkAppFallback.java +++ b/src/main/java/com/rultor/web/TkAppFallback.java @@ -30,7 +30,7 @@ package com.rultor.web; import com.jcabi.log.Logger; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import io.sentry.Sentry; import java.io.IOException; import java.net.HttpURLConnection; @@ -57,7 +57,7 @@ final class TkAppFallback extends TkWrap { /** * Revision of rultor. */ - private static final String REV = Manifests.read("Rultor-Revision"); + private static final String REV = Env.read("Rultor-Revision"); /** * Ctor. diff --git a/src/test/java/com/rultor/agents/MailsTest.java b/src/test/java/com/rultor/agents/MailsTest.java index dc9c02499b..b629c0eb8f 100644 --- a/src/test/java/com/rultor/agents/MailsTest.java +++ b/src/test/java/com/rultor/agents/MailsTest.java @@ -31,8 +31,8 @@ import com.jcabi.email.Envelope; import com.jcabi.email.Postman; -import com.jcabi.manifests.Manifests; import com.jcabi.xml.XMLDocument; +import com.rultor.Env; import com.rultor.spi.Agent; import com.rultor.spi.Profile; import com.rultor.spi.Talk; @@ -77,7 +77,7 @@ void sendsMail() throws Exception { Matchers.allOf( Matchers.containsString("See #456, release log:"), Matchers.containsString("Released by Rultor"), - Matchers.containsString(Manifests.read("Rultor-Version")), + Matchers.containsString(Env.read("Rultor-Version")), Matchers.containsString( "see [build log](https://www.rultor.com/t/123-abcdef)" ) diff --git a/src/test/java/com/rultor/agents/github/qtn/QnVersionTest.java b/src/test/java/com/rultor/agents/github/qtn/QnVersionTest.java index 8dedf80f14..2c38879927 100644 --- a/src/test/java/com/rultor/agents/github/qtn/QnVersionTest.java +++ b/src/test/java/com/rultor/agents/github/qtn/QnVersionTest.java @@ -33,7 +33,7 @@ import com.jcabi.github.Issue; import com.jcabi.github.Repo; import com.jcabi.github.mock.MkGithub; -import com.jcabi.manifests.Manifests; +import com.rultor.Env; import com.rultor.agents.github.Req; import java.net.URI; import org.hamcrest.MatcherAssert; @@ -93,7 +93,7 @@ void repliesWithLinkToRevision() throws Exception { Matchers.containsString( String.format( "/commit/%s", - Manifests.read("Rultor-Revision") + Env.read("Rultor-Revision") ) ) ); diff --git a/src/test/java/com/rultor/dynamo/DyTalksITTestCase.java b/src/test/java/com/rultor/dynamo/DyTalksITTestCase.java index 208beb3a89..9c8412d1f0 100644 --- a/src/test/java/com/rultor/dynamo/DyTalksITTestCase.java +++ b/src/test/java/com/rultor/dynamo/DyTalksITTestCase.java @@ -33,8 +33,8 @@ import com.jcabi.dynamo.Credentials; import com.jcabi.dynamo.Region; import com.jcabi.dynamo.retry.ReRegion; -import com.jcabi.manifests.Manifests; import com.jcabi.matchers.XhtmlMatchers; +import com.rultor.Env; import com.rultor.spi.Talk; import com.rultor.spi.Talks; import java.io.IOException; @@ -213,7 +213,7 @@ public boolean matches(final Object item) { * @return Region */ private static Region dynamo() { - final String key = Manifests.read("Rultor-DynamoKey"); + final String key = Env.read("Rultor-DynamoKey"); Assumptions.assumingThat(key != null, () -> { }); MatcherAssert.assertThat( "Key should be valid", @@ -226,7 +226,7 @@ private static Region dynamo() { new Credentials.Direct( new Credentials.Simple( key, - Manifests.read("Rultor-DynamoSecret") + Env.read("Rultor-DynamoSecret") ), Integer.parseInt(DyTalksITTestCase.PORT) )