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

refactor ShouldDisplaySurveyPrompt from config package to survey #6187

Merged

Conversation

tejal29
Copy link
Contributor

@tejal29 tejal29 commented Jul 11, 2021

relates to #6166

Should merge after #6185

Refactor config.ShouldDisplaySurveyPrompt to survey.ShouldDisplaySurveyPrompt and align with method survey.DisplaySurveyPrompt

Motivation:
With changes proposed in #6185, we will need the survey package to handle parsing of skaffold.yaml to check if any relevant active surveys need to be shown to users.

In this Pr

  1. Move ShouldDisplaySurveyPrompt, isSurveyPromptDisabled and recentlyPromptedOrTaken to survey package
  2. Move TestShouldDisplaySurveyPrompt , TestRecentlyPromptedOrTaken and TestIsSurveyPromptDisabled to survey package
  3. remove static current variable used for testing in survey package as mentioned by @briandealwis in Add survey config and framework to show feature surveys to skaffold users. #6185 (comment)
    Note: unfortunately we cant get rid of current in https://github.com/GoogleContainerTools/skaffold/blob/master/pkg/skaffold/config/util.go#L56 yet as the WriteConfig tests override it.
  4. Add timeutil package which has utility method to parse date string and compare time.

@google-cla google-cla bot added the cla: yes label Jul 11, 2021
@tejal29 tejal29 force-pushed the refactor_ShouldDisplaySurveyPrompt branch from ac887dd to 125f305 Compare July 11, 2021 23:17
@tejal29 tejal29 changed the base branch from master to add_surver_config July 11, 2021 23:17
@codecov
Copy link

codecov bot commented Jul 11, 2021

Codecov Report

Merging #6187 (2b6541b) into master (12e9772) will decrease coverage by 0.00%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6187      +/-   ##
==========================================
- Coverage   71.09%   71.08%   -0.01%     
==========================================
  Files         484      485       +1     
  Lines       21602    21603       +1     
==========================================
- Hits        15357    15356       -1     
- Misses       5263     5264       +1     
- Partials      982      983       +1     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/cmd.go 73.91% <33.33%> (+0.14%) ⬆️
pkg/skaffold/survey/survey.go 56.66% <83.33%> (+17.77%) ⬆️
pkg/skaffold/config/util.go 66.82% <100.00%> (-1.70%) ⬇️
pkg/skaffold/timeutil/util.go 100.00% <100.00%> (ø)
pkg/skaffold/util/tar.go 52.87% <0.00%> (-4.60%) ⬇️
pkg/skaffold/docker/parse.go 88.23% <0.00%> (+0.84%) ⬆️

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 12e9772...2b6541b. Read the comment docs.

@tejal29 tejal29 force-pushed the refactor_ShouldDisplaySurveyPrompt branch from 125f305 to 406cea6 Compare July 12, 2021 20:06
@tejal29 tejal29 force-pushed the add_surver_config branch from ef9f309 to 1b1471f Compare July 12, 2021 20:09
@tejal29 tejal29 marked this pull request as ready for review July 12, 2021 20:10
@tejal29 tejal29 requested a review from a team as a code owner July 12, 2021 20:10
@tejal29 tejal29 requested review from nkubala and removed request for a team July 12, 2021 20:10
Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

Is it worth moving recentlyPromptedOrTaken() and isSurveyPromptDisabled() (and tests) into the survey package too?

}

func isSurveyPromptDisabled(configfile string) (*ContextConfig, bool) {
func IsSurveyPromptDisabled(configfile string) (*ContextConfig, bool) {
cfg, err := GetConfigForCurrentKubectx(configfile)
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of this for-current-kubectx? Especially since we may now deploy to multiple kubecontexts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That needs a separate PR i feel. everywhere global config is resolved based on current context.
Created an issue here #6189

@tejal29 tejal29 force-pushed the refactor_ShouldDisplaySurveyPrompt branch from 3f23d60 to fd92f9a Compare July 12, 2021 20:48
Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

I thought the magic reprompting date was 2 weeks, so the 10 days threw me for a loop.

pkg/skaffold/survey/survey_test.go Outdated Show resolved Hide resolved
pkg/skaffold/survey/survey_test.go Show resolved Hide resolved
@tejal29
Copy link
Contributor Author

tejal29 commented Jul 12, 2021

I thought the magic reprompting date was 2 weeks, so the 10 days threw me for a loop.

I found it out too when test failed.

@tejal29 tejal29 force-pushed the refactor_ShouldDisplaySurveyPrompt branch from e8e4a7d to 0e7646f Compare July 12, 2021 23:00
@tejal29 tejal29 changed the base branch from add_surver_config to master July 12, 2021 23:01
@tejal29 tejal29 force-pushed the refactor_ShouldDisplaySurveyPrompt branch from 0e7646f to 2b6541b Compare July 12, 2021 23:03
@tejal29 tejal29 merged commit db90d38 into GoogleContainerTools:master Jul 12, 2021
@tejal29 tejal29 deleted the refactor_ShouldDisplaySurveyPrompt branch July 12, 2021 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants