Skip to content

feat: refactor auth token#105

Merged
helayoty merged 1 commit intoAzure:mainfrom
helayoty:refactor-auth-token
Jun 20, 2022
Merged

feat: refactor auth token#105
helayoty merged 1 commit intoAzure:mainfrom
helayoty:refactor-auth-token

Conversation

@helayoty
Copy link
Contributor

@helayoty helayoty commented Jun 17, 2022

Description of your changes

Refactor configprovider to be "authtoken"

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

Design Doc: https://msazure.visualstudio.com/CloudNativeCompute/_git/CloudNativeCompute.wiki/pullrequest/6139435?path=/AKS/Team-Logistics/Caravel/SIG-Multi%252DCluster/Upstream/Join-%252D-Leave-workflow/Decision-Records/init-sidecar-containers.md

@helayoty helayoty requested review from Arvindthiru, minhng22 and ryanzhang-oss and removed request for ryanzhang-oss June 17, 2022 00:12
@helayoty helayoty marked this pull request as ready for review June 17, 2022 00:12
FetchToken(ctx context.Context) (AuthToken, error)
}

type AuthTokenWriter interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need a token writer interface? Is it for testing? There is no multiple implementations of this interface for the foreseeable future either.

Copy link
Contributor Author

@helayoty helayoty Jun 20, 2022

Choose a reason for hiding this comment

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

For unit testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how does this interface make the code more testable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it allows us to write to memory instead of the file system.

Comment on lines +16 to +17
refreshCalculate func(interfaces.AuthToken) time.Duration
afterFunc func(time.Duration, func()) *time.Timer
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any reason to make these functions? For test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be able to test it.

Copy link
Contributor

Choose a reason for hiding this comment

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

can they not just be a function instead? I don't get why it has to be a function pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both are functions not pointers to functions.

You might have gotten confused at afterFunc which returns a pointer to a time.Time (in order to match time.AfterFunc's signature)

@ryanzhang-oss
Copy link
Contributor

Good job refactoring the code. It looks much better now.

@codecov
Copy link

codecov bot commented Jun 20, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@13e39db). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #105   +/-   ##
=======================================
  Coverage        ?   66.82%           
=======================================
  Files           ?        3           
  Lines           ?      615           
  Branches        ?        0           
=======================================
  Hits            ?      411           
  Misses          ?      197           
  Partials        ?        7           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13e39db...7fe7fe7. Read the comment docs.

Copy link
Contributor

@ryanzhang-oss ryanzhang-oss left a comment

Choose a reason for hiding this comment

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

there is a common patten on how to use timer

@helayoty helayoty merged commit 7feffe1 into Azure:main Jun 20, 2022
@helayoty helayoty deleted the refactor-auth-token branch June 20, 2022 20:44
zhiying-lin pushed a commit to zhiying-lin/fleet that referenced this pull request Jun 25, 2025
)

Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](step-security/harden-runner@0634a26...002fdce)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Britania Rodriguez Reyes <145056127+britaniar@users.noreply.github.com>
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.

3 participants