Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

manage consul catalogue #10

Merged
merged 8 commits into from
Jun 12, 2022
Merged

manage consul catalogue #10

merged 8 commits into from
Jun 12, 2022

Conversation

vincentDcmps
Copy link
Contributor

@vincentDcmps vincentDcmps commented May 21, 2022

Description

this PR bring suppport of consul catalog to get label
it's my first try in go devlelopment feel free to modify code if my work is a litle dirty

Type of change

  • Bug fix
  • New feature
  • Code style update
  • Refactoring
  • CI
  • Documentation
  • Tests
  • Other

Checklist:

  • I've read & comply with the contributing guidelines
  • I have made corresponding changes the documentation (README.md) if required.

Copy link
Owner

@calvinbui calvinbui left a comment

Choose a reason for hiding this comment

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

take a look at the GitHub CI failures too

cmd/main.go Outdated
}
}else if conf.ServiceDiscovery == config.Consul {
Copy link
Owner

Choose a reason for hiding this comment

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

you will need to run go fmt on your files

Comment on lines 10 to 12
func ListServices (consul *api.Client) (map[string][]string){

catalog:= consul.Catalog()
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
func ListServices (consul *api.Client) (map[string][]string){
catalog:= consul.Catalog()
func ListServices (consul *api.Client) (map[string][]string){
catalog:= consul.Catalog()

Comment on lines 1 to 4
package entry


type RawEntry struct {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
package entry
type RawEntry struct {
package entry
type RawEntry struct {

@@ -0,0 +1,21 @@
package entry
Copy link
Owner

Choose a reason for hiding this comment

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

why have you renamed Labels to Entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

last name for thi type was container I would like something who work in both case but we can change entry by label if ou want

Comment on lines 7 to 10
}


func (c RawEntry) GetLabelValue(label string) (string, bool) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
}
func (c RawEntry) GetLabelValue(label string) (string, bool) {
}
func (c RawEntry) GetLabelValue(label string) (string, bool) {

@vincentDcmps
Copy link
Contributor Author

I have apply a go fmt

@vincentDcmps vincentDcmps requested a review from calvinbui May 23, 2022 06:40
Copy link
Owner

@calvinbui calvinbui left a comment

Choose a reason for hiding this comment

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

can you provide some steps for me to test as well?

README.md Outdated Show resolved Hide resolved
internal/consul/services.go Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
internal/config/main.go Outdated Show resolved Hide resolved
Comment on lines +14 to +17
const (
Docker = "Docker"
Consul = "Consul"
)
Copy link
Owner

Choose a reason for hiding this comment

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

I dont find this necessary, unless you have a reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just would like test to create something like an enumeration to avoid to modify all the if the configuration variable change

@vincentDcmps
Copy link
Contributor Author

vincentDcmps commented May 24, 2022

to test you can launch a consul server

docker run \
    -d \
    -p 8500:8500 \
    -p 8600:8600/udp \
    --name=consul \
    consul agent -server -ui -node=server-1 -bootstrap-expect=1 -client=0.0.0.0```

add a service


docker exec consul /bin/sh -c "echo '{\"service\": {\"name\": \"test\", \"tags\": [\"homer.enable=true\",\"homer.name=test\",\"homer.name=test\",\"homer.service=Application\"]}}' >> /consul/config/test.json"

and reload consul config

docker exec consul consul reload

@vincentDcmps vincentDcmps requested a review from calvinbui May 26, 2022 08:57
@calvinbui
Copy link
Owner

i'm on leave, will review this when i'm back

@calvinbui
Copy link
Owner

@vincentDcmps
Copy link
Contributor Author

done

Copy link
Owner

@calvinbui calvinbui left a comment

Choose a reason for hiding this comment

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

i have tested successfully. i'll write some tests and make a release

cmd/main.go Show resolved Hide resolved
@calvinbui calvinbui merged commit 55af7b6 into calvinbui:master Jun 12, 2022
@calvinbui
Copy link
Owner

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants