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

Make it possible to add annotations to the keys secret #3484

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sdahlbac
Copy link
Contributor

Add command line option --keys-secret-annotations for specifying the annotations to be added to the keys secret when doing func kubernetes deploy

Tested manually using

--keys-secret-annotations reflector.v1.k8s.emberstack.com/reflection-allowed=true,reflector.v1.k8s.emberstack.com/reflection-auto-enabled=true,reflector.v1.k8s.emberstack.com/reflection-auto-namespaces=default

which renders the relevant bit of the keys secret like follows

...
kind: Secret
metadata:
  name: <name>
  annotations:
    reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
    reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
    reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: default

Issue describing the changes in this PR

resolves #3483

Pull request checklist

  • My changes do not require documentation changes I do not know, does it?
    • Otherwise: Documentation issue linked to PR
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

I have not ran nor added tests as I have a mac.

@sdahlbac
Copy link
Contributor Author

@microsoft-github-policy-service agree

@liliankasem
Copy link
Member

/azp run coretools.public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

liliankasem
liliankasem previously approved these changes Oct 15, 2024
@liliankasem liliankasem self-requested a review October 15, 2024 20:14
@liliankasem
Copy link
Member

lgtm but I don't want to merge this in without tests; you should be able to write unit tests on a mac (it's my primary device as well). If you're not longer able to contribute to this PR, I can speak to the team about getting this reassigned!

@liliankasem liliankasem requested a review from a team as a code owner October 17, 2024 18:16
@sdahlbac
Copy link
Contributor Author

@liliankasem
Copy link
Member

Is https://github.com/Azure/azure-functions-core-tools/blob/v4.x/CONTRIBUTING.md#running-the-test-suite incorrect then?

I believe it is outdated. It was written 7 years ago. My team just got ownership of this repo so we can work on updating this outdated information, but this might take some time given other priorities. You should be able to run tests like any normal c# project

@sdahlbac
Copy link
Contributor Author

@liliankasem I just tried getting the tests to run, or even cd test/Azure.Functions.Cli.Tests; dotnet build:

Azure.Functions.Cli.Tests.csproj contains

  <Target Name="CopyInProc8" AfterTargets="Build" Condition="'$(TargetFramework)'=='net6.0'">
    <Exec Command="xcopy /Y /I /E &quot;$(MSBuildThisFileDirectory)..\..\src\Azure.Functions.Cli\bin\$(Configuration)\$(TargetFramework)\in-proc8\*&quot; &quot;$(OutDir)in-proc8\&quot;" />
  </Target>

which for obvious? reasons is not really working on OSX

making the tests work at all seems a bit out of scope for this PR IMO.

@aishwaryabh aishwaryabh changed the base branch from v4.x to main November 26, 2024 20:25
Comment on lines 484 to +491
if (eventInfo.Source.Type == typeof(string) && double.TryParse(eventInfo.Source.Value.ToString(), out _))
{
eventInfo.Style = ScalarStyle.DoubleQuoted;
} else if (eventInfo.Source.Type == typeof(string) && bool.TryParse(eventInfo.Source.Value.ToString(), out _))
{
eventInfo.Style = ScalarStyle.DoubleQuoted;
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (eventInfo.Source.Type == typeof(string) && double.TryParse(eventInfo.Source.Value.ToString(), out _))
{
eventInfo.Style = ScalarStyle.DoubleQuoted;
} else if (eventInfo.Source.Type == typeof(string) && bool.TryParse(eventInfo.Source.Value.ToString(), out _))
{
eventInfo.Style = ScalarStyle.DoubleQuoted;
}
if (eventInfo.Source.Type == typeof(string) &&
(double.TryParse(eventInfo.Source.Value.ToString(), out _) ||
bool.TryParse(eventInfo.Source.Value.ToString(), out _)))
{
eventInfo.Style = ScalarStyle.DoubleQuoted;
}

@liliankasem
Copy link
Member

@liliankasem I just tried getting the tests to run, or even cd test/Azure.Functions.Cli.Tests; dotnet build:

Azure.Functions.Cli.Tests.csproj contains

  <Target Name="CopyInProc8" AfterTargets="Build" Condition="'$(TargetFramework)'=='net6.0'">
    <Exec Command="xcopy /Y /I /E &quot;$(MSBuildThisFileDirectory)..\..\src\Azure.Functions.Cli\bin\$(Configuration)\$(TargetFramework)\in-proc8\*&quot; &quot;$(OutDir)in-proc8\&quot;" />
  </Target>

which for obvious? reasons is not really working on OSX

making the tests work at all seems a bit out of scope for this PR IMO.

Sorry for the delay here, I missed this. this code snippet no longer exists so that shouldn't be an issue. But tests on osx are still a pain :/ Given it's such a minor change and we are in the middle of refactoring the test project, I think it's okay to merge.

Copy link
Member

@liliankasem liliankasem left a comment

Choose a reason for hiding this comment

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

minor nit on if statement format

@liliankasem
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -93,6 +95,7 @@ public override ICommandLineParserResult ParseArgs(string[] args)
SetFlag<string>("config-file", "if --write-configs is true, write configs to this file (default: 'functions.yaml')", f => ConfigFile = f);
SetFlag<string>("hash-files", "Files to hash to determine the image version", f => HashFilesPattern = f);
SetFlag<bool>("image-build", "If false, skip the docker build", f => BuildImage = f);
SetFlag<string>("keys-secret-annotations", "The annotations to add to the keys secret e.g. key1=val1,key2=val2", a => KeysSecretAnnotations = a.Split(',').Select(s => s.Split('=')).ToDictionary(k => k[0], v => v[1]));
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
SetFlag<string>("keys-secret-annotations", "The annotations to add to the keys secret e.g. key1=val1,key2=val2", a => KeysSecretAnnotations = a.Split(',').Select(s => s.Split('=')).ToDictionary(k => k[0], v => v[1]));
SetFlag<string>("key-secret-annotations", "The annotations to add to the keys secret e.g. key1=val1,key2=val2", a => KeySecretAnnotations = a.Split(',').Select(s => s.Split('=')).ToDictionary(k => k[0], v => v[1]));

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.

Add possibility to add annotations when doing func kubernetes deploy
2 participants