Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Now-DNS issue#368 #504

Merged
merged 8 commits into from
Aug 4, 2023
Merged

Added Now-DNS issue#368 #504

merged 8 commits into from
Aug 4, 2023

Conversation

CyberAustin
Copy link
Contributor

@CyberAustin CyberAustin commented Jul 15, 2023

Fixes #368

@CyberAustin CyberAustin changed the title Now dns Added Now-DNS issue#368 Jul 15, 2023
@CyberAustin
Copy link
Contributor Author

Crap. Line 137 I left a "debugging statement" in there 😄

Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks 💯 !

Just a few minor changes to be made, thanks 😉

go.mod Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please add nowdns to the list in the readme.md, and add a document docs/nowdns.md

@CyberAustin
Copy link
Contributor Author

Also please add nowdns to the list in the readme.md, and add a document docs/nowdns.md

Apparently in my sleep deprived state I neglected to add this to my last commit 😬

@CyberAustin
Copy link
Contributor Author

CyberAustin commented Jul 18, 2023

Changes made. Docker build still failing though.

Step 37/50 : RUN GOARCH="$(xcputranslate translate -targetplatform ${TARGETPLATFORM} -field arch)"     GOARM="$(xcputranslate translate -targetplatform ${TARGETPLATFORM} -field arm)"     go build -trimpath -ldflags="-s -w     -X 'main.version=$VERSION'     -X 'main.created=$CREATED'     -X 'main.commit=$COMMIT'     " -o app cmd/updater/main.go
 ---> Running in 5c6c1893196b
go: invalid GOARM: must be 5, 6, 7
The command '/bin/sh -c GOARCH="$(xcputranslate translate -targetplatform ${TARGETPLATFORM} -field arch)"     GOARM="$(xcputranslate translate -targetplatform ${TARGETPLATFORM} -field arm)"     go build -trimpath -ldflags="-s -w     -X 'main.version=$VERSION'     -X 'main.created=$CREATED'     -X 'main.commit=$COMMIT'     " -o app cmd/updater/main.go' returned a non-zero code: 2

@qdm12
Copy link
Owner

qdm12 commented Jul 18, 2023

The build fails because of go: invalid GOARM: must be 5, 6, 7 it might be a bug from xcputranslate. What's your host platform? You can do uname -a

@CyberAustin
Copy link
Contributor Author

CyberAustin commented Jul 18, 2023

Linux mint 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

How would I override it? --build-arg GOARM=5 doesn't seem to help.

edit: Well, if I delete the GOARCH and GOARM lines, it builds just fine. 😂

@CyberAustin
Copy link
Contributor Author

CyberAustin commented Jul 18, 2023

Fixed the Dockerfile. The ARG TARGETPLATFORM was blank. Everything builds fine now.

Edit: But referencing the Dockerfile from other repos, apparently it is supposed to build just fine with TARGETPLATFORM being blank. So IDK.

@CyberAustin CyberAustin requested a review from qdm12 July 18, 2023 20:33
@CyberAustin
Copy link
Contributor Author

Okay, builds inside of a GitHub codespace container just fine with the original Dockerfile. Build output below.

#1 transferring dockerfile: 32B done
#1 DONE 0.1s

#2 [internal] load .dockerignore
#2 transferring context: 35B done
#2 DONE 0.2s

#3 [internal] load metadata for docker.io/library/golang:1.20-alpine3.18
#3 DONE 0.5s

#4 [internal] load metadata for docker.io/qmcgaw/xcputranslate:v0.6.0
#4 DONE 0.5s

#5 [internal] load metadata for docker.io/qmcgaw/binpot:mockgen-v1.6.0
#5 DONE 0.5s

#6 [internal] load metadata for docker.io/qmcgaw/binpot:golangci-lint-v1.53.2
#6 DONE 0.6s

#7 [mockgen 1/1] FROM docker.io/qmcgaw/binpot:mockgen-v1.6.0@sha256:9338f2b706b42197fc5d46f02f03f8a93029b7bea9c819068cb2581f75d3d5b6
#7 DONE 0.0s

#8 [golangci-lint 1/1] FROM docker.io/qmcgaw/binpot:golangci-lint-v1.53.2@sha256:f2517d64e10011cbb98d9ae57f3ddd26d82237f139084767a001df162e1252a6
#8 DONE 0.0s

#9 [xcputranslate 1/1] FROM docker.io/qmcgaw/xcputranslate:v0.6.0@sha256:610582458e71facb54fd16cfb207e8b233afb6e15178742aa5332fd257926b74
#9 DONE 0.0s

#10 [base  1/11] FROM docker.io/library/golang:1.20-alpine3.18@sha256:7839c9f01b5502d7cb5198b2c032857023424470b3e31ae46a8261ffca72912a
#10 DONE 0.0s

#11 [internal] load build context
#11 transferring context: 18.88kB 0.0s done
#11 DONE 0.1s

#12 [base  9/11] COPY pkg/ ./pkg/
#12 CACHED

#13 [build 1/1] RUN GOARCH="$(xcputranslate translate -targetplatform linux/amd64 -field arch)"     GOARM="$(xcputranslate translate -targetplatform linux/amd64 -field arm)"     go build -trimpath -ldflags="-s -w     -X 'main.version=unknown'     -X 'main.created=an unknown date'     -X 'main.commit=unknown'     " -o app cmd/updater/main.go
#13 CACHED

#14 [base  4/11] COPY --from=xcputranslate /xcputranslate /usr/local/bin/xcputranslate
#14 CACHED

#15 [base  5/11] COPY --from=golangci-lint /bin /go/bin/golangci-lint
#15 CACHED

#16 [base  3/11] RUN apk --update add git g++ findutils
#16 CACHED

#17 [base  2/11] WORKDIR /tmp/gobuild
#17 CACHED

#18 [base  8/11] RUN go mod download
#18 CACHED

#19 [base 10/11] COPY cmd/ ./cmd/
#19 CACHED

#20 [base 11/11] COPY internal/ ./internal/
#20 CACHED

#21 [base  6/11] COPY --from=mockgen /bin /go/bin/mockgen
#21 CACHED

#22 [base  7/11] COPY go.mod go.sum ./
#22 CACHED

#23 [stage-8 1/1] COPY --from=build --chown=1000:1000 /tmp/gobuild/app /updater/app
#23 CACHED

#24 exporting to image
#24 exporting layers done
#24 writing image sha256:bececb724395b216a77f82f08132c1b7a9c0c75bdb63bf3073f328d9a8fc8661 0.0s done
#24 naming to docker.io/library/ddns-updater-blank done
#24 DONE 0.0s
WARNING: buildx: failed to read current commit information with git rev-parse --is-inside-work-tree

@qdm12
Copy link
Owner

qdm12 commented Jul 23, 2023

That's most likely because your local docker is a bit outdated or doesn't use buildkit/buildx, which should set TARGETPLATFORM to linux/amd64 in your case automatically.

Now I'm trying to figure out how to prevent this issue arising again on such Docker setups.

First, there is a bug where TARGETPLATFORM cannot have a default in the Dockerfile: docker/buildx#510 so setting it to linux/amd64 won't work for cross compilation.

As it is, xcputranslate fails and exits with 1, for example xcputranslate translate -targetplatform "" -field arch produces

Fatal error: invalid platform: string is malformed: ""
exit status 1

But because it's wrapped in a subshell in GOARCH="$(xcputranslate translate -targetplatform ${TARGETPLATFORM} -field arch)", the command is only silently failing and really GOARM is set to Fatal error: invalid platform: string is malformed: ""... Maybe you would have an idea how to fix the GOARCH and GOARM lines in the Dockerfile so it crashes if xcputranslate exits with 1??

There is also an alternative where xcputranslate handles the empty TARGETPLATFORM string and outputs the current platform, but that's a bit of a pain to implement and reliably detect the platform version, so I would rather avoid.

docs/nowdns.md Outdated Show resolved Hide resolved
docs/nowdns.md Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
internal/provider/providers/nowdns/provider.go Outdated Show resolved Hide resolved
@CyberAustin CyberAustin requested a review from qdm12 July 23, 2023 15:54
Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that and it was failing to update the record.
It has to be passed as "@", otherwise the API throws a "nohost" error.
Fair point. Fixed.

If the host can only be @ (not * or abc), then remove the option host from the config and the field host in the provider struct.

@CyberAustin
Copy link
Contributor Author

CyberAustin commented Jul 24, 2023 via email

@CyberAustin
Copy link
Contributor Author

I did that and it was failing to update the record.
It has to be passed as "@", otherwise the API throws a "nohost" error.
Fair point. Fixed.

If the host can only be @ (not * or abc), then remove the option host from the config and the field host in the provider struct.

This opens up a whole lot of other issues, like having to refactor host out of the rest of the file, redefine or replace utils.ToString(p.domain, p.host, constants.NowDNS, p.ipVersion) as a variadatic function. I think I found a simpler solution that will be in the next commit that I think will work just as well.

@CyberAustin
Copy link
Contributor Author

Basically just set host to @ in the provider.go file so that it is always that way, and removed any reference to host in the documentation.

@CyberAustin CyberAustin requested a review from qdm12 July 25, 2023 19:05
Copy link
Contributor Author

@CyberAustin CyberAustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the solution is good, simple and ready to merge into master.

Copy link
Owner

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, great work 💯 Merging it 😉

side note: I went ahead and removed the host injection and host field in the struct (hardcoding @ where needed), since that was itching my brain too much to have a constant struct field and unused argument injected.

@qdm12 qdm12 merged commit 5c3e407 into qdm12:master Aug 4, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: support now-dns.com
2 participants